machine learning in production

54
Running Machine Learning Applications In Production Sam BESSALAH @samklr

Upload: samir-bessalah

Post on 21-Apr-2017

2.200 views

Category:

Data & Analytics


0 download

TRANSCRIPT

Page 1: Machine Learning In Production

RunningMachine Learning Applications

In Production

Sam BESSALAH@samklr

Page 2: Machine Learning In Production
Page 3: Machine Learning In Production
Page 4: Machine Learning In Production
Page 5: Machine Learning In Production

Might Works well for KAGGLE!

Page 6: Machine Learning In Production

Might Works well for KAGGLE!But Kaggle isn’t real world Machine

learning!

Page 7: Machine Learning In Production
Page 8: Machine Learning In Production

In Real Life

- Trade off : Accuracy vs Interpretability cs Speed vs Infrastructure contraints

- Interpretability and Speed often beats accuracy

- Most of the time Kaggle is a feature engineering contest

- Contest oriented vs Real Product Impact

Page 9: Machine Learning In Production

But in real life … Things are less obvious

Data Engineers

Data Pipeline

Data Scientists / ML Engineers

APP

Applications Developers

Page 10: Machine Learning In Production

But in real life … Things are less obvious

Data Engineers

Data Pipeline

Data Scientists / ML Engineers

APP

Applications Developers

Innovation is often (wrongly ?) thought to be here ...

Page 11: Machine Learning In Production

http://www.slideshare.net/jssm1th/an-architecture-for-agile-machine-learning-in-realtime-applications

Page 12: Machine Learning In Production
Page 13: Machine Learning In Production

@josh_wills

Page 14: Machine Learning In Production

josh_wills

Page 15: Machine Learning In Production
Page 16: Machine Learning In Production

Production Requirements :

- Flexibility and agility

- Scalability and Performance

- Enable Real time decision making, sometimes at huge QPS at subseconds pace.

- Security

Page 17: Machine Learning In Production
Page 18: Machine Learning In Production

josh_wills

Page 19: Machine Learning In Production
Page 20: Machine Learning In Production

Machine Learning as a Software Problem

- Most ML developement patterns lead to software design anti patterns

- Dependencies in code, creeps through Models dependencies in Data

- Wasteful use of data, since most ml model selection require multiple version of data. Hence the instability of data, and of prediction services

- Breaks system isolation, leading to un-maintainable stacks

Page 21: Machine Learning In Production

In Production, Machine Learning is a Software and System Problem.

Treat it accordingly !!!!

Page 22: Machine Learning In Production
Page 23: Machine Learning In Production
Page 24: Machine Learning In Production
Page 25: Machine Learning In Production

Deployment / Model Serving

Page 26: Machine Learning In Production

Deployment / Model ServingThe Missing Part in ML

Page 27: Machine Learning In Production

- Model Serving is often ignored or left out to Back End Engineers to implement at their own liking.

- More often it involves serving an API or a Service to do the Predict function. But that not often enough.

- Software scaling can become problematic to the accuracy of the model.

- How many models are you serving?

- Are you running something else ?

- Are you updating your model in real time?

Page 28: Machine Learning In Production

Example : AirBnb

Page 29: Machine Learning In Production
Page 30: Machine Learning In Production

- Trained Models are stored in PMML files

- They serve their models via Openscoring

- They do most of the experiments in a different pipeline.

Page 31: Machine Learning In Production
Page 32: Machine Learning In Production

PMML ?

Page 33: Machine Learning In Production
Page 34: Machine Learning In Production

PMML?

- Might be the solution for some (most ?) cases

- Support many models, but lacks support for many others

- Fails to capture the evolution of your modeling process … Transformations, re encoding, etc .

- Better suited for exporting models to other systems, rather than being served to machine learning products with real user facing.

- And … XML ?? Really????

Page 35: Machine Learning In Production
Page 36: Machine Learning In Production
Page 37: Machine Learning In Production

Model Versioning - Packaging

- You usually don’t serve only one model. But a lot more. Especially when running experiments.

- You should vie to package your model in versionned way.

- Git is awesome, but not appropriate for live model serving

- Build a model repository or a model index

- I usually use fast KV store or advanced data stores to save my models

- Build a service to manage your models (Model Manager) responsible for evaluating and updating your model.

Page 38: Machine Learning In Production
Page 39: Machine Learning In Production
Page 40: Machine Learning In Production

TensorFlow Serving

Page 41: Machine Learning In Production
Page 42: Machine Learning In Production
Page 43: Machine Learning In Production

Serialization

- Remember PMML ?

- In Big Data, data has schema and proper evolution?

- Why not models ?

- Lots to choose from : Protobuf, Avro

- Use binary schema to represent and version your models

Page 44: Machine Learning In Production

Evaluation

- Business metrics often differ from core model metrics : Trade off between long term metrics and short term metrics.

- Hyperparameters

- A/B Testing - Multi Armed Bandits Problem

Page 45: Machine Learning In Production

Hyper Parameters

Netflix

Page 46: Machine Learning In Production
Page 47: Machine Learning In Production
Page 48: Machine Learning In Production

A/B Testing - Multi-armed Bandit

Page 49: Machine Learning In Production

A/B Testing - Multi-armed Bandit

Dataiku

Page 50: Machine Learning In Production

Experiments

Page 51: Machine Learning In Production
Page 52: Machine Learning In Production

Reproducibility

- How to keep track of data used for training ?

- Are notebooks enough?

- Junpyter Notebooks, Spark Notebooks, Zeppelin, etc ….

- Need for an end to end solution. Not perfect, but a workable one.

Page 53: Machine Learning In Production

I forgot many things

- Monitoring

- Pipeline tuning (one model is often fed to another one)

- RPC over REST for fast model serving ?

- How to deal with heterogeneous systems ?

- Do you really have to distribute your processing?

- Is more data better than smartly tuned algorithms?

Page 54: Machine Learning In Production