1 of 138

CS307

Machine Learning

Lecture 15

Ensemble Learning

Krishnendu Ghosh

Department of Computer Science & Engineering

Indian Institute of Information Technology Dharwad

2 of 138

Ensemble Learning

Ensemble learning combines the predictions of multiple models (called "weak learners" or "base models") to make a stronger, more reliable prediction. The goal is to reduce errors and improve performance.

​

It is like asking a group of experts for their opinions instead of relying on just one person. Each expert might make mistakes, but when you combine their knowledge, the final decision is often better and more accurate.

2

3 of 138

Ensemble Learning

There are many types of ensemble methods:

​

  1. Voting
  2. Bagging (Bootstrap Aggregating)
  3. Random Forests
  4. Boosting
  5. Stacked Generalization (Blending)

3

4 of 138

Ensemble Learning: Voting

Voting

4

5 of 138

Ensemble Learning: Voting

​

Majority Voting / Hard Voting

Hard voting is the simplest case of majority voting. Here, we predict the class label y^

via majority (plurality) voting of each classifier Cj:

y^=mode{C1(x),C2(x),...,Cm(x)}

Assuming that we combine three classifiers that classify a training sample as follows:

classifier 1 -> class 0

classifier 2 -> class 0

classifier 3 -> class 1

y^=mode{0,0,1}=0

Via majority vote, we would classify the sample as "class 0."

5

6 of 138

Ensemble Learning: Voting

​

Weighted Majority Vote

In addition to the simple majority vote (hard voting) as described in the previous section, we can compute a weighted majority vote by associating a weight wj with classifier Cj:

y^=argmaxi∑j=1mwjχA(Cj(x)=i),

where χA is the characteristic function [Cj(x)=i∈A], and A is the set of unique class labels.

Continuing with the example from the previous section

classifier 1 -> class 0

classifier 2 -> class 0

classifier 3 -> class 1

assigning the weights {0.2, 0.2, 0.6} would yield a prediction y^=1:

argmaxi[0.2×i0+0.2×i0+0.6×i1]=1

6

7 of 138

Ensemble Learning: Voting

​

Soft Voting

In soft voting, we predict the class labels based on the predicted probabilities p for classifier -- this approach is only recommended if the classifiers are well-calibrated.

y^=argmaxi∑j=1mwjpij,

where wj is the weight that can be assigned to the jth classifier.

Assuming the example in the previous section was a binary classification task with class labels i∈{0,1}, our ensemble could make the following prediction:

C1(x)→[0.9,0.1]

C2(x)→[0.8,0.2]

C3(x)→[0.4,0.6]

7

8 of 138

Ensemble Learning: Bagging

​

Bagging (Bootstrap Aggregating) is an ensemble learning technique designed to improve the accuracy and stability of machine learning algorithms. It involves the following steps:

​

  • Data Sampling: Creating multiple subsets of the training dataset using bootstrap sampling (random sampling with replacement).
  • Model Training: raining a separate model on each subset of the data.
  • Aggregation: Combining the predictions from all individual models (averaged for regression or majority voting for classification) to produce the final output.

8

9 of 138

Ensemble Learning: Bagging

​

9

10 of 138

Ensemble Learning: Bagging

​

Key Benefits:

  • Reduces Variance: By averaging multiple predictions, bagging reduces the variance of the model and helps prevent overfitting.
  • Improves Accuracy: Combining multiple models usually leads to better performance than individual models.

​

Overview of Bagging classifier algorithm:

  • Bootstrap Sampling
  • Base Model Training
  • Prediction Aggregation
  • Out-of-Bag (OOB) Evaluation
  • Final Prediction

10

11 of 138

Ensemble Learning: Bagging

​

Example of Bagging Algorithms:

  • Random Forests (an extension of bagging applied to decision trees)

11

12 of 138

Ensemble Learning: Random Forest

​

A Random Forest is a collection of decision trees that work together to make predictions. In this article, we'll explain how the Random Forest algorithm works and how to use it.

​

​

12

13 of 138

Ensemble Learning: Boosting

​

Boosting is an ensemble technique that combines multiple weak learners to create a strong learner. Weak models are trained in series such that each next model tries to correct errors of the previous model until the entire training dataset is predicted correctly.

13

14 of 138

Ensemble Learning: Boosting

​

Overview of Boosting algorithm:

  • Initialize Model Weights: Begin with a single weak learner and assign equal weights to all training examples.
  • Train Weak Learner: Train weak learners on these dataset.
  • Sequential Learning: Boosting works by training models sequentially where each model focuses on correcting the errors of its predecessor. Boosting typically uses a single type of weak learner like decision trees.
  • Weight Adjustment: Boosting assigns weights to training datapoints. Misclassified examples receive higher weights in the next iteration so that next models pay more attention to them.

14

15 of 138

Ensemble Learning: Boosting

​

Key Benefits:

  • Reduces Bias: By focusing on hard-to-classify instances, boosting reduces bias and improves the overall model accuracy.
  • Produces Strong Predictors: Combining weak learners leads to a strong predictive model.

​

Example of Boosting Algorithms:

  • AdaBoost
  • Gradient Boosting Machines (GBM)
  • XGBoost
  • LightGBM

15

16 of 138

Ensemble Learning: Stacked Generalization

​

​

​

Stacking (Stacked Generalization) is an ensemble learning technique that aims to combine multiple models to improve predictive performance. It involves the following steps:

  • Base Models: Training multiple models (level-0 models) on the same dataset.
  • Meta-Model: Training a new model (level-1 or meta-model) to combine the predictions of the base models. Using the predictions of the base models as input features for the meta-model.

​

​

16

17 of 138

Ensemble Learning: Stacked Generalization

​

​

​

Key Benefits:

  • Leverages Model Diversity: By combining different types of models, stacking can capture a wide range of patterns in the data.
  • Improves Performance: The meta-model learns how to best combine the predictions from the base models, often leading to improved performance over individual models.

​

​

17

18 of 138

Random Forest

Random forests or random decision forests is an ensemble learning method for classification, regression and other tasks that works by creating a multitude of decision trees during training.

18

19 of 138

Random Forest

19

20 of 138

Random Forest

20

21 of 138

Random Forest

21

22 of 138

Random Forest

22

23 of 138

Random Forest

23

24 of 138

Random Forest

24

25 of 138

Random Forest

25

26 of 138

Random Forest

26

27 of 138

Random Forest

27

28 of 138

Random Forest

28

29 of 138

Random Forest

29

30 of 138

Random Forest

30

31 of 138

Random Forest

31

32 of 138

Random Forest

32

33 of 138

Adaboost

33

34 of 138

Random Forest

34

35 of 138

Random Forest

35

36 of 138

Random Forest

36

37 of 138

Random Forest

37

38 of 138

Random Forest

38

39 of 138

Random Forest

39

40 of 138

Random Forest

40

41 of 138

Random Forest

41

42 of 138

Random Forest

42

43 of 138

Adaboost

43

44 of 138

RF

44

45 of 138

RF

45

46 of 138

RF

46

47 of 138

RF

47

48 of 138

RF

48

49 of 138

RF

49

50 of 138

RF

50

51 of 138

RF

51

52 of 138

RF

52

53 of 138

RF

53

54 of 138

RF

54

55 of 138

RF

55

56 of 138

RF

56

57 of 138

RF

57

58 of 138

RF

58

59 of 138

RF

59

60 of 138

RF

60

61 of 138

RF

61

62 of 138

RF

62

63 of 138

RF

63

64 of 138

RF

64

65 of 138

RF

65

66 of 138

RF

66

67 of 138

RF

67

68 of 138

RF

68

69 of 138

RF

69

70 of 138

Adaboost

AdaBoost (short for Adaptive Boosting) is a statistical classification meta-algorithm formulated by Yoav Freund and Robert Schapire in 1995, who won the 2003 Gödel Prize for their work.

70

71 of 138

Adaboost

71

72 of 138

Adaboost

72

73 of 138

Adaboost

73

74 of 138

Adaboost

74

75 of 138

Adaboost

75

76 of 138

Adaboost

76

77 of 138

Adaboost

77

78 of 138

Adaboost

78

79 of 138

Adaboost

79

80 of 138

Adaboost

80

81 of 138

Adaboost

81

82 of 138

Adaboost

82

83 of 138

Adaboost

83

84 of 138

Adaboost

84

85 of 138

Adaboost

85

86 of 138

Adaboost

86

87 of 138

Adaboost

87

88 of 138

Adaboost

88

89 of 138

Adaboost

89

90 of 138

Adaboost

90

91 of 138

Adaboost

91

92 of 138

Adaboost

92

93 of 138

Adaboost

93

94 of 138

Adaboost

94

95 of 138

Adaboost

95

96 of 138

Adaboost

96

97 of 138

Adaboost

97

98 of 138

Adaboost

98

99 of 138

Adaboost

99

100 of 138

Adaboost

100

101 of 138

Adaboost

101

102 of 138

Adaboost

102

103 of 138

Adaboost

103

104 of 138

Adaboost

104

105 of 138

Adaboost

105

106 of 138

Adaboost

106

107 of 138

Adaboost

107

108 of 138

Adaboost

108

109 of 138

Adaboost

109

110 of 138

Adaboost

110

111 of 138

Adaboost

111

112 of 138

Adaboost

112

113 of 138

Adaboost

113

114 of 138

Adaboost

114

115 of 138

Adaboost

115

116 of 138

Adaboost

116

117 of 138

Adaboost

117

118 of 138

Adaboost

118

119 of 138

Adaboost

119

120 of 138

Adaboost

120

121 of 138

Adaboost

121

122 of 138

Adaboost

122

123 of 138

Adaboost

123

124 of 138

Adaboost

124

125 of 138

Adaboost

125

126 of 138

Adaboost

126

127 of 138

Adaboost

127

128 of 138

Adaboost

128

129 of 138

Adaboost

129

130 of 138

Adaboost

130

131 of 138

Adaboost

131

132 of 138

Adaboost

132

133 of 138

Adaboost

133

134 of 138

Adaboost

134

135 of 138

Adaboost

135

136 of 138

Adaboost

136

137 of 138

Adaboost

137

138 of 138

Thank You

138