SlideShare uma empresa Scribd logo
1 de 50
Baixar para ler offline
CONTINUOUS DELIVERY
FOR MACHINE LEARNING
Workshop | 27th November | ThoughtWorks London
2
Structure of Today’s Workshop
- INTRODUCTION TO THE TOPIC
- EXERCISE 1: SETUP
- EXERCISE 2: DEPLOYMENT PIPELINE
- BREAK
- EXERCISE 3: ML PIPELINE
- DEMO: TRACKING EXPERIMENTS & MODEL MONITORING
©ThoughtWorks 2019
3
Facilitators
©ThoughtWorks 2019
Danilo Sato,
Principal Technology
Consultant
Zehra Kavasoglu,
Data Scientist
James Green,
Data Engineer
Jade Forsberg,
Software Developer
7000+ technologists with 43 offices in 14 countries
Partner for technology driven business transformation
©ThoughtWorks 2019
join.thoughtworks.com
#1
in Agile and
Continuous Delivery
100+
books written
©ThoughtWorks 2019
©ThoughtWorks 2019
TECHNIQUES
Continuous delivery
for machine
learning (CD4ML)
models
#9
TRIAL
©ThoughtWorks 2019
9
#9
CONTINUOUS INTELLIGENCE CYCLE
©ThoughtWorks 2019 8
CD4ML isn’t a technology or a
tool; it is a practice and a set of
principles. Quality is built into
software and improvement is
always possible.
But machine learning systems
have unique challenges; unlike
deterministic software, it is
difficult—or impossible—to
understand the behavior of
data-driven intelligent systems.
This poses a huge challenge
when it comes to deploying
machine learning systems in
accordance with CD principles.
9
PRODUCTIONIZING ML IS HARD
Production systems should be:
● Reproducible
● Testable
● Auditable
● Continuously Improving
HOW DO WE APPLY DECADES OF SOFTWARE DELIVERY EXPERIENCE TO
INTELLIGENT SYSTEMS?
©ThoughtWorks 2019
CD4ML isn’t a technology or a
tool; it is a practice and a set of
principles. Quality is built into
software and improvement is
always possible.
But machine learning systems
have unique challenges; unlike
deterministic software, it is
difficult—or impossible—to
understand the behavior of
data-driven intelligent systems.
This poses a huge challenge
when it comes to deploying
machine learning systems in
accordance with CD principles.
10
PRODUCTIONIZING ML IS HARD
Production systems should be:
● Reproducible
● Testable
● Auditable
● Continuously Improving
Machine Learning is:
● Non-deterministic
● Hard to test
● Hard to explain
● Hard to improve
HOW DO WE APPLY DECADES OF SOFTWARE DELIVERY EXPERIENCE TO
INTELLIGENT SYSTEMS?
©ThoughtWorks 2019
MANY SOURCES OF CHANGE
11©ThoughtWorks 2019
ModelData Code
+ +
Schema
Sampling over Time
Volume
Algorithms
More Training
Experiments
Business Needs
Bug Fixes
Configuration
“Continuous Delivery is the ability to get changes of
all types — including new features, configuration
changes, bug fixes and experiments — into
production, or into the hands of users, safely and
quickly in a sustainable way.”
- Jez Humble & Dave Farley
12©ThoughtWorks 2019
©ThoughtWorks 2019
PRINCIPLES OF CONTINUOUS DELIVERY
13
Create a Repeatable, Reliable Process for Releasing
Software
Automate Almost Everything
Build Quality In
Work in Small Batches
Keep Everything in Source Control
Done Means “Released”
Improve Continuously
WHAT DO WE NEED IN OUR STACK?
14
Doing CD with Machine Learning is still a hard problem
MODEL
PERFORMANCE
ASSESSMENT
TRACKING
VERSION
CONTROL AND
ARTIFACT
REPOSITORIES
©ThoughtWorks 2019
MODEL
MONITORING
AND
OBSERVABILITY
DISCOVERABLE
AND
ACCESSIBLE
DATA
CONTINUOUS
DELIVERY
ORCHESTRATION
TO COMBINE
PIPELINES
INFRASTRUCTURE
FOR MULTIPLE
ENVIRONMENTS
AND
EXPERIMENTS
training
data
Model Building
candidate
models
training
code
codemodeldata
PUTTING EVERYTHING TOGETHER
©ThoughtWorks 2019 15
training
data
Model Building
Model Evaluation
and
Experimentation
candidate
models
metrics
training
code
chosen
model
test
data
codemodeldata
PUTTING EVERYTHING TOGETHER
©ThoughtWorks 2019 16
training
data
Model Building
Model Evaluation
and
Experimentation
Productionize
Model
candidate
models
metrics
training
code
chosen
model
productionized
model
test
data
codemodeldata
PUTTING EVERYTHING TOGETHER
©ThoughtWorks 2019 17
training
data
Model Building
Model Evaluation
and
Experimentation
Productionize
Model
Testing
candidate
models
metrics
training
code
chosen
model
productionized
model
test
code
model
test
data
test
data
codemodeldata
PUTTING EVERYTHING TOGETHER
©ThoughtWorks 2019 18
training
data
Model Building Deployment
Model Evaluation
and
Experimentation
Productionize
Model
Testing
candidate
models
metrics
training
code
chosen
model
productionized
model
test
code
model
test
data
test
data
application
code
code and
model in
production
codemodeldata
PUTTING EVERYTHING TOGETHER
©ThoughtWorks 2019 19
training
data
Model Building Deployment
Model Evaluation
and
Experimentation
Productionize
Model
Testing
candidate
models
metrics
Monitoring and
Observability
training
code
chosen
model
productionized
model
test
code
model
test
data
test
data
application
code
code and
model in
production
production
data
codemodeldata
PUTTING EVERYTHING TOGETHER
©ThoughtWorks 2019 20
training
data
Model Building Deployment
Model Evaluation
and
Experimentation
Productionize
Model
Testing
candidate
models
metrics
Monitoring and
Observability
training
code
chosen
model
productionized
model
test
code
model
test
data
test
data
application
code
code and
model in
production
production
data
codemodeldata
PUTTING EVERYTHING TOGETHER
©ThoughtWorks 2019 21
WHAT WE WILL USE IN THIS WORKSHOP
22
There are many options for tools and technologies to implement CD4ML
©ThoughtWorks 2019
THE MACHINE
LEARNING PROBLEM
WE ARE EXPLORING
TODAY
©ThoughtWorks 2019 23
A REAL BUSINESS PROBLEM
RETAIL / SUPPLY CHAIN
Loss of sales, opportunity cost, stock waste, discounting
REQUIRES
Accurate Demand Forecasting
TYPICAL CHALLENGES
→ Predictions Are Inaccurate
→ Development Takes A Long Time
→ Difficult To Adapt To Market Change Pace
24©ThoughtWorks 2019 24
SALES FORECASTING
FOR GROCERY
RETAILER
● 4,000 items
● 50 stores
● 125,000,000 sales transactions
● 4.5 years of data
Make predictions based on data from:
25
TASK:
Predict how many of each
product will be purchased
in each store on a given
date
©ThoughtWorks 2019
THE SIMPLIFIED WEB APPLICATION
As a buyer, I want to be able to choose a product and
predict how many units the product will sell at a future date.
26©ThoughtWorks 2019
EXERCISE 1: SETUP
https://github.com/ThoughtWorksInc/continuous-intelligence-workshop
27
● Click on instructions → 1-setup.md
● Follow the steps to setup your local development
environment
● Use your assigned User ID
©ThoughtWorks 2019 27
DEPLOYMENT PIPELINE
Automates the process of building, testing, and deploying applications to production
28
Application code in
version control
repository
Container image
as deployment
artifact
Deploy container
to production
servers
©ThoughtWorks 2019
29©ThoughtWorks 2019
An Open Source Continuous Delivery server to model and visualise complex workflows
Pipeline Group
ANATOMY OF A GOCD PIPELINE
30©ThoughtWorks 2019
EXERCISE 2:
DEPLOYMENT
PIPELINE
https://github.com/ThoughtWorksInc/continuous-intelligence-workshop
31
● Click on instructions → 2-deployment-pipeline.md
● Follow the steps to setup your deployment pipeline
● GoCD URL: https://gocd.cd4ml.net
©ThoughtWorks 2019 31
BUT NOW WHAT?
● How do we retrain the model more often?
● How to deploy the retrained model to production?
● How to make sure we don’t break anything when
deploying?
● How to make sure that our modeling approach or
parameterization is still the best fit for the data?
● How to monitor our model “in the wild”?
Once your model is in production...
32©ThoughtWorks 2019 32
BASIC DATA SCIENCE WORKFLOW
33
Gather data and
extract features
Separate into
training and
validation sets
Train model and
evaluate
performance
©ThoughtWorks 2019
SALES FORECAST MODEL TRAINING PROCESS
34©ThoughtWorks 2019
download_data.py
Data splitter.py
Training Data
Validation Data
decision_tree.py
model.pkl
metrics.json
evaluation.py
CHALLENGE 1: THESE ARE LARGE FILES
35©ThoughtWorks 2019
download_data.py
Data splitter.py
Training Data
Validation Data
decision_tree.py
model.pkl
metrics.json
evaluation.py
CHALLENGE 2: AD-HOC MULTI-STEP PROCESS
36©ThoughtWorks 2019
download_data.py
Data splitter.py
Training Data
Validation Data
decision_tree.py
model.pkl
metrics.json
evaluation.py
● dvc is git porcelain for storing large files using cloud storage
● dvc connects model training steps to create reproducible workflows
SOLUTION: dvc
data science version control
37
master
change-max-depth
try-random-forest
model.pkl
decision_tree.py
model.pkl.dvc
©ThoughtWorks 2019
ANATOMY OF A DVC COMMAND
This runs a command and creates a .dvc file. The dvc file points to the
dependencies. The output files are versioned and stored in the cloud by running
dvc push.
When you use the output files (store47-2016.csv) as dependencies for the next
step, a pipeline is automatically created.
You can re-execute an entire pipeline with one command: dvc repro
38
dvc run -d src/download_data.py
-o data/raw/store47-2016.csv python src/download_data.py
©ThoughtWorks 2019 38
EXERCISE 3: MACHINE LEARNING
PIPELINE
https://github.com/ThoughtWorksInc/continuous-intelligence-workshop
39
● Click on instructions → 3-machine-learning-
pipeline.md
● Follow the steps on your local development environment
and in GoCD to create your Machine Learning pipeline
©ThoughtWorks 2019 39
HOW DO WE TRACK
EXPERIMENTS?
● Which experiments and hypothesis are being explored?
● Which algorithms are being used in each experiment?
● Which version of the code was used?
● How long does it take to run each experiment?
● What parameter and hyperparameters were used?
● How fast are my models learning?
● How do we compare results from different runs?
We need to track the scientific process and evaluate our models:
40©ThoughtWorks 2019 40
41©ThoughtWorks 2019
An Open Source platform for managing end-to-end machine learning lifecycle
DEMO: TRACKING EXPERIMENTS
42
● MLflow URL: https://mlflow.cd4ml.net
©ThoughtWorks 2019 42
HOW TO LEARN CONTINUOUSLY?
● Track model usage
● Track model inputs to find training-serving skew
● Track model outputs
● Track model interpretability outputs to identify potential
bias or overfit
● Track model fairness to understand how it behaves
against dimensions that could introduce unfair bias
We need to capture production data to improve our models:
43©ThoughtWorks 2019 43
EFK STACK
Monitoring and Observability infrastructure
44
Open Source data
collector for unified
logging
Open Source Search
Engine
Open Source web UI
to explore and
visualise data
©ThoughtWorks 2019
45©ThoughtWorks 2019
An Open Source UI that makes it easy to explore and visualise the data index in Elasticsearch
DEMO: MODEL MONITORING
46
● Kibana URL: https://kibana.cd4ml.net
©ThoughtWorks 2019 46
SUMMARY - WHAT
HAVE WE LEARNED?
©ThoughtWorks 2019 47
CD4ML
● Proper data/model versioning tools enable reproducible work to be done in
parallel.
● No need to maintain complex data processing/model training scripts.
● We can then put data science work into a Continuous Delivery workflow.
● Result: Continuous, on-demand AI development and deployment,
from research to production, in an automated fashion.
● Benefit: production AI systems that are always as smart as your data
science team.
48©ThoughtWorks 2019
QUESTIONS
©ThoughtWorks 2019 49
THANK YOU
Danilo Sato dsato@thoughtworks.com
James Green jagreen@thoughtworks.com
Jade Forsberg jade.forsberg@thoughtworks.com
Zehra Kavasoglu zehra@thoughtworks.com

Mais conteúdo relacionado

Mais procurados

Tales From a Balanced Team
Tales From a Balanced TeamTales From a Balanced Team
Tales From a Balanced Team
VMware Tanzu
 
2015-09-02.Sept ATL Demand Event_ SEND
2015-09-02.Sept ATL Demand Event_ SEND2015-09-02.Sept ATL Demand Event_ SEND
2015-09-02.Sept ATL Demand Event_ SEND
Randy Pilkenton
 

Mais procurados (20)

Designers, Developers & Dogs
Designers, Developers & DogsDesigners, Developers & Dogs
Designers, Developers & Dogs
 
Design System as a Product
Design System as a ProductDesign System as a Product
Design System as a Product
 
Technology Radar Webinar UK - Vol. 22
Technology Radar Webinar UK - Vol. 22Technology Radar Webinar UK - Vol. 22
Technology Radar Webinar UK - Vol. 22
 
From project to product mindset and onwards to product platform architectures
From project to product mindset and onwards to product platform architecturesFrom project to product mindset and onwards to product platform architectures
From project to product mindset and onwards to product platform architectures
 
The Agile Business Manifesto
The Agile Business ManifestoThe Agile Business Manifesto
The Agile Business Manifesto
 
The Disciplines of Continuous innovation
The Disciplines of Continuous innovationThe Disciplines of Continuous innovation
The Disciplines of Continuous innovation
 
Tales From a Balanced Team
Tales From a Balanced TeamTales From a Balanced Team
Tales From a Balanced Team
 
Overview of the Implementing Innovation Course
Overview of the Implementing Innovation CourseOverview of the Implementing Innovation Course
Overview of the Implementing Innovation Course
 
Building a resilient business model @ HITEC Webinar
Building a resilient business model  @ HITEC WebinarBuilding a resilient business model  @ HITEC Webinar
Building a resilient business model @ HITEC Webinar
 
recommendation = optimization(prediction)
recommendation = optimization(prediction)recommendation = optimization(prediction)
recommendation = optimization(prediction)
 
Always Be Deploying. How to make R great for machine learning in (not only) E...
Always Be Deploying. How to make R great for machine learning in (not only) E...Always Be Deploying. How to make R great for machine learning in (not only) E...
Always Be Deploying. How to make R great for machine learning in (not only) E...
 
Evidence Based Management - Measuring value to enable improvement and agility
Evidence Based Management - Measuring value to enable improvement and agilityEvidence Based Management - Measuring value to enable improvement and agility
Evidence Based Management - Measuring value to enable improvement and agility
 
How Business Model Innovation intertwines with Design Thinking and Agile Deve...
How Business Model Innovation intertwines with Design Thinking and Agile Deve...How Business Model Innovation intertwines with Design Thinking and Agile Deve...
How Business Model Innovation intertwines with Design Thinking and Agile Deve...
 
Framing Patterns
Framing PatternsFraming Patterns
Framing Patterns
 
Innovation in Custom Software Development
Innovation in Custom Software DevelopmentInnovation in Custom Software Development
Innovation in Custom Software Development
 
Project to product mindset
Project to product mindsetProject to product mindset
Project to product mindset
 
Hardware is hard(er)
Hardware is hard(er)Hardware is hard(er)
Hardware is hard(er)
 
Customer and Medical Device Development
Customer and Medical Device DevelopmentCustomer and Medical Device Development
Customer and Medical Device Development
 
2015-09-02.Sept ATL Demand Event_ SEND
2015-09-02.Sept ATL Demand Event_ SEND2015-09-02.Sept ATL Demand Event_ SEND
2015-09-02.Sept ATL Demand Event_ SEND
 
Intergen Smarts 7 (2004)
Intergen Smarts 7 (2004)Intergen Smarts 7 (2004)
Intergen Smarts 7 (2004)
 

Semelhante a Continuous Delivery for Machine Learning

Decoding Puppet & Jenkins via DevOps
Decoding Puppet & Jenkins via DevOpsDecoding Puppet & Jenkins via DevOps
Decoding Puppet & Jenkins via DevOps
Skillspeed
 

Semelhante a Continuous Delivery for Machine Learning (20)

CD4ML - ThoughtWorks MeetUp Munich Christoph Windheuser May 8th 2019
CD4ML - ThoughtWorks MeetUp Munich Christoph Windheuser May 8th 2019CD4ML - ThoughtWorks MeetUp Munich Christoph Windheuser May 8th 2019
CD4ML - ThoughtWorks MeetUp Munich Christoph Windheuser May 8th 2019
 
“Data Versioning: Towards Reproducibility in Machine Learning,” a Presentatio...
“Data Versioning: Towards Reproducibility in Machine Learning,” a Presentatio...“Data Versioning: Towards Reproducibility in Machine Learning,” a Presentatio...
“Data Versioning: Towards Reproducibility in Machine Learning,” a Presentatio...
 
Emerging Best Practises for Machine Learning Engineering (Canberra Meetup edits)
Emerging Best Practises for Machine Learning Engineering (Canberra Meetup edits)Emerging Best Practises for Machine Learning Engineering (Canberra Meetup edits)
Emerging Best Practises for Machine Learning Engineering (Canberra Meetup edits)
 
Continuous Intelligence: Keeping Your AI Application in Production (NDC Sydne...
Continuous Intelligence: Keeping Your AI Application in Production (NDC Sydne...Continuous Intelligence: Keeping Your AI Application in Production (NDC Sydne...
Continuous Intelligence: Keeping Your AI Application in Production (NDC Sydne...
 
An Engineering Digital Twin to Accelerate Time to Production
An Engineering Digital Twin to Accelerate Time to ProductionAn Engineering Digital Twin to Accelerate Time to Production
An Engineering Digital Twin to Accelerate Time to Production
 
Continuous Intelligence: Moving Machine Learning into Production Reliably
Continuous Intelligence: Moving Machine Learning into Production ReliablyContinuous Intelligence: Moving Machine Learning into Production Reliably
Continuous Intelligence: Moving Machine Learning into Production Reliably
 
Real-time Manufacturing Management for a Hybrid Process
Real-time Manufacturing Management for a Hybrid ProcessReal-time Manufacturing Management for a Hybrid Process
Real-time Manufacturing Management for a Hybrid Process
 
MACHINE LEARNING AUTOMATIONS PIPELINE WITH CI/CD
MACHINE LEARNING AUTOMATIONS PIPELINE WITH CI/CDMACHINE LEARNING AUTOMATIONS PIPELINE WITH CI/CD
MACHINE LEARNING AUTOMATIONS PIPELINE WITH CI/CD
 
Emerging Best Practises for Machine Learning Engineering- Lex Toumbourou (By ...
Emerging Best Practises for Machine Learning Engineering- Lex Toumbourou (By ...Emerging Best Practises for Machine Learning Engineering- Lex Toumbourou (By ...
Emerging Best Practises for Machine Learning Engineering- Lex Toumbourou (By ...
 
Continuous Delivery
Continuous DeliveryContinuous Delivery
Continuous Delivery
 
Continuous Deployment To The Cloud
Continuous Deployment To The CloudContinuous Deployment To The Cloud
Continuous Deployment To The Cloud
 
Decoding Puppet & Jenkins via DevOps
Decoding Puppet & Jenkins via DevOpsDecoding Puppet & Jenkins via DevOps
Decoding Puppet & Jenkins via DevOps
 
What is the best approach to tdd
What is the best approach to tddWhat is the best approach to tdd
What is the best approach to tdd
 
Full stack development best practice and toolset
Full stack development best practice and toolsetFull stack development best practice and toolset
Full stack development best practice and toolset
 
Continuous Deployment To The Cloud With Spring Cloud Pipelines @WarsawCloudNa...
Continuous Deployment To The Cloud With Spring Cloud Pipelines @WarsawCloudNa...Continuous Deployment To The Cloud With Spring Cloud Pipelines @WarsawCloudNa...
Continuous Deployment To The Cloud With Spring Cloud Pipelines @WarsawCloudNa...
 
Production-Ready Kubernetes: It's Not About Technology
Production-Ready Kubernetes: It's Not About TechnologyProduction-Ready Kubernetes: It's Not About Technology
Production-Ready Kubernetes: It's Not About Technology
 
PureApplication: Devops and Urbancode
PureApplication: Devops and UrbancodePureApplication: Devops and Urbancode
PureApplication: Devops and Urbancode
 
Why we should consider Open Hybrid Cloud.pdf
Why we should  consider Open Hybrid Cloud.pdfWhy we should  consider Open Hybrid Cloud.pdf
Why we should consider Open Hybrid Cloud.pdf
 
IBM Bluemix OpenWhisk: Interconnect 2016, Las Vegas: CCD-1088: The Future of ...
IBM Bluemix OpenWhisk: Interconnect 2016, Las Vegas: CCD-1088: The Future of ...IBM Bluemix OpenWhisk: Interconnect 2016, Las Vegas: CCD-1088: The Future of ...
IBM Bluemix OpenWhisk: Interconnect 2016, Las Vegas: CCD-1088: The Future of ...
 
IBM Bluemix Openwhisk
IBM Bluemix OpenwhiskIBM Bluemix Openwhisk
IBM Bluemix Openwhisk
 

Mais de Thoughtworks

Mais de Thoughtworks (18)

More impact with flexible teams
More impact with flexible teamsMore impact with flexible teams
More impact with flexible teams
 
Culture of Innovation
Culture of InnovationCulture of Innovation
Culture of Innovation
 
Dual-Track Agile
Dual-Track AgileDual-Track Agile
Dual-Track Agile
 
Developer Experience
Developer ExperienceDeveloper Experience
Developer Experience
 
Amazon's Culture of Innovation
Amazon's Culture of InnovationAmazon's Culture of Innovation
Amazon's Culture of Innovation
 
Error handling
Error handlingError handling
Error handling
 
Your test coverage is a lie!
Your test coverage is a lie!Your test coverage is a lie!
Your test coverage is a lie!
 
Docker container security
Docker container securityDocker container security
Docker container security
 
A Tribute to Turing
A Tribute to TuringA Tribute to Turing
A Tribute to Turing
 
Rsa maths worked out
Rsa maths worked outRsa maths worked out
Rsa maths worked out
 
Do No Harm: Do Technologists Need a Code of Ethics?
Do No Harm: Do Technologists Need a Code of Ethics?Do No Harm: Do Technologists Need a Code of Ethics?
Do No Harm: Do Technologists Need a Code of Ethics?
 
Making best-in-class security ubiquitous - Why security is no longer just an ...
Making best-in-class security ubiquitous - Why security is no longer just an ...Making best-in-class security ubiquitous - Why security is no longer just an ...
Making best-in-class security ubiquitous - Why security is no longer just an ...
 
Security by default - Building continuous cyber-resilience.
Security by default - Building continuous cyber-resilience.Security by default - Building continuous cyber-resilience.
Security by default - Building continuous cyber-resilience.
 
How to tell secrets
How to tell secretsHow to tell secrets
How to tell secrets
 
Alice has a Blue Car: Beginning the Conversation Around Ethically Aware Decis...
Alice has a Blue Car: Beginning the Conversation Around Ethically Aware Decis...Alice has a Blue Car: Beginning the Conversation Around Ethically Aware Decis...
Alice has a Blue Car: Beginning the Conversation Around Ethically Aware Decis...
 
Holistic approach to cloud adoption
Holistic approach to cloud adoptionHolistic approach to cloud adoption
Holistic approach to cloud adoption
 
Ada Lovelace Day 2019 - Sydney
Ada Lovelace Day 2019 - SydneyAda Lovelace Day 2019 - Sydney
Ada Lovelace Day 2019 - Sydney
 
Ada Lovelace Day 2019 - Brisbane
Ada Lovelace Day 2019 - BrisbaneAda Lovelace Day 2019 - Brisbane
Ada Lovelace Day 2019 - Brisbane
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Continuous Delivery for Machine Learning

  • 1. CONTINUOUS DELIVERY FOR MACHINE LEARNING Workshop | 27th November | ThoughtWorks London
  • 2. 2 Structure of Today’s Workshop - INTRODUCTION TO THE TOPIC - EXERCISE 1: SETUP - EXERCISE 2: DEPLOYMENT PIPELINE - BREAK - EXERCISE 3: ML PIPELINE - DEMO: TRACKING EXPERIMENTS & MODEL MONITORING ©ThoughtWorks 2019
  • 3. 3 Facilitators ©ThoughtWorks 2019 Danilo Sato, Principal Technology Consultant Zehra Kavasoglu, Data Scientist James Green, Data Engineer Jade Forsberg, Software Developer
  • 4. 7000+ technologists with 43 offices in 14 countries Partner for technology driven business transformation ©ThoughtWorks 2019 join.thoughtworks.com
  • 5. #1 in Agile and Continuous Delivery 100+ books written ©ThoughtWorks 2019
  • 7. TECHNIQUES Continuous delivery for machine learning (CD4ML) models #9 TRIAL ©ThoughtWorks 2019 9 #9
  • 9. CD4ML isn’t a technology or a tool; it is a practice and a set of principles. Quality is built into software and improvement is always possible. But machine learning systems have unique challenges; unlike deterministic software, it is difficult—or impossible—to understand the behavior of data-driven intelligent systems. This poses a huge challenge when it comes to deploying machine learning systems in accordance with CD principles. 9 PRODUCTIONIZING ML IS HARD Production systems should be: ● Reproducible ● Testable ● Auditable ● Continuously Improving HOW DO WE APPLY DECADES OF SOFTWARE DELIVERY EXPERIENCE TO INTELLIGENT SYSTEMS? ©ThoughtWorks 2019
  • 10. CD4ML isn’t a technology or a tool; it is a practice and a set of principles. Quality is built into software and improvement is always possible. But machine learning systems have unique challenges; unlike deterministic software, it is difficult—or impossible—to understand the behavior of data-driven intelligent systems. This poses a huge challenge when it comes to deploying machine learning systems in accordance with CD principles. 10 PRODUCTIONIZING ML IS HARD Production systems should be: ● Reproducible ● Testable ● Auditable ● Continuously Improving Machine Learning is: ● Non-deterministic ● Hard to test ● Hard to explain ● Hard to improve HOW DO WE APPLY DECADES OF SOFTWARE DELIVERY EXPERIENCE TO INTELLIGENT SYSTEMS? ©ThoughtWorks 2019
  • 11. MANY SOURCES OF CHANGE 11©ThoughtWorks 2019 ModelData Code + + Schema Sampling over Time Volume Algorithms More Training Experiments Business Needs Bug Fixes Configuration
  • 12. “Continuous Delivery is the ability to get changes of all types — including new features, configuration changes, bug fixes and experiments — into production, or into the hands of users, safely and quickly in a sustainable way.” - Jez Humble & Dave Farley 12©ThoughtWorks 2019
  • 13. ©ThoughtWorks 2019 PRINCIPLES OF CONTINUOUS DELIVERY 13 Create a Repeatable, Reliable Process for Releasing Software Automate Almost Everything Build Quality In Work in Small Batches Keep Everything in Source Control Done Means “Released” Improve Continuously
  • 14. WHAT DO WE NEED IN OUR STACK? 14 Doing CD with Machine Learning is still a hard problem MODEL PERFORMANCE ASSESSMENT TRACKING VERSION CONTROL AND ARTIFACT REPOSITORIES ©ThoughtWorks 2019 MODEL MONITORING AND OBSERVABILITY DISCOVERABLE AND ACCESSIBLE DATA CONTINUOUS DELIVERY ORCHESTRATION TO COMBINE PIPELINES INFRASTRUCTURE FOR MULTIPLE ENVIRONMENTS AND EXPERIMENTS
  • 19. training data Model Building Deployment Model Evaluation and Experimentation Productionize Model Testing candidate models metrics training code chosen model productionized model test code model test data test data application code code and model in production codemodeldata PUTTING EVERYTHING TOGETHER ©ThoughtWorks 2019 19
  • 20. training data Model Building Deployment Model Evaluation and Experimentation Productionize Model Testing candidate models metrics Monitoring and Observability training code chosen model productionized model test code model test data test data application code code and model in production production data codemodeldata PUTTING EVERYTHING TOGETHER ©ThoughtWorks 2019 20
  • 21. training data Model Building Deployment Model Evaluation and Experimentation Productionize Model Testing candidate models metrics Monitoring and Observability training code chosen model productionized model test code model test data test data application code code and model in production production data codemodeldata PUTTING EVERYTHING TOGETHER ©ThoughtWorks 2019 21
  • 22. WHAT WE WILL USE IN THIS WORKSHOP 22 There are many options for tools and technologies to implement CD4ML ©ThoughtWorks 2019
  • 23. THE MACHINE LEARNING PROBLEM WE ARE EXPLORING TODAY ©ThoughtWorks 2019 23
  • 24. A REAL BUSINESS PROBLEM RETAIL / SUPPLY CHAIN Loss of sales, opportunity cost, stock waste, discounting REQUIRES Accurate Demand Forecasting TYPICAL CHALLENGES → Predictions Are Inaccurate → Development Takes A Long Time → Difficult To Adapt To Market Change Pace 24©ThoughtWorks 2019 24
  • 25. SALES FORECASTING FOR GROCERY RETAILER ● 4,000 items ● 50 stores ● 125,000,000 sales transactions ● 4.5 years of data Make predictions based on data from: 25 TASK: Predict how many of each product will be purchased in each store on a given date ©ThoughtWorks 2019
  • 26. THE SIMPLIFIED WEB APPLICATION As a buyer, I want to be able to choose a product and predict how many units the product will sell at a future date. 26©ThoughtWorks 2019
  • 27. EXERCISE 1: SETUP https://github.com/ThoughtWorksInc/continuous-intelligence-workshop 27 ● Click on instructions → 1-setup.md ● Follow the steps to setup your local development environment ● Use your assigned User ID ©ThoughtWorks 2019 27
  • 28. DEPLOYMENT PIPELINE Automates the process of building, testing, and deploying applications to production 28 Application code in version control repository Container image as deployment artifact Deploy container to production servers ©ThoughtWorks 2019
  • 29. 29©ThoughtWorks 2019 An Open Source Continuous Delivery server to model and visualise complex workflows
  • 30. Pipeline Group ANATOMY OF A GOCD PIPELINE 30©ThoughtWorks 2019
  • 31. EXERCISE 2: DEPLOYMENT PIPELINE https://github.com/ThoughtWorksInc/continuous-intelligence-workshop 31 ● Click on instructions → 2-deployment-pipeline.md ● Follow the steps to setup your deployment pipeline ● GoCD URL: https://gocd.cd4ml.net ©ThoughtWorks 2019 31
  • 32. BUT NOW WHAT? ● How do we retrain the model more often? ● How to deploy the retrained model to production? ● How to make sure we don’t break anything when deploying? ● How to make sure that our modeling approach or parameterization is still the best fit for the data? ● How to monitor our model “in the wild”? Once your model is in production... 32©ThoughtWorks 2019 32
  • 33. BASIC DATA SCIENCE WORKFLOW 33 Gather data and extract features Separate into training and validation sets Train model and evaluate performance ©ThoughtWorks 2019
  • 34. SALES FORECAST MODEL TRAINING PROCESS 34©ThoughtWorks 2019 download_data.py Data splitter.py Training Data Validation Data decision_tree.py model.pkl metrics.json evaluation.py
  • 35. CHALLENGE 1: THESE ARE LARGE FILES 35©ThoughtWorks 2019 download_data.py Data splitter.py Training Data Validation Data decision_tree.py model.pkl metrics.json evaluation.py
  • 36. CHALLENGE 2: AD-HOC MULTI-STEP PROCESS 36©ThoughtWorks 2019 download_data.py Data splitter.py Training Data Validation Data decision_tree.py model.pkl metrics.json evaluation.py
  • 37. ● dvc is git porcelain for storing large files using cloud storage ● dvc connects model training steps to create reproducible workflows SOLUTION: dvc data science version control 37 master change-max-depth try-random-forest model.pkl decision_tree.py model.pkl.dvc ©ThoughtWorks 2019
  • 38. ANATOMY OF A DVC COMMAND This runs a command and creates a .dvc file. The dvc file points to the dependencies. The output files are versioned and stored in the cloud by running dvc push. When you use the output files (store47-2016.csv) as dependencies for the next step, a pipeline is automatically created. You can re-execute an entire pipeline with one command: dvc repro 38 dvc run -d src/download_data.py -o data/raw/store47-2016.csv python src/download_data.py ©ThoughtWorks 2019 38
  • 39. EXERCISE 3: MACHINE LEARNING PIPELINE https://github.com/ThoughtWorksInc/continuous-intelligence-workshop 39 ● Click on instructions → 3-machine-learning- pipeline.md ● Follow the steps on your local development environment and in GoCD to create your Machine Learning pipeline ©ThoughtWorks 2019 39
  • 40. HOW DO WE TRACK EXPERIMENTS? ● Which experiments and hypothesis are being explored? ● Which algorithms are being used in each experiment? ● Which version of the code was used? ● How long does it take to run each experiment? ● What parameter and hyperparameters were used? ● How fast are my models learning? ● How do we compare results from different runs? We need to track the scientific process and evaluate our models: 40©ThoughtWorks 2019 40
  • 41. 41©ThoughtWorks 2019 An Open Source platform for managing end-to-end machine learning lifecycle
  • 42. DEMO: TRACKING EXPERIMENTS 42 ● MLflow URL: https://mlflow.cd4ml.net ©ThoughtWorks 2019 42
  • 43. HOW TO LEARN CONTINUOUSLY? ● Track model usage ● Track model inputs to find training-serving skew ● Track model outputs ● Track model interpretability outputs to identify potential bias or overfit ● Track model fairness to understand how it behaves against dimensions that could introduce unfair bias We need to capture production data to improve our models: 43©ThoughtWorks 2019 43
  • 44. EFK STACK Monitoring and Observability infrastructure 44 Open Source data collector for unified logging Open Source Search Engine Open Source web UI to explore and visualise data ©ThoughtWorks 2019
  • 45. 45©ThoughtWorks 2019 An Open Source UI that makes it easy to explore and visualise the data index in Elasticsearch
  • 46. DEMO: MODEL MONITORING 46 ● Kibana URL: https://kibana.cd4ml.net ©ThoughtWorks 2019 46
  • 47. SUMMARY - WHAT HAVE WE LEARNED? ©ThoughtWorks 2019 47
  • 48. CD4ML ● Proper data/model versioning tools enable reproducible work to be done in parallel. ● No need to maintain complex data processing/model training scripts. ● We can then put data science work into a Continuous Delivery workflow. ● Result: Continuous, on-demand AI development and deployment, from research to production, in an automated fashion. ● Benefit: production AI systems that are always as smart as your data science team. 48©ThoughtWorks 2019
  • 50. THANK YOU Danilo Sato dsato@thoughtworks.com James Green jagreen@thoughtworks.com Jade Forsberg jade.forsberg@thoughtworks.com Zehra Kavasoglu zehra@thoughtworks.com