SlideShare a Scribd company logo
Machine Learning School in Seville
2nd edition
March 2020
ML Automation
jao@bigml.com
Idealized Machine Learning Workflows
Dr. Natalia Konstantinova (http://nkonst.com/machine-learning-explained-simple-words/)
Example workflow
Example workflow: Web UI
(Non) automation via Web UI
Strengths of Web UI
Simple Just clicking around
Discoverable Exploration and experimenting
Abstract Transparent error handling and scalability
(Non) automation via Web UI
Strengths of Web UI
Simple Just clicking around
Discoverable Exploration and experimenting
Abstract Transparent error handling and scalability
Problems of Web UI
Only simple Simple tasks are simple, hard tasks quickly get
hard
No automation or batch operations Clicking humans don’t
scale well
Abstracting over raw HTTP: bindings
Example workflow
Example workflow: Python bindings
from bigml.api import BigML
api = BigML()
source = 'source/5643d345f43a234ff2310a3e'
dataset = api.create_dataset(source)
api.ok(dataset)
r, s = 0.8, "seed"
train_dataset = api.create_dataset(dataset, {"rate": r, "seed": s})
test_dataset = api.create_dataset(dataset, {"rate": r, "seed": s,
"out_of_bag": True})
api.ok(train_dataset)
model = api.create_model(train_dataset)
api.ok(model)
api.ok(test_dataset)
evaluation = api.create_evaluation(model, test_dataset)
api.ok(evaluation)
Automation via bindings
Is this production code?
How do we generalize to, say, 100 datasets?
Example workflow: Python bindings
# Now do it 100 times, serially
for i in range(0, 100):
r, s = 0.8, i
train = api.create_dataset(dataset, {"rate": r, "seed": s})
test = api.create_dataset(dataset, {"rate": r, "seed": s,
"out_of_bag": True})
api.ok(train)
model.append(api.create_model(train))
api.ok(model)
api.ok(test)
evaluation.append(api.create_evaluation(model, test))
api.ok(evaluation[i])
Example workflow: Python bindings
# More efficient if we parallelize, but at what level?
for i in range(0, 100):
r, s = 0.8, i
train.append(api.create_dataset(dataset, {"rate": r, "seed": s}))
test.append(api.create_dataset(dataset, {"rate": r, "seed": s,
"out_of_bag": True})
# Do we wait here?
api.ok(train[i])
api.ok(test[i])
for i in range(0, 100):
model.append(api.create_model(train[i]))
api.ok(model[i])
for i in range(0, 100):
evaluation.append(api.create_evaluation(model, test_dataset))
api.ok(evaluation[i])
Example workflow: Python bindings
# More efficient if we parallelize, but at what level?
for i in range(0, 100):
r, s = 0.8, i
train.append(api.create_dataset(dataset, {"rate": r, "seed": s}))
test.append(api.create_dataset(dataset, {"rate": r, "seed": s,
"out_of_bag": True})
for i in range(0, 100):
# Or do we wait here?
api.ok(train[i])
model.append(api.create_model(train[i]))
for i in range(0, 100):
# and here?
api.ok(model[i])
api.ok(train[i])
evaluation.append(api.create_evaluation(model, test_dataset))
api.ok(evaluation[i])
Example workflow: Python bindings
# More efficient if we parallelize, but how do we handle errors??
for i in range(0, 100):
r, s = 0.8, i
train.append(api.create_dataset(dataset, {"rate": r, "seed": s}))
test.append(api.create_dataset(dataset, {"rate": r, "seed": s, "out_of
for i in range(0, 100):
api.ok(train[i])
model.append(api.create_model(train[i]))
for i in range(0, 100):
try:
api.ok(model[i])
api.ok(test[i])
evaluation.append(api.create_evaluation(model, test_dataset))
api.ok(evaluation[i])
except:
# How to recover if test[i] is failed? New datasets? Abort?
Client-side Machine Learning Automation
Problems of bindings-based, client solutions
Complexity Lots of details outside the problem domain
Reuse No inter-language compatibility
Scalability Client-side workflows are hard to optimize
Reproducibility Noisy, complex and hard to audit development
environment
Not enough abstraction
Machine Learning Workflows: the iceberg’s tip
Machine Learning Workflows: the iceberg’s tip
Machine Learning Workflows: the iceberg’s tip
A partial solution: CLI declarative tools
# "1-click" ensemble
bigmler --train data/iris.csv 
--number-of-models 500 
--sample-rate 0.85 
--output-dir output/iris-ensemble 
--project "ML Workshop"
# "1-click" dataset with parameterized fields
bigmler --train data/diabetes.csv 
--no-model 
--name "4-featured diabetes" 
--dataset-fields 
"plasma glucose,insulin,diabetes pedigree,diabetes" 
--output-dir output/diabetes 
--project "ML Workshop"
Not-so-easy: crossvalidation
But not that bad
bigmler analyze --cross-validation # parameterized input 
--dataset $(cat output/diabetes/dataset) 
--k-folds 3 # number of folds during validation 
--output-dir output/diabetes-validation
Machine Learning Workflows: the iceberg’s tip
Machine Learning Workflows: the iceberg’s tip
Machine Learning Workflows: the iceberg’s tip
Jeannine Takaki, Microsoft Azure Team
Machine Learning Workflows: the iceberg’s tip
Client-side Machine Learning Automation
Problems of client-side solutions
Hard to generalize Declarative client tools hide complexity at
the cost of flexibility
Hard to combine Black–box tools cannot be easily integrated
as parts of bigger client–side workflows
Hard to audit Client–side development environments are
complex and very hard to sandbox
Not enough automation
Client-side Machine Learning Automation
Problems of client-side solutions
Complex Too fine-grained, leaky abstractions
Cumbersome Error handling, network issues
Hard to reuse Tied to a single programming language
Hard to scale Parallelization again a problem
Hard to generalize Declarative client tools hide complexity at
the cost of flexibility
Hard to combine Black–box tools cannot be easily integrated
as parts of bigger client–side workflows
Hard to audit Client–side development environments are
complex and very hard to sandbox
Not enough abstraction
Client-side Machine Learning Automation
Problems of client-side solutions
Complex Too fine-grained, leaky abstractions
Cumbersome Error handling, network issues
Hard to reuse Tied to a single programming language
Hard to scale Parallelization again a problem
Hard to generalize Declarative client tools hide complexity at
the cost of flexibility
Hard to combine Black–box tools cannot be easily integrated
as parts of bigger client–side workflows
Hard to audit Client–side development environments are
complex and very hard to sandbox
Algorithmic complexity and computing resources management
problems mostly washed away are back!
Workflows galore
Workflows galore
Machine Learning Automation
Machine Learning Automation
Solution (scalability, reuse): Back to the server
Machine Learning Automation
Solution (complexity, reuse): Domain-specific languages
Machine Learning Automation
Solution (complexity, reuse): Domain-specific languages
venturebeat.com
Machine Learning Automation
Solution (complexity, reuse): Domain-specific languages
In a Nutshell
1. Workflows reified as server–side, RESTful resources
2. Domain–specific language for ML workflow automation
Back to the server
Back to the server
Workflows as RESTful Resources
Library Reusable building-block: a collection of
WhizzML definitions that can be
imported by other libraries or scripts.
Script Executable code that describes an actual
workflow.
• Imports List of libraries with code
used by the script.
• Inputs List of input values that
parameterize the workflow.
• Outputs List of values computed by
the script and returned to the user.
Execution Given a script and a complete set of
inputs, the workflow can be executed
and its outputs generated.
Server-side Workflows: the bazaar
Metaprogramming in reflective DSLs: Scriptify
Resources that create
resources that create
resources that create
resources that create
resources that create
resources that create
. . .
Example workflow: Python bindings
from bigml.api import BigML
api = BigML()
source = 'source/5643d345f43a234ff2310a3e'
dataset = api.create_dataset(source)
api.ok(dataset)
r, s = 0.8, "seed"
train_dataset = api.create_dataset(dataset, {"rate": r, "seed": s})
test_dataset = api.create_dataset(dataset, {"rate": r, "seed": s,
"out_of_bag": True})
api.ok(train_dataset)
model = api.create_model(train_dataset)
api.ok(model)
api.ok(test_dataset)
evaluation = api.create_evaluation(model, test_dataset)
api.ok(evaluation)
Syntactic Abstraction: Simple workflow
;; ML artifacts are first-class citizens,
;; we only need to talk about our domain
(let ([train-id test-id] (create-dataset-split id 0.8)
model-id (create-model train-id))
(create-evaluation test-id
model-id
{"name" "Evaluation 80/20"
"missing_strategy" 0}))
Syntactic Abstraction: Simple workflow
;; ML artifacts are first-class citizens,
;; we only need to talk about our domain
(let ([train-id test-id] (create-dataset-split id 0.8)
model-id (create-model train-id))
(create-evaluation test-id
model-id
{"name" "Evaluation 80/20"
"missing_strategy" 0}))
Ready for production!
Scalability: Trivial parallelization
;; Workflow for 1 resource
(let ([train-id test-id] (create-dataset-split id 0.8)
model-id (create-model train-id))
(create-evaluation test-id model-id))
Scalability: Trivial parallelization
;; Workflow for arbitrary number of resources
(let (splits (for (id input-datasets)
(create-dataset-split id 0.8)))
(for (s splits)
(create-evaluation (s 1) (create-model (s 0)))))
Scalability: Trivial parallelization
;; Workflow for arbitrary number of resources
(let (splits (for (id input-datasets)
(create-dataset-split id 0.8)))
(for (s splits)
(create-evaluation (s 1) (create-model (s 0)))))
Ready for production!
Scalability: Trivial parallelization
from bigml.api import BigML
api = BigML()
# choose workflow
script = 'script/567b4b5be3f2a123a690ff56'
# define parameters
inputs = {'input-dataset': 'dataset/5643d345f43a234ff2310a30'}
# execute
api.ok(api.create_execution(script, inputs))
Scalability: Trivial parallelization
from bigml.api import BigML
api = BigML()
# choose workflow
script = 'script/567b4b5be3f2a123a690de1228'
# define parameters
inputs = {'input-datasets': ['dataset/5643d345f43a234ff2310a30',
'dataset/5643d345f43a234ff2310a31',
'dataset/5643d345f43a234ff2310a32',
...]}
# execute
api.ok(api.create_execution(script, inputs))
Example: Stacked Generalization
Objective: Improve predictions by modeling the output scores
of multiple trained models.
• Create a training and a holdout set
• Create n different models on the training set (with some
difference among them; e.g., single-tree vs. ensemble vs.
logistic regression)
• Make predictions from those models on the holdout set
• Train a model to predict the class based on the other
models’ predictions
Example: Stacked Generalization
Example: Stacked Generalization
Example: Stacked Generalization
Example: Stacked Generalization
Example: Stacked Generalization
Example: Stacked Generalization
Example: Stacked Generalization
Example: Stacked Generalization
(define [train-id hold-id]
(create-random-dataset-split dataset-id 0.5))
(define models
(create* ["model" "ensemble" "logisticregression"]
{"dataset" train-id}
{"dataset" train-id "number_of_models" 20}
{"dataset" train-id}))
Example: Stacked Generalization
Example: Stacked Generalization
(define (add-prediction-column dataset model)
(let (bp (create-and-wait-batch-prediction did mid))
((fetch bp) "output_dataset_resource")))
(define pred-dataset
(reduce add-prediction-column hold-id models))
Example: Stacked Generalization
Example: Stacked Generalization
(define meta-model
(create-model pred-dataset {"excluded_fields"
(input-fields dataset-id)}))
Example: Stacked Generalization
(define [train-id hold-id]
(create-random-dataset-split input-id 0.5))
(define models
(create* ["model" "ensemble" "logisticregression"]
{"dataset" train-id}
{"dataset" train-id "number_of_models" 20}
{"dataset" train-id}))
(define (add-prediction-column dataset model)
(let (bp (create-and-wait-batch-prediction did mid))
((fetch bp) "output_dataset_resource")))
(define ds (reduce add-prediction-column hold-id models))
(define meta-model
(create-model ds {"excluded_fields"
Example: Stacked Generalization
Example: Stacked Generalization
(define [models meta-model] (read-result execution-id))
(define predictions
(for (model models)
(create-prediction model input-data)))
(define prediction-values
(for (p predictions) (prediction-value p)))
(create-prediction {"model" meta-model
"input_data" prediction-values})
Are we there yet?
Are we there yet?
Instead of coding up “do this, then
this, then this, then ...” you can say,
“try to get a good score on these
data.” In other words, “here’s what
I like, let me know when one of
your monkeys on a typewriter gets
there.”
Cassie Kozyrkov
Are we there yet?
Instead of coding up “do this, then
this, then this, then ...” you can say,
“try to get a good score on these
data.” In other words, “here’s what
I like, let me know when one of
your monkeys on a typewriter gets
there.”
Cassie Kozyrkov
• Automatic model selection
• More declarative DSLs
• Automatic feature engineering
Are we there yet?
Instead of coding up “do this, then
this, then this, then ...” you can say,
“try to get a good score on these
data.” In other words, “here’s what
I like, let me know when one of
your monkeys on a typewriter gets
there.”
Cassie Kozyrkov
• Automatic model selection – OptiML
• More declarative DSLs
• Automatic feature engineering
Are we there yet?
Instead of coding up “do this, then
this, then this, then ...” you can say,
“try to get a good score on these
data.” In other words, “here’s what
I like, let me know when one of
your monkeys on a typewriter gets
there.”
Cassie Kozyrkov
• Automatic model selection – OptiML
• More declarative DSLs – Working on it!
• Automatic feature engineering
Are we there yet?
Instead of coding up “do this, then
this, then this, then ...” you can say,
“try to get a good score on these
data.” In other words, “here’s what
I like, let me know when one of
your monkeys on a typewriter gets
there.”
Cassie Kozyrkov
• Automatic model selection – OptiML
• More declarative DSLs – Working on it!
• Automatic feature engineering – 80% of an ML project

More Related Content

PDF
Machine Learning Platformization & AutoML: Adopting ML at Scale in the Enterp...
PDF
MLSEV Virtual. ML Platformization and AutoML in the Enterprise
PDF
Large-Scale Machine Learning at Twitter
PDF
ML Infra for Netflix Recommendations - AI NEXTCon talk
PDF
MLSEV Virtual. ML: Business Perspective
PDF
Models in Minutes using AutoML
PDF
MLSEV. BigML Workshop II
PDF
AISF19 - Building Scalable, Kubernetes-Native ML/AI Pipelines with TFX, KubeF...
Machine Learning Platformization & AutoML: Adopting ML at Scale in the Enterp...
MLSEV Virtual. ML Platformization and AutoML in the Enterprise
Large-Scale Machine Learning at Twitter
ML Infra for Netflix Recommendations - AI NEXTCon talk
MLSEV Virtual. ML: Business Perspective
Models in Minutes using AutoML
MLSEV. BigML Workshop II
AISF19 - Building Scalable, Kubernetes-Native ML/AI Pipelines with TFX, KubeF...

What's hot (20)

PDF
Introduction to ML.NET
PDF
Cloud based Machine Learning Platforms, a review - Sagar Khashu
PDF
Seldon: Deploying Models at Scale
PDF
MLOps Bridging the gap between Data Scientists and Ops.
PPTX
Why is dev ops for machine learning so different - dataxdays
PDF
Home robots meet IBM Watson for Voice UI, and AI
PDF
Automatic machine learning (AutoML) 101
PPTX
Grokking Techtalk #40: AWS’s philosophy on designing MLOps platform
PDF
Machine Learning Project Lifecycle
PPTX
Notes on Deploying Machine-learning Models at Scale
PDF
AI: What's Next for Facebook
PDF
Managers guide to effective building of machine learning products
PDF
DutchMLSchool. ML Automation
PDF
The Power of Auto ML and How Does it Work
PDF
Machine Learning system architecture – Microsoft Translator, a Case Study : ...
PDF
Model Risk Management for Machine Learning
PPTX
AI in architecture
PDF
Agile Machine Learning for Real-time Recommender Systems
PDF
Data ops: Machine Learning in production
PPTX
Ai use cases
Introduction to ML.NET
Cloud based Machine Learning Platforms, a review - Sagar Khashu
Seldon: Deploying Models at Scale
MLOps Bridging the gap between Data Scientists and Ops.
Why is dev ops for machine learning so different - dataxdays
Home robots meet IBM Watson for Voice UI, and AI
Automatic machine learning (AutoML) 101
Grokking Techtalk #40: AWS’s philosophy on designing MLOps platform
Machine Learning Project Lifecycle
Notes on Deploying Machine-learning Models at Scale
AI: What's Next for Facebook
Managers guide to effective building of machine learning products
DutchMLSchool. ML Automation
The Power of Auto ML and How Does it Work
Machine Learning system architecture – Microsoft Translator, a Case Study : ...
Model Risk Management for Machine Learning
AI in architecture
Agile Machine Learning for Real-time Recommender Systems
Data ops: Machine Learning in production
Ai use cases
Ad

Similar to MLSEV Virtual. From my First BigML Project to Production (20)

PDF
DutchMLSchool 2022 - Automation
PDF
BSSML16 L10. Summary Day 2 Sessions
PDF
MLSD18. Automating Machine Learning Workflows
PDF
Automating Machine Learning Workflows: A Report from the Trenches - Jose A. O...
PDF
VSSML17 L7. REST API, Bindings, and Basic Workflows
PDF
BSSML16 L8. REST API, Bindings, and Basic Workflows
PDF
MLflow: Infrastructure for a Complete Machine Learning Life Cycle with Mani ...
PDF
MLSEV. BigML Workshop I
PDF
Azure Engineering MLOps
PDF
VSSML16 L7. REST API, Bindings, and Basic Workflows
PPTX
Why is dev ops for machine learning so different
PDF
Utilisation de MLflow pour le cycle de vie des projet Machine learning
PPTX
MOPs & ML Pipelines on GCP - Session 6, RGDC
PDF
VSSML18. REST API and Bindings
PDF
Pitfalls of machine learning in production
PDF
Reproducible AI Using PyTorch and MLflow
PPTX
Open, Secure & Transparent AI Pipelines
PDF
A survey on Machine Learning In Production (July 2018)
PDF
Reproducible AI Using PyTorch and MLflow
PDF
Rsqrd AI: ML Tooling at an AI-first Startup
DutchMLSchool 2022 - Automation
BSSML16 L10. Summary Day 2 Sessions
MLSD18. Automating Machine Learning Workflows
Automating Machine Learning Workflows: A Report from the Trenches - Jose A. O...
VSSML17 L7. REST API, Bindings, and Basic Workflows
BSSML16 L8. REST API, Bindings, and Basic Workflows
MLflow: Infrastructure for a Complete Machine Learning Life Cycle with Mani ...
MLSEV. BigML Workshop I
Azure Engineering MLOps
VSSML16 L7. REST API, Bindings, and Basic Workflows
Why is dev ops for machine learning so different
Utilisation de MLflow pour le cycle de vie des projet Machine learning
MOPs & ML Pipelines on GCP - Session 6, RGDC
VSSML18. REST API and Bindings
Pitfalls of machine learning in production
Reproducible AI Using PyTorch and MLflow
Open, Secure & Transparent AI Pipelines
A survey on Machine Learning In Production (July 2018)
Reproducible AI Using PyTorch and MLflow
Rsqrd AI: ML Tooling at an AI-first Startup
Ad

More from BigML, Inc (20)

PDF
Digital Transformation and Process Optimization in Manufacturing
PDF
DutchMLSchool 2022 - ML for AML Compliance
PDF
DutchMLSchool 2022 - Multi Perspective Anomalies
PDF
DutchMLSchool 2022 - My First Anomaly Detector
PDF
DutchMLSchool 2022 - Anomaly Detection
PDF
DutchMLSchool 2022 - History and Developments in ML
PDF
DutchMLSchool 2022 - End-to-End ML
PDF
DutchMLSchool 2022 - A Data-Driven Company
PDF
DutchMLSchool 2022 - ML in the Legal Sector
PDF
DutchMLSchool 2022 - Smart Safe Stadiums
PDF
DutchMLSchool 2022 - Process Optimization in Manufacturing Plants
PDF
DutchMLSchool 2022 - Anomaly Detection at Scale
PDF
DutchMLSchool 2022 - Citizen Development in AI
PDF
Democratizing Object Detection
PDF
BigML Release: Image Processing
PDF
Machine Learning in Retail: Know Your Customers' Customer. See Your Future
PDF
Machine Learning in Retail: ML in the Retail Sector
PDF
ML in GRC: Machine Learning in Legal Automation, How to Trust a Lawyerbot
PDF
ML in GRC: Supporting Human Decision Making for Regulatory Adherence with Mac...
PDF
ML in GRC: Cybersecurity versus Governance, Risk Management, and Compliance
Digital Transformation and Process Optimization in Manufacturing
DutchMLSchool 2022 - ML for AML Compliance
DutchMLSchool 2022 - Multi Perspective Anomalies
DutchMLSchool 2022 - My First Anomaly Detector
DutchMLSchool 2022 - Anomaly Detection
DutchMLSchool 2022 - History and Developments in ML
DutchMLSchool 2022 - End-to-End ML
DutchMLSchool 2022 - A Data-Driven Company
DutchMLSchool 2022 - ML in the Legal Sector
DutchMLSchool 2022 - Smart Safe Stadiums
DutchMLSchool 2022 - Process Optimization in Manufacturing Plants
DutchMLSchool 2022 - Anomaly Detection at Scale
DutchMLSchool 2022 - Citizen Development in AI
Democratizing Object Detection
BigML Release: Image Processing
Machine Learning in Retail: Know Your Customers' Customer. See Your Future
Machine Learning in Retail: ML in the Retail Sector
ML in GRC: Machine Learning in Legal Automation, How to Trust a Lawyerbot
ML in GRC: Supporting Human Decision Making for Regulatory Adherence with Mac...
ML in GRC: Cybersecurity versus Governance, Risk Management, and Compliance

Recently uploaded (20)

PPTX
climate analysis of Dhaka ,Banglades.pptx
PPTX
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
PPTX
STUDY DESIGN details- Lt Col Maksud (21).pptx
PPTX
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
PPTX
Supervised vs unsupervised machine learning algorithms
PPTX
1_Introduction to advance data techniques.pptx
PPTX
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
PPT
ISS -ESG Data flows What is ESG and HowHow
PPTX
IB Computer Science - Internal Assessment.pptx
PPTX
Introduction to Knowledge Engineering Part 1
PPT
Quality review (1)_presentation of this 21
PPTX
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
PPTX
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PPTX
Acceptance and paychological effects of mandatory extra coach I classes.pptx
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PDF
Fluorescence-microscope_Botany_detailed content
PPTX
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
climate analysis of Dhaka ,Banglades.pptx
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
STUDY DESIGN details- Lt Col Maksud (21).pptx
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
Supervised vs unsupervised machine learning algorithms
1_Introduction to advance data techniques.pptx
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
ISS -ESG Data flows What is ESG and HowHow
IB Computer Science - Internal Assessment.pptx
Introduction to Knowledge Engineering Part 1
Quality review (1)_presentation of this 21
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
Data_Analytics_and_PowerBI_Presentation.pptx
Acceptance and paychological effects of mandatory extra coach I classes.pptx
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
Fluorescence-microscope_Botany_detailed content
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
Introduction-to-Cloud-ComputingFinal.pptx
The THESIS FINAL-DEFENSE-PRESENTATION.pptx

MLSEV Virtual. From my First BigML Project to Production

  • 1. Machine Learning School in Seville 2nd edition March 2020
  • 3. Idealized Machine Learning Workflows Dr. Natalia Konstantinova (http://nkonst.com/machine-learning-explained-simple-words/)
  • 6. (Non) automation via Web UI Strengths of Web UI Simple Just clicking around Discoverable Exploration and experimenting Abstract Transparent error handling and scalability
  • 7. (Non) automation via Web UI Strengths of Web UI Simple Just clicking around Discoverable Exploration and experimenting Abstract Transparent error handling and scalability Problems of Web UI Only simple Simple tasks are simple, hard tasks quickly get hard No automation or batch operations Clicking humans don’t scale well
  • 8. Abstracting over raw HTTP: bindings
  • 10. Example workflow: Python bindings from bigml.api import BigML api = BigML() source = 'source/5643d345f43a234ff2310a3e' dataset = api.create_dataset(source) api.ok(dataset) r, s = 0.8, "seed" train_dataset = api.create_dataset(dataset, {"rate": r, "seed": s}) test_dataset = api.create_dataset(dataset, {"rate": r, "seed": s, "out_of_bag": True}) api.ok(train_dataset) model = api.create_model(train_dataset) api.ok(model) api.ok(test_dataset) evaluation = api.create_evaluation(model, test_dataset) api.ok(evaluation)
  • 11. Automation via bindings Is this production code? How do we generalize to, say, 100 datasets?
  • 12. Example workflow: Python bindings # Now do it 100 times, serially for i in range(0, 100): r, s = 0.8, i train = api.create_dataset(dataset, {"rate": r, "seed": s}) test = api.create_dataset(dataset, {"rate": r, "seed": s, "out_of_bag": True}) api.ok(train) model.append(api.create_model(train)) api.ok(model) api.ok(test) evaluation.append(api.create_evaluation(model, test)) api.ok(evaluation[i])
  • 13. Example workflow: Python bindings # More efficient if we parallelize, but at what level? for i in range(0, 100): r, s = 0.8, i train.append(api.create_dataset(dataset, {"rate": r, "seed": s})) test.append(api.create_dataset(dataset, {"rate": r, "seed": s, "out_of_bag": True}) # Do we wait here? api.ok(train[i]) api.ok(test[i]) for i in range(0, 100): model.append(api.create_model(train[i])) api.ok(model[i]) for i in range(0, 100): evaluation.append(api.create_evaluation(model, test_dataset)) api.ok(evaluation[i])
  • 14. Example workflow: Python bindings # More efficient if we parallelize, but at what level? for i in range(0, 100): r, s = 0.8, i train.append(api.create_dataset(dataset, {"rate": r, "seed": s})) test.append(api.create_dataset(dataset, {"rate": r, "seed": s, "out_of_bag": True}) for i in range(0, 100): # Or do we wait here? api.ok(train[i]) model.append(api.create_model(train[i])) for i in range(0, 100): # and here? api.ok(model[i]) api.ok(train[i]) evaluation.append(api.create_evaluation(model, test_dataset)) api.ok(evaluation[i])
  • 15. Example workflow: Python bindings # More efficient if we parallelize, but how do we handle errors?? for i in range(0, 100): r, s = 0.8, i train.append(api.create_dataset(dataset, {"rate": r, "seed": s})) test.append(api.create_dataset(dataset, {"rate": r, "seed": s, "out_of for i in range(0, 100): api.ok(train[i]) model.append(api.create_model(train[i])) for i in range(0, 100): try: api.ok(model[i]) api.ok(test[i]) evaluation.append(api.create_evaluation(model, test_dataset)) api.ok(evaluation[i]) except: # How to recover if test[i] is failed? New datasets? Abort?
  • 16. Client-side Machine Learning Automation Problems of bindings-based, client solutions Complexity Lots of details outside the problem domain Reuse No inter-language compatibility Scalability Client-side workflows are hard to optimize Reproducibility Noisy, complex and hard to audit development environment Not enough abstraction
  • 17. Machine Learning Workflows: the iceberg’s tip
  • 18. Machine Learning Workflows: the iceberg’s tip
  • 19. Machine Learning Workflows: the iceberg’s tip
  • 20. A partial solution: CLI declarative tools # "1-click" ensemble bigmler --train data/iris.csv --number-of-models 500 --sample-rate 0.85 --output-dir output/iris-ensemble --project "ML Workshop" # "1-click" dataset with parameterized fields bigmler --train data/diabetes.csv --no-model --name "4-featured diabetes" --dataset-fields "plasma glucose,insulin,diabetes pedigree,diabetes" --output-dir output/diabetes --project "ML Workshop"
  • 22. But not that bad bigmler analyze --cross-validation # parameterized input --dataset $(cat output/diabetes/dataset) --k-folds 3 # number of folds during validation --output-dir output/diabetes-validation
  • 23. Machine Learning Workflows: the iceberg’s tip
  • 24. Machine Learning Workflows: the iceberg’s tip
  • 25. Machine Learning Workflows: the iceberg’s tip Jeannine Takaki, Microsoft Azure Team
  • 26. Machine Learning Workflows: the iceberg’s tip
  • 27. Client-side Machine Learning Automation Problems of client-side solutions Hard to generalize Declarative client tools hide complexity at the cost of flexibility Hard to combine Black–box tools cannot be easily integrated as parts of bigger client–side workflows Hard to audit Client–side development environments are complex and very hard to sandbox Not enough automation
  • 28. Client-side Machine Learning Automation Problems of client-side solutions Complex Too fine-grained, leaky abstractions Cumbersome Error handling, network issues Hard to reuse Tied to a single programming language Hard to scale Parallelization again a problem Hard to generalize Declarative client tools hide complexity at the cost of flexibility Hard to combine Black–box tools cannot be easily integrated as parts of bigger client–side workflows Hard to audit Client–side development environments are complex and very hard to sandbox Not enough abstraction
  • 29. Client-side Machine Learning Automation Problems of client-side solutions Complex Too fine-grained, leaky abstractions Cumbersome Error handling, network issues Hard to reuse Tied to a single programming language Hard to scale Parallelization again a problem Hard to generalize Declarative client tools hide complexity at the cost of flexibility Hard to combine Black–box tools cannot be easily integrated as parts of bigger client–side workflows Hard to audit Client–side development environments are complex and very hard to sandbox Algorithmic complexity and computing resources management problems mostly washed away are back!
  • 33. Machine Learning Automation Solution (scalability, reuse): Back to the server
  • 34. Machine Learning Automation Solution (complexity, reuse): Domain-specific languages
  • 35. Machine Learning Automation Solution (complexity, reuse): Domain-specific languages venturebeat.com
  • 36. Machine Learning Automation Solution (complexity, reuse): Domain-specific languages
  • 37. In a Nutshell 1. Workflows reified as server–side, RESTful resources 2. Domain–specific language for ML workflow automation
  • 38. Back to the server
  • 39. Back to the server
  • 40. Workflows as RESTful Resources Library Reusable building-block: a collection of WhizzML definitions that can be imported by other libraries or scripts. Script Executable code that describes an actual workflow. • Imports List of libraries with code used by the script. • Inputs List of input values that parameterize the workflow. • Outputs List of values computed by the script and returned to the user. Execution Given a script and a complete set of inputs, the workflow can be executed and its outputs generated.
  • 42. Metaprogramming in reflective DSLs: Scriptify Resources that create resources that create resources that create resources that create resources that create resources that create . . .
  • 43. Example workflow: Python bindings from bigml.api import BigML api = BigML() source = 'source/5643d345f43a234ff2310a3e' dataset = api.create_dataset(source) api.ok(dataset) r, s = 0.8, "seed" train_dataset = api.create_dataset(dataset, {"rate": r, "seed": s}) test_dataset = api.create_dataset(dataset, {"rate": r, "seed": s, "out_of_bag": True}) api.ok(train_dataset) model = api.create_model(train_dataset) api.ok(model) api.ok(test_dataset) evaluation = api.create_evaluation(model, test_dataset) api.ok(evaluation)
  • 44. Syntactic Abstraction: Simple workflow ;; ML artifacts are first-class citizens, ;; we only need to talk about our domain (let ([train-id test-id] (create-dataset-split id 0.8) model-id (create-model train-id)) (create-evaluation test-id model-id {"name" "Evaluation 80/20" "missing_strategy" 0}))
  • 45. Syntactic Abstraction: Simple workflow ;; ML artifacts are first-class citizens, ;; we only need to talk about our domain (let ([train-id test-id] (create-dataset-split id 0.8) model-id (create-model train-id)) (create-evaluation test-id model-id {"name" "Evaluation 80/20" "missing_strategy" 0})) Ready for production!
  • 46. Scalability: Trivial parallelization ;; Workflow for 1 resource (let ([train-id test-id] (create-dataset-split id 0.8) model-id (create-model train-id)) (create-evaluation test-id model-id))
  • 47. Scalability: Trivial parallelization ;; Workflow for arbitrary number of resources (let (splits (for (id input-datasets) (create-dataset-split id 0.8))) (for (s splits) (create-evaluation (s 1) (create-model (s 0)))))
  • 48. Scalability: Trivial parallelization ;; Workflow for arbitrary number of resources (let (splits (for (id input-datasets) (create-dataset-split id 0.8))) (for (s splits) (create-evaluation (s 1) (create-model (s 0))))) Ready for production!
  • 49. Scalability: Trivial parallelization from bigml.api import BigML api = BigML() # choose workflow script = 'script/567b4b5be3f2a123a690ff56' # define parameters inputs = {'input-dataset': 'dataset/5643d345f43a234ff2310a30'} # execute api.ok(api.create_execution(script, inputs))
  • 50. Scalability: Trivial parallelization from bigml.api import BigML api = BigML() # choose workflow script = 'script/567b4b5be3f2a123a690de1228' # define parameters inputs = {'input-datasets': ['dataset/5643d345f43a234ff2310a30', 'dataset/5643d345f43a234ff2310a31', 'dataset/5643d345f43a234ff2310a32', ...]} # execute api.ok(api.create_execution(script, inputs))
  • 51. Example: Stacked Generalization Objective: Improve predictions by modeling the output scores of multiple trained models. • Create a training and a holdout set • Create n different models on the training set (with some difference among them; e.g., single-tree vs. ensemble vs. logistic regression) • Make predictions from those models on the holdout set • Train a model to predict the class based on the other models’ predictions
  • 59. Example: Stacked Generalization (define [train-id hold-id] (create-random-dataset-split dataset-id 0.5)) (define models (create* ["model" "ensemble" "logisticregression"] {"dataset" train-id} {"dataset" train-id "number_of_models" 20} {"dataset" train-id}))
  • 61. Example: Stacked Generalization (define (add-prediction-column dataset model) (let (bp (create-and-wait-batch-prediction did mid)) ((fetch bp) "output_dataset_resource"))) (define pred-dataset (reduce add-prediction-column hold-id models))
  • 63. Example: Stacked Generalization (define meta-model (create-model pred-dataset {"excluded_fields" (input-fields dataset-id)}))
  • 64. Example: Stacked Generalization (define [train-id hold-id] (create-random-dataset-split input-id 0.5)) (define models (create* ["model" "ensemble" "logisticregression"] {"dataset" train-id} {"dataset" train-id "number_of_models" 20} {"dataset" train-id})) (define (add-prediction-column dataset model) (let (bp (create-and-wait-batch-prediction did mid)) ((fetch bp) "output_dataset_resource"))) (define ds (reduce add-prediction-column hold-id models)) (define meta-model (create-model ds {"excluded_fields"
  • 66. Example: Stacked Generalization (define [models meta-model] (read-result execution-id)) (define predictions (for (model models) (create-prediction model input-data))) (define prediction-values (for (p predictions) (prediction-value p))) (create-prediction {"model" meta-model "input_data" prediction-values})
  • 67. Are we there yet?
  • 68. Are we there yet? Instead of coding up “do this, then this, then this, then ...” you can say, “try to get a good score on these data.” In other words, “here’s what I like, let me know when one of your monkeys on a typewriter gets there.” Cassie Kozyrkov
  • 69. Are we there yet? Instead of coding up “do this, then this, then this, then ...” you can say, “try to get a good score on these data.” In other words, “here’s what I like, let me know when one of your monkeys on a typewriter gets there.” Cassie Kozyrkov • Automatic model selection • More declarative DSLs • Automatic feature engineering
  • 70. Are we there yet? Instead of coding up “do this, then this, then this, then ...” you can say, “try to get a good score on these data.” In other words, “here’s what I like, let me know when one of your monkeys on a typewriter gets there.” Cassie Kozyrkov • Automatic model selection – OptiML • More declarative DSLs • Automatic feature engineering
  • 71. Are we there yet? Instead of coding up “do this, then this, then this, then ...” you can say, “try to get a good score on these data.” In other words, “here’s what I like, let me know when one of your monkeys on a typewriter gets there.” Cassie Kozyrkov • Automatic model selection – OptiML • More declarative DSLs – Working on it! • Automatic feature engineering
  • 72. Are we there yet? Instead of coding up “do this, then this, then this, then ...” you can say, “try to get a good score on these data.” In other words, “here’s what I like, let me know when one of your monkeys on a typewriter gets there.” Cassie Kozyrkov • Automatic model selection – OptiML • More declarative DSLs – Working on it! • Automatic feature engineering – 80% of an ML project