machine learning introduction - indico · esa unclassified - for official use jose martinez heras |...
TRANSCRIPT
ESA UNCLASSIFIED - For Official Use
Machine Learning Introduction
Jose Martinez Heras
16/04/2019
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 2
About
• José Martínez Heras
• Computer Scientist
• Spanish
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 3
Machine Learning Lectures at ESOC
https://github.com/jmartinezheras/2018-MachineLearning-Lectures-ESA
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 4
Objectives for this session
• What Machine Learning can / cannot do
• Examples in Space and other domains
• How it works
• Key Concepts & Best Practices
• Understand how some techniques work
• Hands-On session: predict Mars Express thermal power consumption
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 5
Artificial Intelligence
Reasoning
Knowledge
Planning
Machine Learning
Natural Language Processing
Perception
Move & manipulate
objects
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 6
Artificial Intelligence
Reasoning
Knowledge
Planning
Machine Learning
Natural Language Processing
Perception
Move & manipulate
objects
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 7
Artificial Intelligence
Reasoning
Knowledge
Planning
Machine Learning
Natural Language Processing
Perception
Move & manipulate
objects
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 8
What’s Machine Learning?
• “The field of study that gives computers the ability to learn without being
explicitly programmed” [Artur Samuel, 1959]
• “A computer program is said to learn from experience E with respect to some
task T and some performance measure P, if its performance on T, as measured
by P, improves with experience E” [Tom Mitchell, 1997]
• The science (and art) of programming computers so that they can learn
from data [Aurélien Géron, 2017]
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 9
How is Machine Learning different from programming
DataProgram
Perform task
Results DataModel
Perform task
Results
Data
ML
Learning
ModelResults
Requirements Program
Only for some tasks
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 10
Which tasks can Machine Learning perform?
- Let’s see some examples
Spam Filter Recommendation Engine
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 11
Which tasks can Machine Learning perform?
Real Estate
Predict at which price a property will be sold
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 12
Which tasks can Machine Learning perform?
Advertising
Predict which ads you are more likely to click on
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 13
Which tasks can Machine Learning perform?
Image Classification
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 14
Which tasks can Machine Learning perform?
Self-driving cars
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 15
Which tasks can Machine Learning perform?
Speech Recognition & Synthesis
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 16
Which tasks can Machine Learning perform?
Language Translation
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 17
Which tasks can Machine Learning perform?
Playing Games
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 18
Some examples in Space Operations
Dr.MUST diagnostics: find the cause of an anomaly
VEX attitude errors because of Aspera payload activation
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 19
Some examples in Space Operations
Novelty Detection: a novel behaviour is often the signature of an
anomaly in the way to happen
OOL
Unusual behaviour
Potential anomaly
XMM Tank1 Ext temperature
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 20
Some examples in Space Operations
[MEX] Predict Thermal Power Consumption: Machine Learning competition
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 21
Some examples in Space Operations
[Integral] Radiation Belts entry / exit times prediction to increase science return
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 22
Some examples in Space Operations
[esa.int] Predict which articles will receive
a high number of views
High: Rosetta, comet, surface, lander, image, crater, mars, stars, galaxy, black holes
Low: ESA, company, technology
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 23
Considerations on using Machine Learning
• There must be a pattern in the input –
output relationship (lottery winning
numbers cannot be predicted with ML)
• There must be enough data to
discover this pattern
• It’s difficult to formulate a
mathematical expression (otherwise
we will just use this formula instead)
DataModel
Perform task
Results
Data
ML
Learning
ModelResults
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 24
How Machine Learning Learns?
• Different Machine Learning techniques
for different kinds of tasks
• Learning is finding which model’s
parameters represent best the input –
output mapping
DataModel
Perform task
Results
Data
ML
Learning
ModelResults
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 25
How Machine Learning Learns?
• Linear Regression example:
• Model: f(x) = mx + b
• Model’s parameters: m, b
• Parameter values: m=1, b=0
• Learning is finding which values of ‘m’
and ‘b’ fit the data best (e.g.
minimizes the prediction error)
DataModel
Perform task
Results
Data
ML
Learning
ModelResults
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 26
How Machine Learning Learns?
Find the model parameters values that minimize the error
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 27
How Machine Learning Learns?
m = 0.1014b = 1.2258
Find the model parameters values that minimize the error
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 28
How Machine Learning Learns? – some models
Polynomials: ax + bx2 + … + c
Support Vector Machines (SVM): Vectors
Decision trees: which nodes, which decisions
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 29
How Machine Learning Learns? – some models
Neural Networks / Deep Learning: weights
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 30
Types of Learning
Depending on the level of supervision …
• Supervised
• Unsupervised
• Semi-supervised
• Reinforcement Learning
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 31
Types of Learning
• Supervised
• Supervision: we can tell for every case what the correct answer was
• Example: predict the thermal power consumption
FocusPredict the future
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 32
Types of Learning
• Unsupervised
• Supervision: there is no right answer, we are looking for insights
• Example: market basket analysis for supermarkets
FocusUnderstand the past
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 33
Types of Learning
• Semi-supervised
• Supervision: we can tell the correct output for a limited number of cases
• Example: characterize what a particle impact looks like in TM
Sentinel-1A: particle impact on August 23th 2016
FocusUnderstand the past
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 34
Types of Learning
• Reinforcement Learning
• Supervision: we only know the final outcome, but not intermediate steps
• Example: playing Go
FocusFind which is the next action most likely to lead to the desired outcome
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 35
Types of Learning
• The type of learning with most industrial applications is
Supervised Learning
(Predictive Analytics)
• Depending of what kind of data is predicted we can talk about:
• Regression
• Classification
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 36
Regression
• Predict real numbers
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 37
Classification
• Predict which option out of a limited set of possibilities
Spam Filter What’s in the picture
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 38
Machine Learning Workflow
Problem Understanding
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 39
Machine Learning Workflow
Problem Understanding
Evaluation Criteria
• How will we measure how good the model is performing?
• Do we know already at what point it would be enough?
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 40
Machine Learning Workflow
Problem Understanding
Evaluation Criteria
Baseline
• How the current approach is performing against the evaluation criteria? Define a simple baseline if there is none (e.g. mean value)
• This will allow us to quantify how much Machine Learning helps and if it is worthwhile compared to simpler solutions
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 41
Machine Learning Workflow
Problem Understanding
Evaluation Criteria
Baseline
Prepare Data
• “Enough” data in the sense that it’s representative of the behaviour the model needs to learn
• Features: data transformations that encode your knowledge
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 42
Machine Learning Workflow
Problem Understanding
Evaluation Criteria
Baseline
Prepare Data Train model
• Use data / features to tune the parameters that optimize the evaluation criteria (e.g. minimise error)
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 43
Machine Learning Workflow
Problem Understanding
Evaluation Criteria
Baseline
Prepare Data Train model Error Analysis
More complex model
Simpler model
More data / features
Provides better problem understanding
• Understand what the model is doing: where is it right / wrong
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 44
Machine Learning Workflow
Problem Understanding
Evaluation Criteria
Baseline
Prepare Data Train model Error Analysis
More complex model
Simpler model
More data / features
Provides better problem understanding
ProductionTrained Model
Ready to use
Better baseline
• When we are happy with the error, we can use the trained model: new data features computation model results
• We now have a better baseline
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 45
Machine Learning Workflow
Problem Understanding
Evaluation Criteria
Baseline
Prepare Data Train model Error Analysis
More complex model
Simpler model
More data / features
Better problem understanding
ProductionTrained Model
Ready to use
Better baseline
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 46
Evaluation Criteria
Typically a way to measure error.
Example:
𝑀𝑆𝐸 =1
𝑛
𝑖=1
𝑛
𝑌𝑖 − 𝑌𝑖2
Mean Squared Error
* We will see more evaluation criteria in other sessions
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 47
Train Machine Learning Models
Let’s train 2 models to learn from this data
𝑦 = 0.1 ∗ 𝑥 + 1.25 + 0.2 ∗ 𝐺𝑎𝑢𝑠𝑠𝑖𝑎𝑛𝑁𝑜𝑖𝑠𝑒
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 48
Train Machine Learning Models
Mean Squared Error: 0.0372 Mean Squared Error: 0.0286
Linear Regression Polynomial Regression (degree 7)
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 49
Generalization
Generalization: the ability of a model to perform well on new data
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 50
Generalization
How to tell if a Machine Learning model is generalizing well when we cannot
visualize what it is doing?
?
2-dimensional data 3-dimensional data n-dimensional data
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 51
Generalization
Split data in 2 sets
• Training Set: for training the model
• Testing Set: for evaluating the generalization of the model
* Validation set and cross-validation will be explained later
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 52
Generalization
Data Training Data + Testing Data
The Machine Learning model now
learns from training data only
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 53
Generalization – Error Analysis
Evaluate Performance on Training Data & Test Data
MSE Train: 0.043, MSE Test: 0.0238 MSE Train: 0.043, MSE Test: 85.113
Over-fitting
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 54
Generalization – Error Analysis - Guidelines
Train Error Test Error What to do?
Low High • Need a simpler model• Need more data (more data samples)
* High / Low compared with the error you are willing to accept
Over-fitting
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 55
Generalization – Error Analysis - Guidelines
Train Error Test Error What to do?
Low High • Need a simpler model• Need more data (more data samples)
High High • Need more data• Difficult to learn f(x, z) with only x. Get also z• Get more data samples
• Additional features (e.g. 1
𝑥2)
• Need a more complex model
* High / Low compared with the error you are willing to accept
Over-fitting
Under-fitting
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 56
Generalization – Error Analysis - Guidelines
Train Error Test Error What to do?
Low High • Need a simpler model• Need more data (more data samples)
High High • Need more data• Difficult to learn f(x, z) with only x. Get also z• Get more data samples
• Additional features (e.g. 1
𝑥2)
• Need a more complex model
High Low Unusual: it could mean that the test data is too similar to the train data. Get more test data.
* High / Low compared with the error you are willing to accept
Over-fitting
Under-fitting
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 57
Generalization – Error Analysis - Guidelines
Train Error Test Error What to do?
Low High • Need a simpler model• Need more data (more data samples)
High High • Need more data• Difficult to learn f(x, z) with only x. Get also z• Get more data samples
• Additional features (e.g. 1
𝑥2)
• Need a more complex model
High Low Unusual: it could mean that the test data is too similar to the train data. Get more test data.
Low Low You’re done! – congratulations
* High / Low compared with the error you are willing to accept
Over-fitting
Under-fitting
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 58
Machine Learning Workflow
Problem Understanding
Evaluation Criteria
Baseline
Prepare Data Train model Error Analysis
More complex model
Simpler model
More data / features
Better problem understanding
ProductionTrained Model
Ready to use
Better baseline
Effort
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 59
Let’s talk about Random Forests
• Decision Trees
• Ensembles
• Random Forests
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 60
Random Forests
[MEX] Predict Thermal Power Consumption
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 61
Random Forests
[MEX] Predict Thermal Power Consumption
[Integral] Radiation Belts
entry / exit times prediction
to increase science return
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 62
Random Forests
[MEX] Predict Thermal Power Consumption
[Integral] Radiation Belts
entry / exit times prediction
to increase science return
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 63
Random Forests
Random Forest = Ensemble of Decision Trees
1. Decision Trees
2. Ensembles
3. Random Forests
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 64
Decision Trees – remember Iris example?
Iris setosa Iris versicolor Iris virginica
Knowing the sepal and petal length and width, which flower is it?
Pictures from Wikipedia contributors, "Iris flower data set," Wikipedia, The Free Encyclopedia, https://en.wikipedia.org/w/index.php?title=Iris_flower_data_set&oldid=824486644
(accessed March 5, 2018).
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 65
Decision Trees
It also can provide probabilities
𝑝𝑠𝑒𝑡𝑜𝑠𝑎 = 1.00
Gini is a measurement of purity
𝑝𝑣𝑒𝑟𝑠𝑖𝑐𝑜𝑙𝑜𝑟 = 0.91 𝑝𝑣𝑖𝑟𝑔𝑖𝑛𝑖𝑐𝑎 = 0.98
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 66
Decision Trees
𝐺𝑖𝑛𝑖 = 1 −
𝑘=1
𝑛
𝑝𝑐2
𝐺𝑖𝑛𝑖 = 1 −0
54
2
+49
54
2
+5
54
2
= 0.168
Gini is a measurement of purity
𝑝𝑐= probability of each class
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 67
How do we learn to build Decision Trees?
Greedy optimization that minimizes
𝐽 𝑓, 𝑡𝑓 =𝑚𝑙𝑒𝑓𝑡
𝑚𝐺𝑖𝑛𝑖𝑙𝑒𝑓𝑡 +
𝑚𝑟𝑖𝑔ℎ𝑡
𝑚𝐺𝑖𝑛𝑖𝑟𝑖𝑔ℎ𝑡
𝑓 = which feature
𝑡𝑓 = which threshold for feature f
𝑚 = number of samples
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 68
Features Importance
Features Importance
sepal length (cm): 0.0sepal width (cm): 0.0petal length (cm): 0.562petal width (cm): 0.438
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 69
Decision Trees - Regression
𝑦 = 𝑥2 + 0.2 ∙ 𝐺𝑎𝑢𝑠𝑠𝑖𝑎𝑛𝑁𝑜𝑖𝑠𝑒
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 70
Decision Trees - Regression
𝑦 = 𝑥2 + 0.2 ∙ 𝐺𝑎𝑢𝑠𝑠𝑖𝑎𝑛𝑁𝑜𝑖𝑠𝑒 𝐽 𝑓, 𝑡𝑓 =𝑚𝑙𝑒𝑓𝑡
𝑚𝑀𝑆𝐸𝑙𝑒𝑓𝑡 +
𝑚𝑟𝑖𝑔ℎ𝑡
𝑚𝑀𝑆𝐸𝑟𝑖𝑔ℎ𝑡
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 71
Mean Squared Error
𝑀𝑆𝐸 =1
𝑚
𝑖=1
𝑚
𝑌𝑖 − 𝑌𝑖2
Mean Squared Error
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 72
Decision Trees - Regression
𝑦 = 𝑥2 + 0.2 ∙ 𝐺𝑎𝑢𝑠𝑠𝑖𝑎𝑛𝑁𝑜𝑖𝑠𝑒 𝐽 𝑓, 𝑡𝑓 =𝑚𝑙𝑒𝑓𝑡
𝑚𝑀𝑆𝐸𝑙𝑒𝑓𝑡 +
𝑚𝑟𝑖𝑔ℎ𝑡
𝑚𝑀𝑆𝐸𝑟𝑖𝑔ℎ𝑡
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 73
Regularization in Decision Trees
overfitting tree
For this particular example. Require thateach node has ≥ 5% of the samples
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 74
Regularization in Decision Trees
• Maximum depth
• Maximum number of leaf nodes
• Minimum number of samples at leaf nodes
• Minimum samples at node must have before it can be split
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 75
Decision Trees don’t make assumptions
This is good because it’s not limited by a line, polynomial or any other
predefined model
𝑦 = 𝑥2 + 0.2 ∙ 𝐺𝑎𝑢𝑠𝑠𝑖𝑎𝑛𝑁𝑜𝑖𝑠𝑒 𝑦 = sin(1.5 ∙ 𝑥) + 0.2 ∙ 𝐺𝑎𝑢𝑠𝑠𝑖𝑎𝑛𝑁𝑜𝑖𝑠𝑒
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 76
Decision Trees don’t make assumptions
But it only works well when trained with representative data
𝑦 = 𝑥2 + 0.2 ∙ 𝐺𝑎𝑢𝑠𝑠𝑖𝑎𝑛𝑁𝑜𝑖𝑠𝑒 𝑦 = sin(1.5 ∙ 𝑥) + 0.2 ∙ 𝐺𝑎𝑢𝑠𝑠𝑖𝑎𝑛𝑁𝑜𝑖𝑠𝑒
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 77
Ensembles
• Ensemble = group of Machine Learning models
• Each model in the group produces a different prediction
• Predictions are combined to give a final prediction
• How predictions are combined?
• voting
• bagging
• boosting
• stacking
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 78
Ensembles - Voting
Logistic Regression
Support Vector Machine
Decision Tree
New sample
1
0
1
1
It works better than individual modelsAs long as models are independent, their errors compensate each other
Already trained models
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 79
Ensembles - Bagging
• Voting of several instances of the same model
• majority voting from several trees
• However
• all tress would be so similar that their errors will not compensate
• Let’s make Decision Trees different so that we can combine them
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 80
Ensembles - Bagging
Training Data
Random sampling
Random Sampling
Random Sampling
model
model
model
1
0
1
1
Training the models Using the models
Train decision models with different data / features
New sample
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 81
Random Forest: Bagging Ensemble of Trees
Training Data
Random sampling
Random Sampling
Random Sampling
Decision Tree
Decision Tree
Decision Tree
Train decision models with different data / features
1
0
1
1
Training the models Using the modelsNew sample
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 82
Random Forests
Random Forest are good for generalization
Random Forest provide a similar training error (same bias) as an individual treeRandom Forest provide lower testing error (lower variance) as an individual tree
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 83
How results are combined for Random Forest?
Classification
• Soft-voting
• Combine the probabilities:
highly confident predictions
get higher weight
Regression
• Mean value
You can also implement your own combination of predictions
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 84
How results are combined for Random Forest?
Custom combinations of the Decision Trees Ensembles
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 85
Decision Trees or Random Forest?
Decision Tree
• You are interested in a
white-box model
• Understanding is more
important than predicting
Random Forest
• You don’t mind using a
black-box model
• Predicting (generalizing
well on new data) is
more important than
understanding
Tree + Random Forest
• Decision Tree for
understanding
• Random Forest for
predicting
• Use Tree as surrogate of
the Random Forest
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 86
Surrogate Models
Black Box(e.g. Random Forest)
Results
FeaturesPredicted Results
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 87
Surrogate Models
Black Box(e.g. Random Forest)
Results
FeaturesPredicted Results
White Box(e.g. Decision Tree)
Predicted Results (II)
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 88
Random Forests
Random Forests gives you forecasting super-powers
But only if new data is similar to training data
It’s not as bad as I pictured it
Because, in practice, there are many more features
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 89
Let’s recap
Today we have discussed about:
• What is machine learning
• Some applications in industry & space
• What is the ‘Learning’ in Machine Learning
• Types of machine learning
• Regression / Classification
• Machine Learning workflow
• Generalization
• Decision Trees
• Ensembles
• Random Forests
• Surrogates models for Explainable AI
ESA UNCLASSIFIED - For Official Use Jose Martinez Heras | ESOC | 16/04/2019 | Slide 90
Thank you
LinkedIn: https://www.linkedin.com/in/josemartinezheras/
https://github.com/jmartinezheras/2018-MachineLearning-Lectures-ESA
ESA UNCLASSIFIED - For Official Use
Thank you
LinkedIn: https://www.linkedin.com/in/josemartinezheras/
Jose Martinez Heras