Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
PAGE 1 | AI @ T-MOBILE
Push straight to prodAPI development with R and TensorFlow at T-Mobilerstudio::confJanuary 17th, 2019Heather Nolis, Machine Learning Engineer, T-Mobile – @heatherklusJacqueline Nolis, Principal Data Scientist, Nolis LLC – @skyetetra
PAGE 2 | AI @ T-MOBILE
What does it mean to put into production?
ANALYSISRunning code once to produce a result
Writing code that is continuously running
BUILD
Putting code into production is letting customers interact with it
PAGE 3 | AI @ T-MOBILE
Goal Use machine learning to improve the customer experience
Scope customer care messaging
The project:
PAGE 4 | AI @ T-MOBILE
Scenario Customer sends message:“This high bill shall not pass!”
Goal Prep customer care agent before first response: Current bill status
Method• Classify the message with machine learning: [bill breakdown]• Improve the prediction with customer data:
• Recent account activity• Signal strength• Bill status [overdue]
PAGE 5 | AI @ T-MOBILE
Model creation with R
PAGE 6 | AI @ T-MOBILE
Model building workflow
1. rmarkdown for exploratory analysis
2. Save the model to flat files (and log the build with rmarkdown)
3. Show model off with a shiny demo
PAGE 7 | AI @ T-MOBILE
Neural networks with R, Keras, and TensorFlow
A Convolutional Neural Network (CNN) processes initial customer message and customer data
“Unlock my phone.”
ACCOUNT UNLOCK ORDER
0.80 0.150.05
Recent order: YES
CNN
PAGE 8 | AI @ T-MOBILE
PAGE 9 | AI @ T-MOBILE
Model deployment to prod
PAGE 10 | AI @ T-MOBILE
Choosing the language
Option Analysis Modeling Deployment Verdict
1 ❎
2 ❎
3 ✅
“If you want machine learning in production you need Python” –literally everyone
PAGE 11 | AI @ T-MOBILE
Commit is
made to AI
repository
Jenkins builds the
image
Mesos replicates
and hosts the
containers
Marathon
orchestrates container
deployment
Idea! Treat R like a full programming language(because it is one)
PAGE 12 | AI @ T-MOBILE
Turning R into an API: plumber
#* @get /sumfunction(a, b){as.numeric(a) + as.numeric(b)
}
library(plumber)r <- plumb("rest_contoller.R")r$run(host='0.0.0.0',port=80)
rest_controller.R main.R
Create an R file for the API endpoints
Start the plumber service
Now make HTTP requests to R!
PAGE 13 | AI @ T-MOBILE
• Dockerfile—build instructions• Image—the result of the Dockerfile• Container—Hitting run on an image
# start from the rocker/r-ver:3.5.0 imageFROM rocker/r-ver:3.5.0
# install the linux libraries needed for plumberRUN apt-get update -qq && apt-get install -y \libssl-dev \libcurl4-gnutls-dev
# install plumberRUN R -e "install.packages('plumber')"
# copy everything from the current directory into the containerCOPY / /
# open port 80 to trafficEXPOSE 80
# when the container starts, start the main.RscriptENTRYPOINT ["Rscript", "main.R"]
Example Dockerfilae
Behold: containers!
PAGE 14 | AI @ T-MOBILE
R Keras requires Python• Added Python 3.6 (Anaconda) and
Python Keras installation to Dockerfile• Configured Reticulate to use correct
Python
Container Struggles: Python
PAGE 15 | AI @ T-MOBILE
Plumber does not support HTTPS• Added an Apache 2 server to reroute
Text needs encryption• Sodium R library
Container Struggles: Security
Docker Container
Apache 2
R(plumber)
HTTPS
HTTPS
HTTP
HTTP
PAGE 16 | AI @ T-MOBILE
Initial size (5+ GB)• Switched Pythons
(Anaconda →Miniconda)• Removed Rstudio
(rocker/tidyverse → rocker/r-ver:3.5.0)
• Removed unnecessary Linux, R, Python libraries
Container Struggles: Size
PAGE 17 | AI @ T-MOBILE
R-native API container
TensorFlow enabled
Lightweight
Secure
Status: UP
PAGE 18 | AI @ T-MOBILE
Lessons learned
PAGE 19 | AI @ T-MOBILE
R vs Python
• R & Plumber close to parity with Python & Flask• R advantageous for quick data exploration• Language was never the project failpoint
PAGE 20 | AI @ T-MOBILE
Product
Data Scientist
Data Scientist
ML Engineer
ML Engineer
Java Engineer
Data Scientist
Sr. Manager
Working Together is Critical
PAGE 21 | AI @ T-MOBILE
Where are we today
PAGE 22 | AI @ T-MOBILE
R in prod: Apple Business Chat
“Can I please pay my bill” Customer
PAGE 23 | AI @ T-MOBILE
And you can be here too!
PAGE 24 | AI @ T-MOBILE
Materials: nolisllc.com/rstudio19twitter: @skyetetra @heatherklus