Ensemble Learning
*
1
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
*
2
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
*
3
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Why do ensembles work?
*
4
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Methods for Independently Constructing Ensembles –
*
5
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Methods for Independently Constructing Ensembles –
Methods for Coordinated Construction of Ensembles –
*
6
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
k-Fold Cross-Validation
*
7
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
k-Fold Cross-Validation
It is a popular method because it is simple to understand and because it generally results in a less biased or less optimistic estimate of the model skill than other methods, such as a simple train/test split.
*
8
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
k-Fold Cross-Validation
*
9
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
*
10
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Configuration of k
*
11
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
[0.1, 0.2, 0.3, 0.4, 0.5, 0.6]
*
12
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Fold1: [0.5, 0.2]
Fold2: [0.1, 0.3]
Fold3: [0.4, 0.6]
*
13
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
*
14
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Cross-Validation API
*
15
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
kfold = KFold(3, True, 1)
# enumerate splits
for train, test in kfold.split(data):
print('train: %s, test: %s' % (train, test))
*
16
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
# scikit-learn k-fold cross-validation
from numpy import array
from sklearn.model_selection import KFold
# data sample
data = array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6])
# prepare cross validation
kfold = KFold(3, True, 1)
# enumerate splits
for train, test in kfold.split(data):
print('train: %s, test: %s' % (data[train], data[test]))
*
17
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
train: [0.1 0.4 0.5 0.6], test: [0.2 0.3]
train: [0.2 0.3 0.4 0.6], test: [0.1 0.5]
train: [0.1 0.2 0.3 0.5], test: [0.4 0.6]
*
18
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Variations on Cross-Validation
*
19
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
*
20
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Algorithm:
*
21
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
*
22
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
*
23
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
*
24
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Steps in adaptive Boosting
Performing Adaptive Boosting, we have to iteratively go through each of the steps
Sum of all recursive classifiers
Ensemble Learning
*
25
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
*
26
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Step 1: 1/N
Ensemble Learning
*
27
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
*
28
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
*
29
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
*
30
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
*
31
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
XGBoost
�
*
32
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
*
33
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
System Features
*
34
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
XGBoost enhancements/optimizations
�
*
35
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Bagging
*
36
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Description of the Technique
*
37
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Implementation Steps of Bagging
Step 1: Multiple subsets are created from the original data set with equal tuples, selecting observations with replacement.
Step 2: A base model is created on each of these subsets.
Step 3: Each model is learned in parallel with each training set and independent of each other.
Step 4: The final predictions are determined by combining the predictions from all the models.
*
38
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
*
39
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Working of Bagging on training dataset
Since Bagging resamples the original training dataset with replacement, some instance(or data) may be present multiple times while others are left out.
*
40
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Algorithm for the Bagging classifier:
Classifier generation:
Let N be the size of the training set.
for each of t iterations:
sample N instances with replacement from the original training set.
apply the learning algorithm to the sample.
store the resulting classifier.
Classification:
for each of the t classifiers:
predict class of instance using classifier.
return class that was predicted most often.
*
41
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
*
42
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Random Forest
*
43
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Working of Random Forest
*
44
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Random Forest
Assumptions for Random Forest :
Why use Random Forest?
*
45
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Working of Random Forest
Random Forest works in two-phases
1. create the random forest by combining N decision tree
2. to make predictions for each tree created in the first phase.
The Working process
Step-1: Select random K data points from the training set.
Step-2: Build the decision trees associated with the selected data points (Subsets).
Step-3: Choose the number N for decision trees that you want to build.
Step-4: Repeat Step 1 & 2.
Step-5: For new data points, find the predictions of each decision tree, and assign the new data points to the category that wins the majority votes.
*
46
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Example: Suppose there is a dataset that contains multiple fruit images. So, this dataset is given to the Random forest classifier. The dataset is divided into subsets and given to each decision tree. During the training phase, each decision tree produces a prediction result, and when a new data point occurs, then based on the majority of results, the Random Forest classifier predicts the final decision.
*
47
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Applications of Random Forest
*
48
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Advantages of Random Forest
Disadvantages of Random Forest
*
49
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Some of the factors that cause errors in learning are noise, bias, and variance. The ensemble method is applied to reduce these factors resulting in the stability and accuracy of the result.
*
50
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Bagging
*
51
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Bagging
Example of Bagging:
*
52
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Boosting
Example of Boosting:
*
53
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Bagging and Boosting: Similarities
*
54
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Ensemble Learning
Bagging and Boosting: Differences
Boosting is a method of merging different types of predictions.
Boosting decreases bias, not variance.
In Boosting, models are weighed based on their performance.
New models are affected by a previously built model’s performance in Boosting.
In Boosting, every new subset comprises the elements that were misclassified by previous models
*
55
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Different ways to combine classifiers
Multiclassifiers
They can be divided into two big groups:
*
56
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Different ways to combine classifiers
*
57
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Different ways to combine classifiers
Architecture of Stacking
*
58
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Different ways to combine classifiers
Architecture of Stacking
*
59
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Different ways to combine classifiers
Architecture of Stacking
*
60
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Different ways to combine classifiers
Steps to implement Stacking models:
*
61
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Different ways to combine classifiers
Ensemble techniques related to stacking.
Voting ensembles:
*
62
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Different ways to combine classifiers
*
63
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Different ways to combine classifiers
Weighted Average Ensemble
*
64
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Different ways to combine classifiers
Blending Ensemble:
�
*
65
Dr. S. M. Patil, Computer Engineering Department , SIGCE
Different ways to combine classifiers
Super Learner Ensemble:
�
*
66
Dr. S. M. Patil, Computer Engineering Department , SIGCE