MLOps for R with Azure
Machine Learning
David Smith
Cloud Advocate, Microsoft
@revodavid
What is DevOps?
People. Process. Products.
Build Deploy
&
Test
“
DevOps is the union of people,
process, and products to
Continuous
enable continuous delivery of Develop
Delivery
Operate
value to your end users.
”
[Link]
Plan Monitor
& &
Track Learn
DevOps Process
1 Plan
4 Monitor + Learn
Development Production
2 Develop + Test 3 Release
Machine Learning Process
Prepare data
Evaluate
Production
Build and train
DEVOPS MLOPS
Manage code (source files) Manage code (source files)
Manage data files, notebooks, Rmd docs
Manage infrastructure (as code) Manage infrastructure (as code)
Manage environments (as code)
Source code control Source code control
Track experiment outcomes
Manage data sets
Build executables Train models
Builds take hours Model training may take weeks or months
(mostly) commodity compute GPU compute
Manage build versions Manage model versions
Manage reproducible environments
Tests (deterministic) Tests (probabilistic)
Fix bugs with code Fix bugs with code and/or data
Model drift / model retraining
Azure Machine Learning
Azure ML service SDK for R
Open-source R package for use with CRAN R: azuremlsdk
• Create Workspaces, Experiments, Compute, Models, and other artifacts with
R commands
• Use any R function/package (and track requirements for deployment)
• HyperDrive support: smart hyperparameter search with parallel compute
• Publish models as web services (in Azure or your own infra)
• Trigger training / deployment pipelines from CI/CD services
Accident fatality prediction app
• Import flat CSV file and clean data
Manage
Data
• Export to datastore
• Create training cluster
Train Model • Run experiments: GLM, KNN, GLMNET
• Select model by accuracy
Deploy
model
• Deploy R function as container
• Shiny application
Integrate
model
• Call R function via REST endpoint
Create compute instance for interactive work
Use Compute Instance to prep and share data
Create 2-node training cluster
Nodes pre-loaded with R and
R packages
Scales up as jobs added to
queue, scales down when
unused
Resize as needed
Shared between workspace
users (Python and R)
Low priority nodes for ~80%
discount
GPU clusters available
Train models and choose one to deploy
Register model
Register model with R
model object
Models can be versioned
Packages (CRAN, GitHub
or private) needed to
execute.
R script receives model
and data (JSON) to make
prediction
Deploy Model as service
Integrate model into Shiny app
Pass Shiny input data frame to
endpoint
Extract prediction from endpoint
response
Deploy Shiny app to any server
… or call from any another app
Deliver ML apps with Pipelines
az extension add -n azure-cli-ml
Azure ML Pipelines pip install --upgrade azureml-sdk
Azure Pipelines
in
Azure DevOps
CI/CD for apps with Azure Pipelines
Azure ML extension triggers builds/releases on model registration in Azure ML Services
Complete Pipeline
Retraining
Azure Pipelines Azure ML Service
➔ [Link] ➔ [Link]
Free unlimited build minutes for Free worskpaces, experiments,
public projects model registry
Up to 10 free parallel jobs across Standard Azure rates for compute
Windows, Linux and macOS and deployment or use your own
servers for free
Thank you!
David Smith Slides and links:
Cloud Advocate, Microsoft
@revodavid [Link]/mlops-r