Machine Learning in Retail
Machine Learning in Retail
10.00
ML in Retail Overview of different ML use cases in the Retail sector
11.00
Datatonic Case study Detailed Retail case study
11.20
Workshop: Metadata enrichment Generate structured information from unstructured data
12.30–
13.30
Tools of the trade Explore libraries, frameworks, infrastructure and resources for practical ML
14.45
ML on GCP Introduce the GCP products for ML as well as other infrastructure required
15.15
Workshop: live recommendation Train and deploy a complete TensorFlow pipeline
16.45
Close Recap
Introduction to Machine Learning
Introduction to Machine Learning
- What is ML?
- Why does ML exist?
- How does ML work?
- What can ML do?
- When is ML useful?
Discussion: What is ML?
Mapping AI
ARTIFICIAL
INTELLIGENCE
MACHINE
LEARNING
DECISION
TREES
DEEP
LEARNING
PROBABILISTIC
LEARNING
Why does ML exist?
Learning vs Programming
Human Learning
Classical conditioning
Operant conditioning
Observational learning
The human must direct their The human must be able to Humans have intrinsic motivation.
cognition and senses towards remember the pattern and This can be strengthened with an
understanding the information given subsequently to act upon it. implied reward (promised, observed
in the example. or associated).
History of ML
1950
Convergence of neurology and computer science.
Church–Turing thesis
History of ML “In the summer of 1951 Dean Edmonds and I
went up to Harvard and built our machine. It had
IF (round) THEN
IF (orange AND coarse) THEN
“orange”
ELSE IF (green AND smooth) THEN
“apple”
ELSE IF …
…
ELSE IF …
“banana”
History of ML
1986 – return of neural networks
(Logistic regression 1958)
(Fuzzy logic in expert systems)
21st century
Human or superhuman
Image classification
Games (Go, DotA, Atari)
Medical diagnosis
Speech transcription (batch)
Almost human
Text translation
Object recognition
Text comprehension
The value of data
“The world is its own best model. It is
always exactly up to date. It always
has every detail there is to be known.
The trick is to sense it appropriately
and often enough.”
Making decisions based on data is not new. It is just
much easier now
Big Data
Rows and columns Tags and relationships Data without rigid form
Predictable and neat, though Organised into hierarchies and Unstructured data accounts for
often imperfect networks. More freeform than 90% of enterprise data.
structured data but still queryable
+ CSV + Images
+ SQL databases + JSON + Audio
+ XML + Free text
+ NoSQL databases
“ Mimicking functions of the human brain (DL) coupled with the
availability of low-cost massive computational hardware resources
(GPU) and huge data pools (Big Data) provides opportunities to
solve problems which so far have relied on human brain-power.*”
*https://hackernoon.com/what-is-the-difference-between-machine-learning-and-human-learning-53119c217194
How does ML work?
Human Learning
Attention Capacity Motivation
Interpreting the example. ‘Retention’ and ‘Reproduction’. Desire to learn.
The human must direct their The human must be able to Humans have intrinsic motivation.
cognition and senses towards remember the pattern and This can be strengthened with an
understanding the information given subsequently to act upon it. implied reward (promised, observed
in the example. or associated).
Machine Learning
Attention Capacity Motivation
Interpreting the example. ‘Retention’ and ‘Reproduction’. Desire to learn.
Information must be provided to the The machine must be able to Machines have no intrinsic
machine in a way it can learn from. remember the pattern and motivation. They must instead
subsequently to act upon it. optimize an objective function to
2.2 direct successful learning.
-0.1
14.7
9.5
-3.5
N.B. ‘attention’ is also an active field of study
in machine learning.
Machine Learning
Attention Capacity Motivation
Interpreting the example. ‘Retention’ and ‘Reproduction’. Desire to learn.
y = mx + c y = mx + c + ε
x y
1 3.1
2 5.0
3 6.9
4 9.2
y = 2x + 1
Data
ML in one slide INPUT
Knowledge
OUTPUT
Data
ML in one slide INPUT
TARGET
There are only 3 tasks in ML
Learn to predict y from x Learn the structure behind x Minimize / maximize a score
REINFORCEMENT
CLASSIFICATION REGRESSION CLUSTERING EMBEDDING METAHEURISTICS
LEARNING
Discrete y Continuous y Discrete patterns Continuous patterns Act and receive Mimic natural process
reward / punishment e.g. ant colony
Optimization
Find the global min / max of a function
Explore different values of x to find best y
Classification + Regression
Train a model to predict an output
Learn how y depends on x
Reinforcement Learning
Train an agent to take the best actions
Given a state, find the action that leads to most reward
Forecasting
Predict the future of a time series
Uncover trends and correlations across time
Summarizing data
Learn a concise representation
Clustering Embedding
Probabilistic Modelling
Distinguish signal from noise
Anomaly detection Filtering
When is ML useful?
When is Machine Learning useful?
If someone knows it, they should just program it If you really need an AI to do it for you, then ML
conventionally! may be a good solution.
Ask yourself...
optimize
self-describe
ML effort allocation - expectation vs. reality
≠
Where should you focus your effort?
+ Big data and analytics are prerequisites for + Tailor KPIs to each use case
building any ML pipeline + Define the baseline(s) you want to beat
+ Understand your data
+ Design multiple models for a business problem + Exploit pre-trained ML models on your data
+ Account for different user behaviours before exploring new ones
Introduction to Machine Learning (Recap)
Why does ML exist?
Introduction to Machine Learning (Recap)
How does ML work?
2.2
-0.1
14.7
9.5
-3.5
Introduction to Machine Learning (Recap)
What can ML do?
Introduction to Machine Learning (Recap)
When is ML useful?
There is some
thing to learn
There is suffici
ent data to lea
rn it
It is currently u
nknown...
… or it can’t be
programmed e
asily
Machine Learning in Retail
How can ML add value to Retail?
Machine Learning converts examples into knowledge
Mapping the value of ML across the retail chain
How can we optimise How can we maximise How can we enhance How can we target the
resource harnessing? revenue? customer experience? relevant customers?
+ Predict the future value for existing customers who have a known
transaction history
+ Pareto principle: “20% of your customers account for 80% of your
sales”
+ What role does ML have in store front and enhancing the user experience of shopping?
Brand Brand
X? Y? Brand
Transactional Z?
Browsing
Demographics
+ How likely is each + Personalised content
customer to buy each + Better targeting
brand?
Through automation, machine
learning, and cloud scale we built
a full end-to-end pipeline
capable of generating billions of
propensity scores.
The single automated Brand Propensity Scoring
solution can scale to more than thousands of
brands.
Title Text
Retailer
Retailer membership number: 12345678
Try it yourself!
https://cloud.google.com/vision/
cloud.google.com/products/ai
Workshop: Metadata generation for music reviews using
Google’s Natural Language API
+ Load in some Pitchfork review data from a Cloud Storage bucket and explore
what it looks like
+ Connect to the Cloud Language AI through the python client library and see
how each API responds
+ Apply the API to the reviews, and examine the added value of the results
you get
pitchfork.com
goo.gl/zYWrm9
Colab: Metadata enrichment
Workshop: Metadata enrichment.ipynb
goo.gl/zYWrm9
Colab: Metadata enrichment
goo.gl/zYWrm9
Colab: Metadata enrichment
Workshop: Metadata enrichment.ipynb
goo.gl/zYWrm9
Colab: Metadata enrichment
Copy of Workshop: Metadata enrichment.ipynb
Colab: Metadata
Enrichment
Metadata Enrichment Workshop (Recap)
In this workshop we have used the Cloud Natural Language API to extract structured data from
text reviews, including:
+ Content classification
+ Syntactic analysis
+ Sentiment analysis
+ Entity analysis
Lunch Break
Plan for the day
9.15
Introduction to Machine Learning Overview of ML theory and context
10.00
ML in Retail Overview of different ML use cases in the Retail sector
11.00
Datatonic Case study Detailed Retail case study
11.20
Workshop: Metadata enrichment Generate structured information from unstructured data
12.30–
13.30
Tools of the trade Explore libraries, frameworks, infrastructure and resources for practical ML
14.45
ML on GCP Introduce the GCP products for ML as well as other infrastructure required
15.15
Workshop: live recommendation Train and deploy a complete TensorFlow pipeline
16.45
Close Recap
Tools of the Trade
ML in practise
What does a typical Machine Learning pipeline look like?
Model Final
Raw Data Design Training Model
What does a typical Machine Learning pipeline look like?
Feature
selection
Feature
engineering
What does a typical Machine Learning pipeline look like?
Which and how much data do you Which type of ML problem What are you trying to predict?
have access to?
Feature is it?
selection
Process your data to make it Feature Design and refine your ML Make your model
usable and informative engineering model production-ready
What does a typical Machine Learning pipeline look like?
Discover Deploy
Explore Test
Invent Integrate
Define Monitor
Discover Model Build Deploy
1 2 3 4 5
Define ML use cases Data exploration Select algorithm Data pipeline & Build ML model
Choose the right ML
feature engineering Develop the first iteration
Define specific ML use cases for Perform exploratory
Create the right of the ML model
the project analysis to understand the algorithm for the task
data features from raw data
for the ML task
Start
a new ML project
10 9 8 7 6
Monitor model Operationalize model Plan for deployment Present results Iterate ML model
Monitor deployed ML model Deploy and operationalize Prepare for deployment in Present results of the model in Refine the ML model to
and retrain or rebuild when ML model in production production a way that demonstrates its improve performance and
performance degrades value to stakeholders efficacy
Libraries & Frameworks
Try it out
1. Find Estimators
TensorFlow Estimators
tf.estimator tf.contrib
BaselineRegressor tf.contrib.estimator.RNNClassifier
LinearRegressor
BoostedTreesRegressor tf.contrib.factorization.GMM
DNNRegressor tf.contrib.factorization.KMeansClustering
DNNLinearCombinedRegressor tf.contrib.factorization.WALSMatrixFactorization
tf.contrib.gan.estimator.GANEstimator
tf.contrib.gan.estimator.StarGANEstimator
This workshop will introduce you to the scipy ecosystem to preprocess data, then scikit-learn and
TensorFlow's canned estimators to do machine learning.
ord
rec
dio
Au
Spectrograms of phonemes
“Fujitsu” Frequencies
contained by
the signal
Workshop: Introduction to Scikit-learn & Tensorflow
frequency
+ We'll attempt to cluster the phonemes based on the
11
similarity of their time series, and also classify them
correctly. time
217
goo.gl/zYWrm9
Colab: Tools of the Trade
Tools of the Trade.ipynb
phoneme_train.csv
phoneme_test.csv
Colab: Tools of the Trade
goo.gl/zYWrm9
Colab: Tools of the Trade
Tools of the Trade.ipynb
goo.gl/zYWrm9
Colab: Tools of the Trade
Copy of Tools of the Trade.ipynb
Colab
Colab: Tools of the Trade (Recap)
Compute Engine
Kubernetes Engine
App Engine
ML Engine
Google Cloud Platform + Machine Learning
TPU / GPU
Compute Engine
Kubernetes Engine
App Engine
ML Engine
Google Cloud Platform + Machine Learning
Data Studio
Dataprep
Dataflow
Dataproc
Google Cloud Platform + Machine Learning
Data Studio
Dataprep
Dataflow
Dataproc
Composer
Google Cloud Platform + Machine Learning
Datalab
Google Cloud Platform + Machine Learning
Storage BigTable
Datastore Spanner
SQL BigQuery
Google Cloud Platform + Machine Learning
+ Linear regression
+ Logistic regression (binary and
multi-class)
+ K-means
In Alpha
+ Matrix Factorization
+ XGboost
+ Custom TF models
BigQuery ML
Google Cloud Platform + Machine Learning
AutoML
Speech and Vision APIs
Dialogflow
Google Cloud Platform + Machine Learning
AutoML Tables
Google Cloud Platform + Machine Learning
Workshop: live recommendation
Section Overview
- Prepare training data
ML Engine
What you’ll build
Database Cloud Storage
VM
DIY
VM
VM
CREATE A VM
YOUR VM
Database Cloud Storage
VM
1 2 3 4 5
Define ML use cases Data exploration Select algorithm Data pipeline & Build ML model
Choose the right ML
feature engineering Develop the first iteration
Define specific ML use cases for Perform exploratory
Create the right of the ML model
the project analysis to understand the algorithm for the task
data features from raw data
for the ML task
Start
a new ML project
10 9 8 7 6
Monitor model Operationalize model Plan for deployment Present results Iterate ML model
Monitor deployed ML model Deploy and operationalize Prepare for deployment in Present results of the model in Refine the ML model to
and retrain or rebuild when ML model in production production a way that demonstrates its improve performance and
performance degrades value to stakeholders efficacy
Recap
Recap - What can ML do?
Recap - There are only 3 tasks in ML
TARGET
Recap - When is Machine Learning useful?
If someone knows it, they should just program it If you really need an AI to do it for you, then ML
conventionally! may be a good solution.
Recap - ML in Retail
How can we optimise How can we maximise How can we enhance How can we target the
resource harnessing? revenue? customer experience? relevant customers?
Recap - Metadata enrichment workshop
Recap - ML in practice
Discover Deploy
Explore Test
Invent Integrate
Define Monitor
Recap - Tools of the trade
Recap - Tools of the trade workshop
Recap - Google Cloud Platform + ML
Recap - Live recommendation workshop
VM
https://drive.google.com/drive/folders/163FogjEa9ZKGmI9BIBO
p-6p5lD7e1D3K
Discussion
What’s next?
Understand how to leverage Identify & prioritise the most Flesh out a specific use case &
Objective tools available on GCP to build impactful use case(s) for your define a plan for realising it
successful models business