SlideShare une entreprise Scribd logo
1  sur  26
Productionalizing
Machine Learning Models:
Good, Bad and Ugly
Irina Kukuyeva, Ph.D.
SoCal Python
January 30, 2018
2
Fashion:
Consulting:
IoT
Healthcare
Media & Entertainment
Finance
CPG
Retail
Video Game Publisher
Online Advertising:
Healthcare:
Ph.D.
My Background
3
Spectrum of (Select) Production Environments
Online Advertising*
Revenue $1M+/year
Near-real time
Consulting
Revenue $3M+/year
ASAP
Fashion
Customer Retention
Near-real time
Finance
Automation
Daily
Love, love, love
leather/faux leather
jackets! Especially the
blue!
Positive sentiment
What ML Model Lifecycle Really Looks Like
what customer
described
what data
looked like
what DS
began to build
what budget
could buy
what pivot
looked like
what code
got reused
what got
tested [1]
what got
pushed to prod
what got
documented
what customer
wanted
4
Agenda
what customer
described
what data
looked like
what DS
began to build
what budget
could buy
what pivot
looked like
what code
got reused
what got
tested [1]
what got
pushed to prod
what got
documented
what customer
wanted
Step 1
(Appendix)
Step 2:
Data QA
(Other Talks)
Step 3:
ML Development
(Other Talks)
Step 4:
Pre-prod
Step 5:
Prod
Step 5:
Prod
Step 4:
Pre-prod
Step 1
(Appendix)
5
Step 4: Pre-Production
6
7
Pre-Production: Pay Down Tech Debt
Technical Debt — Borrowing against future to tradeoff between quality of
code and speed of delivery now [2], [3]
• Incur debt: write code, including ML pipelines [4]
• Pay down debt: extensively test and refactor pipeline end-to-end
[5]
→ Test 1: Joel’s Test: 12 Steps to Better Code [6]
• Spec?
• Source control? Best practices? [7]
• One-step build? Daily builds? CI?
• Bug database? Release schedule? QA?
• Fix bugs before write new code?
8
Pre-Production: Pay Down Tech Debt
[8]
9
Consulting
Daily stand-up
Sprint planning
Version control*
Fix bugs first
Bugs emailed/db
Release on bugfix
One-step build
Atlassian suite
Virtual machines
Online Advertising*
Daily stand-up
Sprint planning
—
—
Bug database
—
—
—
—
Finance
—
—
Version control*
Fix bugs first
—
—
One-step build
Trello
—
Fashion
Weekly stand-up
—
Version control
Fix bugs first
—
Release on bugfix
One-step build
PRD, Trello
Virtual env, CircleCI,
Docker
Test 1: Joel’s Test: 12 Steps to Better Code … in practice:
Pre-Production: Pay Down Tech Debt
→ Test 2: ML Test Score [9], [10]
• Data and feature quality
• Model development
• ML infrastructure
• Monitoring ML
10
Pre-Production: Pay Down Tech Debt
[11]
11
→ Other tips — ML:
• Choose simplest model, most appropriate for task and prod env
• Test model against (simulated) “ground truth” or 2nd implementation [12]
• Evaluate effects of floating point [12]
• Model validation beyond accuracy
[13]
Pre-Production: Pay Down Tech Debt
12
→ Other tips — Code:
• What is your production environment?
• Set-up logging
• Add else to if or try/except + error
• DRY → refactor
• Add regression tests
• Comment liberally (explain “why”) + up-to-date [20]
Pre-Production: Pay Down Tech Debt
[14]
13
Consulting
Minimal time to add new
feature
Unsuitable features
excluded
Online Advertising* Fashion
Test input features
(typing, pytest)
Finance
Minimal time to add new
feature
Privacy built-in
Test 2: ML Test Score … in practice:
– Data and Feature Quality –
Pre-Production: Pay Down Tech Debt
– Model Development –
Simulated ground truth Baseline model + 2nd
implementation
Rolling refresh
Performance overall +
those most likely to click
Proxy + actual metrics
Code review (PR)
Hyperparameter
optimization
(sklearn.GridSearchCV)
Baseline model
Bias correction
Proxy + actual metrics
14
Consulting
Loosely coupled fcns
Central repo for clients
Regression testing
One-step build, prod
Online Advertising*
Streaming
Fashion
Loosely coupled fcns
Streaming API (sanic)
Integration test (pytest)
One-step build, prod
Finance
Loosely coupled fcns
Streaming
One-step build, prod*
Reproducibility of
training
Pre-Production: Pay Down Tech Debt
– ML Monitoring –
Logging
Software + package
versions check
Data availability check
Logging (logging)
Evaluates empty +
factual responses
Local = prod env
(virtualenv, Docker)
Comp time (timeit)
Missing data check
Test 2: ML Test Score … in practice (cont’d):
– ML Infrastructure –
15
Test 2: ML Test Score … in practice (cont’d):
Pre-Production: Pay Down Tech Debt
Step 5: Production
16
17
Production: Deploy Code and Monitor Performance
→ One-button push to prod branch/repo
→ Model Rollout
→ Monitoring
[15]
Step 6: Post-Production
18
19
→ Documentation + QA gets cut first
→ Debugging, debugging, debugging → code is never perfect
→ Bugfix vs. Feature
→ Post-mortem
→ Use the product
→ Support and Training
Post-Production: Keep Code Up and Running
[16]
20
Post-Production: Align Business and Team Goals
→ Team targets: deadlines and revenue goals
→ Team competitions
[17]
21
Key Takeaways
→ Communication, tooling, logging, documentation, debugging
→ Automatically evaluate all components of ML pipeline
→ High model accuracy is not always the answer
→ Scope down, then scale up
[18]
22
You Did It!
Code is in prod!
Celebrate!
23
You Did It!
Code is in prod!
Celebrate!
… But not too hard. Tomorrow you start on v2.
Questions?
24
[ 1] http://www.projectcartoon.com/cartoon/1
[ 2] https://research.google.com/pubs/pub43146.html
[ 3] https://www.linkedin.com/pulse/when-your-tech-debt-comes-due-kevin-scott
[ 4] https://www.sec.gov/news/press-release/2013-222
[ 5] http://dilbert.com/strip/2017-01-03
[ 6] https://www.joelonsoftware.com/2000/08/09/the-joel-test-12-steps-to-better-code/
[ 7] https://solidgeargroup.com/wp-content/uploads/2016/07/tower_cheatsheet_white_EN_0.pdf
[ 8] http://geek-and-poke.com/geekandpoke/2014/2/23/dev-cycle-friday-evening-edition
[ 9] https://www.eecs.tufts.edu/~dsculley/papers/ml_test_score.pdf
[10] http://martin.zinkevich.org/rules_of_ml/rules_of_ml.pdf
[11] https://www.slideshare.net/Tech_InMobi/building-machine-learning-pipelines
[12] https://www.researchgate.net/publication/262569275_Testing_Scientific_Software_A_Systematic_Literature_Review
[13] https://classeval.wordpress.com/introduction/basic-evaluation-measures/
[14] https://xkcd.com/1024/ [15] https://xkcd.com/1319/
[16] https://www.devrant.io/search?term=debugging
[17] https://marketoonist.com/2015/03/hackathons.html
[18] https://s-media-cache-ak0.pinimg.com/originals/9c/25/08/9c25082f5c4d3477124356e45673d426.png
[19] https://www.pinterest.com/pin/177258935306351629/
[20] http://kellysutton.com/2017/09/01/comment-drift.html
25
References
26
Appendix: Establish Business Use Case
→ Kick-off meeting with stakeholders:
• Discuss use case, motivation and scope
• Find out about format of deliverable and how it will be used by team
• Brainstorm and discuss potential solutions
• Iron-out deadlines, checkpoints and on-going support structure
• Ask about prod env (if appropriate)
• Scope down, then scale up
• Close meeting with recap of action items
Key Takeaways: communication + clear expectations
[19]

Contenu connexe

Similaire à Productionalizing Machine Learning Models: The Good, the Bad, and the Ugly

AI projects - Lifecyle & Best Practices
AI projects - Lifecyle & Best PracticesAI projects - Lifecyle & Best Practices
AI projects - Lifecyle & Best PracticesVincent de Stoecklin
 
ODSC May 2019 - The DataOps Manifesto
ODSC May 2019 - The DataOps ManifestoODSC May 2019 - The DataOps Manifesto
ODSC May 2019 - The DataOps ManifestoDataKitchen
 
The Need for Speed
The Need for SpeedThe Need for Speed
The Need for SpeedCapgemini
 
Six cigma AJAL
Six cigma AJALSix cigma AJAL
Six cigma AJALAJAL A J
 
Project Management (October - 2014) [CBSGS - Paper Solution] {Mumbai University}
Project Management (October - 2014) [CBSGS - Paper Solution] {Mumbai University}Project Management (October - 2014) [CBSGS - Paper Solution] {Mumbai University}
Project Management (October - 2014) [CBSGS - Paper Solution] {Mumbai University}Mumbai B.Sc.IT Study
 
Technology-Driven Development: Using Automation and Development Techniques to...
Technology-Driven Development: Using Automation and Development Techniques to...Technology-Driven Development: Using Automation and Development Techniques to...
Technology-Driven Development: Using Automation and Development Techniques to...Hiroyuki Ito
 
[Rakuten TechConf2014] [C-6] Japan ICHIBA Daily Work - Tools & Processes
[Rakuten TechConf2014] [C-6] Japan ICHIBA Daily Work - Tools & Processes[Rakuten TechConf2014] [C-6] Japan ICHIBA Daily Work - Tools & Processes
[Rakuten TechConf2014] [C-6] Japan ICHIBA Daily Work - Tools & ProcessesRakuten Group, Inc.
 
Legacy code - Taming The Beast
Legacy code  - Taming The BeastLegacy code  - Taming The Beast
Legacy code - Taming The BeastSARCCOM
 
CH-2.1 Conceptualizing and Initializing the IT Project.ppt
CH-2.1 Conceptualizing and Initializing the IT Project.pptCH-2.1 Conceptualizing and Initializing the IT Project.ppt
CH-2.1 Conceptualizing and Initializing the IT Project.pptamanuel236786
 
Using Data Science to Build an End-to-End Recommendation System
Using Data Science to Build an End-to-End Recommendation SystemUsing Data Science to Build an End-to-End Recommendation System
Using Data Science to Build an End-to-End Recommendation SystemVMware Tanzu
 
How to Prepare for Product Based Companies?
How to Prepare for Product Based Companies?How to Prepare for Product Based Companies?
How to Prepare for Product Based Companies?Joel Kingsley
 
EBE 2020 How METRO & Ciklum built a new B2B marketplace
EBE 2020 How METRO & Ciklum built a new B2B marketplaceEBE 2020 How METRO & Ciklum built a new B2B marketplace
EBE 2020 How METRO & Ciklum built a new B2B marketplaceE-Commerce Berlin EXPO
 
ContentsTeam Work Schedule3Team Task Assignment3Project .docx
ContentsTeam Work Schedule3Team Task Assignment3Project .docxContentsTeam Work Schedule3Team Task Assignment3Project .docx
ContentsTeam Work Schedule3Team Task Assignment3Project .docxbobbywlane695641
 
7 Steps Big Data Journey for Enterprises
7 Steps Big Data Journey for Enterprises7 Steps Big Data Journey for Enterprises
7 Steps Big Data Journey for EnterprisesRaju Shreewastava
 
Continuous Intelligence Workshop
Continuous Intelligence WorkshopContinuous Intelligence Workshop
Continuous Intelligence WorkshopDavid Tan
 

Similaire à Productionalizing Machine Learning Models: The Good, the Bad, and the Ugly (20)

Class2
Class2Class2
Class2
 
AI projects - Lifecyle & Best Practices
AI projects - Lifecyle & Best PracticesAI projects - Lifecyle & Best Practices
AI projects - Lifecyle & Best Practices
 
ODSC May 2019 - The DataOps Manifesto
ODSC May 2019 - The DataOps ManifestoODSC May 2019 - The DataOps Manifesto
ODSC May 2019 - The DataOps Manifesto
 
The Need for Speed
The Need for SpeedThe Need for Speed
The Need for Speed
 
prod-dev-management.pptx
prod-dev-management.pptxprod-dev-management.pptx
prod-dev-management.pptx
 
Six cigma AJAL
Six cigma AJALSix cigma AJAL
Six cigma AJAL
 
Project Management (October - 2014) [CBSGS - Paper Solution] {Mumbai University}
Project Management (October - 2014) [CBSGS - Paper Solution] {Mumbai University}Project Management (October - 2014) [CBSGS - Paper Solution] {Mumbai University}
Project Management (October - 2014) [CBSGS - Paper Solution] {Mumbai University}
 
Introduction to Six Sigma
Introduction to Six SigmaIntroduction to Six Sigma
Introduction to Six Sigma
 
Technology-Driven Development: Using Automation and Development Techniques to...
Technology-Driven Development: Using Automation and Development Techniques to...Technology-Driven Development: Using Automation and Development Techniques to...
Technology-Driven Development: Using Automation and Development Techniques to...
 
[Rakuten TechConf2014] [C-6] Japan ICHIBA Daily Work - Tools & Processes
[Rakuten TechConf2014] [C-6] Japan ICHIBA Daily Work - Tools & Processes[Rakuten TechConf2014] [C-6] Japan ICHIBA Daily Work - Tools & Processes
[Rakuten TechConf2014] [C-6] Japan ICHIBA Daily Work - Tools & Processes
 
Legacy code - Taming The Beast
Legacy code  - Taming The BeastLegacy code  - Taming The Beast
Legacy code - Taming The Beast
 
CH-2.1 Conceptualizing and Initializing the IT Project.ppt
CH-2.1 Conceptualizing and Initializing the IT Project.pptCH-2.1 Conceptualizing and Initializing the IT Project.ppt
CH-2.1 Conceptualizing and Initializing the IT Project.ppt
 
Using Data Science to Build an End-to-End Recommendation System
Using Data Science to Build an End-to-End Recommendation SystemUsing Data Science to Build an End-to-End Recommendation System
Using Data Science to Build an End-to-End Recommendation System
 
How to Prepare for Product Based Companies?
How to Prepare for Product Based Companies?How to Prepare for Product Based Companies?
How to Prepare for Product Based Companies?
 
EBE 2020 How METRO & Ciklum built a new B2B marketplace
EBE 2020 How METRO & Ciklum built a new B2B marketplaceEBE 2020 How METRO & Ciklum built a new B2B marketplace
EBE 2020 How METRO & Ciklum built a new B2B marketplace
 
ContentsTeam Work Schedule3Team Task Assignment3Project .docx
ContentsTeam Work Schedule3Team Task Assignment3Project .docxContentsTeam Work Schedule3Team Task Assignment3Project .docx
ContentsTeam Work Schedule3Team Task Assignment3Project .docx
 
Sigma sdlc
Sigma sdlcSigma sdlc
Sigma sdlc
 
7 Steps Big Data Journey for Enterprises
7 Steps Big Data Journey for Enterprises7 Steps Big Data Journey for Enterprises
7 Steps Big Data Journey for Enterprises
 
Technical Debt.pptx
Technical Debt.pptxTechnical Debt.pptx
Technical Debt.pptx
 
Continuous Intelligence Workshop
Continuous Intelligence WorkshopContinuous Intelligence Workshop
Continuous Intelligence Workshop
 

Dernier

Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxolyaivanovalion
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystSamantha Rae Coolbeth
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxolyaivanovalion
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一ffjhghh
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 

Dernier (20)

Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data Analyst
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 

Productionalizing Machine Learning Models: The Good, the Bad, and the Ugly

  • 1. Productionalizing Machine Learning Models: Good, Bad and Ugly Irina Kukuyeva, Ph.D. SoCal Python January 30, 2018
  • 2. 2 Fashion: Consulting: IoT Healthcare Media & Entertainment Finance CPG Retail Video Game Publisher Online Advertising: Healthcare: Ph.D. My Background
  • 3. 3 Spectrum of (Select) Production Environments Online Advertising* Revenue $1M+/year Near-real time Consulting Revenue $3M+/year ASAP Fashion Customer Retention Near-real time Finance Automation Daily Love, love, love leather/faux leather jackets! Especially the blue! Positive sentiment
  • 4. What ML Model Lifecycle Really Looks Like what customer described what data looked like what DS began to build what budget could buy what pivot looked like what code got reused what got tested [1] what got pushed to prod what got documented what customer wanted 4
  • 5. Agenda what customer described what data looked like what DS began to build what budget could buy what pivot looked like what code got reused what got tested [1] what got pushed to prod what got documented what customer wanted Step 1 (Appendix) Step 2: Data QA (Other Talks) Step 3: ML Development (Other Talks) Step 4: Pre-prod Step 5: Prod Step 5: Prod Step 4: Pre-prod Step 1 (Appendix) 5
  • 7. 7 Pre-Production: Pay Down Tech Debt Technical Debt — Borrowing against future to tradeoff between quality of code and speed of delivery now [2], [3] • Incur debt: write code, including ML pipelines [4] • Pay down debt: extensively test and refactor pipeline end-to-end [5]
  • 8. → Test 1: Joel’s Test: 12 Steps to Better Code [6] • Spec? • Source control? Best practices? [7] • One-step build? Daily builds? CI? • Bug database? Release schedule? QA? • Fix bugs before write new code? 8 Pre-Production: Pay Down Tech Debt [8]
  • 9. 9 Consulting Daily stand-up Sprint planning Version control* Fix bugs first Bugs emailed/db Release on bugfix One-step build Atlassian suite Virtual machines Online Advertising* Daily stand-up Sprint planning — — Bug database — — — — Finance — — Version control* Fix bugs first — — One-step build Trello — Fashion Weekly stand-up — Version control Fix bugs first — Release on bugfix One-step build PRD, Trello Virtual env, CircleCI, Docker Test 1: Joel’s Test: 12 Steps to Better Code … in practice: Pre-Production: Pay Down Tech Debt
  • 10. → Test 2: ML Test Score [9], [10] • Data and feature quality • Model development • ML infrastructure • Monitoring ML 10 Pre-Production: Pay Down Tech Debt [11]
  • 11. 11 → Other tips — ML: • Choose simplest model, most appropriate for task and prod env • Test model against (simulated) “ground truth” or 2nd implementation [12] • Evaluate effects of floating point [12] • Model validation beyond accuracy [13] Pre-Production: Pay Down Tech Debt
  • 12. 12 → Other tips — Code: • What is your production environment? • Set-up logging • Add else to if or try/except + error • DRY → refactor • Add regression tests • Comment liberally (explain “why”) + up-to-date [20] Pre-Production: Pay Down Tech Debt [14]
  • 13. 13 Consulting Minimal time to add new feature Unsuitable features excluded Online Advertising* Fashion Test input features (typing, pytest) Finance Minimal time to add new feature Privacy built-in Test 2: ML Test Score … in practice: – Data and Feature Quality – Pre-Production: Pay Down Tech Debt – Model Development – Simulated ground truth Baseline model + 2nd implementation Rolling refresh Performance overall + those most likely to click Proxy + actual metrics Code review (PR) Hyperparameter optimization (sklearn.GridSearchCV) Baseline model Bias correction Proxy + actual metrics
  • 14. 14 Consulting Loosely coupled fcns Central repo for clients Regression testing One-step build, prod Online Advertising* Streaming Fashion Loosely coupled fcns Streaming API (sanic) Integration test (pytest) One-step build, prod Finance Loosely coupled fcns Streaming One-step build, prod* Reproducibility of training Pre-Production: Pay Down Tech Debt – ML Monitoring – Logging Software + package versions check Data availability check Logging (logging) Evaluates empty + factual responses Local = prod env (virtualenv, Docker) Comp time (timeit) Missing data check Test 2: ML Test Score … in practice (cont’d): – ML Infrastructure –
  • 15. 15 Test 2: ML Test Score … in practice (cont’d): Pre-Production: Pay Down Tech Debt
  • 17. 17 Production: Deploy Code and Monitor Performance → One-button push to prod branch/repo → Model Rollout → Monitoring [15]
  • 19. 19 → Documentation + QA gets cut first → Debugging, debugging, debugging → code is never perfect → Bugfix vs. Feature → Post-mortem → Use the product → Support and Training Post-Production: Keep Code Up and Running [16]
  • 20. 20 Post-Production: Align Business and Team Goals → Team targets: deadlines and revenue goals → Team competitions [17]
  • 21. 21 Key Takeaways → Communication, tooling, logging, documentation, debugging → Automatically evaluate all components of ML pipeline → High model accuracy is not always the answer → Scope down, then scale up [18]
  • 22. 22 You Did It! Code is in prod! Celebrate!
  • 23. 23 You Did It! Code is in prod! Celebrate! … But not too hard. Tomorrow you start on v2.
  • 25. [ 1] http://www.projectcartoon.com/cartoon/1 [ 2] https://research.google.com/pubs/pub43146.html [ 3] https://www.linkedin.com/pulse/when-your-tech-debt-comes-due-kevin-scott [ 4] https://www.sec.gov/news/press-release/2013-222 [ 5] http://dilbert.com/strip/2017-01-03 [ 6] https://www.joelonsoftware.com/2000/08/09/the-joel-test-12-steps-to-better-code/ [ 7] https://solidgeargroup.com/wp-content/uploads/2016/07/tower_cheatsheet_white_EN_0.pdf [ 8] http://geek-and-poke.com/geekandpoke/2014/2/23/dev-cycle-friday-evening-edition [ 9] https://www.eecs.tufts.edu/~dsculley/papers/ml_test_score.pdf [10] http://martin.zinkevich.org/rules_of_ml/rules_of_ml.pdf [11] https://www.slideshare.net/Tech_InMobi/building-machine-learning-pipelines [12] https://www.researchgate.net/publication/262569275_Testing_Scientific_Software_A_Systematic_Literature_Review [13] https://classeval.wordpress.com/introduction/basic-evaluation-measures/ [14] https://xkcd.com/1024/ [15] https://xkcd.com/1319/ [16] https://www.devrant.io/search?term=debugging [17] https://marketoonist.com/2015/03/hackathons.html [18] https://s-media-cache-ak0.pinimg.com/originals/9c/25/08/9c25082f5c4d3477124356e45673d426.png [19] https://www.pinterest.com/pin/177258935306351629/ [20] http://kellysutton.com/2017/09/01/comment-drift.html 25 References
  • 26. 26 Appendix: Establish Business Use Case → Kick-off meeting with stakeholders: • Discuss use case, motivation and scope • Find out about format of deliverable and how it will be used by team • Brainstorm and discuss potential solutions • Iron-out deadlines, checkpoints and on-going support structure • Ask about prod env (if appropriate) • Scope down, then scale up • Close meeting with recap of action items Key Takeaways: communication + clear expectations [19]