decision trees some exercises
play

Decision Trees Some exercises 1. Exemplifying how to compute - PowerPoint PPT Presentation

0. Decision Trees Some exercises 1. Exemplifying how to compute information gains and how to work with decision stumps CMU, 2013 fall, W. Cohen E. Xing, sample questions, pr. 4 2. Timmy wants to know how to do well for ML exam. He collects


  1. 23. As of September 2012, 800 extrasolar planets have been identified in our galaxy. Super- secret surveying spaceships sent to all these planets have established whether they are habitable for humans or not, but sending a spaceship to each planet is expensive. In this problem, you will come up with decision trees to predict if a planet is habitable based only on features observable using telescopes. Size Orbit Habitable Count a. In nearby table you are given the data from all 800 planets surveyed so far. The fea- Big Near Yes 20 tures observed by telescope are Size (“Big” or Big Far Yes 170 “Small”), and Orbit (“Near” or “Far”). Each Small Near Yes 139 row indicates the values of the features and Small Far Yes 45 habitability, and how many times that set of Big Near No 130 values was observed. So, for example, there Big Far No 30 were 20 “Big” planets “Near” their star that Small Near No 11 were habitable. Small Far No 255 Derive and draw the decision tree learned by ID3 on this data (use the maximum information gain criterion for splits, don’t do any pruning). Make sure to clearly mark at each node what attribute you are splitting on, and which value corresponds to which branch. By each leaf node of the tree, write in the number of habitable and inhabitable planets in the training data that belong to that node.

  2. 24. Answer: Level 1 H(374/800) H(374/800) [374+,426−] [374+,426−] Size Orbit B S N F [190+,160−] [184+,266−] [159+,141−] [215+,285−] H(19/35) H(92/225) H(47/100) H(43/100) � 92 � 19 � � 35 + 45 H ( Habitable | Size ) = 80 · H 80 · H 35 225 80 · 0 . 9946 + 45 35 IG ( Habitable ; Size ) = 0 . 0128 = 80 · 0 . 9759 = 0 . 9841 � 47 � 43 � � 3 + 5 H ( Habitable | Orbit ) = 8 · H 8 · H IG ( Habitable ; Orbit ) = 0 . 0067 100 100 3 8 · 0 . 9974 + 5 = 8 · 0 . 9858 = 0 . 9901

  3. 25. The final decision tree [374+,426−] Size B S [190+,160−] [184+,266−] Orbit Orbit N F N F [20+,130−] [170+,30−] [139+,11−] [45+,255−] − + + −

  4. 26. Size Orbit Temperature Habitable b. For just 9 of the planets, a third feature, Temperature (in Kelvin degrees), Big Far 205 No has been measured, as shown in the Big Near 205 No nearby table. Big Near 260 Yes Redo all the steps from part a on this data Big Near 380 Yes using all three features. For the Temper- Small Far 205 No ature feature, in each iteration you must Small Far 260 Yes maximize over all possible binary thresh- Small Near 260 Yes olding splits (such as T ≤ 250 vs. T > 250 , Small Near 380 No for example). Small Near 380 No According to your decision tree, would a planet with the features (Big, Near, 280) be predicted to be habitable or not habitable? Hint : You might need to use the following values of the entropy function for a Bernoulli variable of parameter p : H (1 / 3) = 0 . 9182 , H (2 / 5) = 0 . 9709 , H (92 / 225) = 0 . 9759 , H (43 / 100) = 0 . 9858 , H (16 / 35) = 0 . 9946 , H (47 / 100) = 0 . 9974 .

  5. 27. Answer Binary threshold splits for the continuous attribute Temperature : Temperature 205 232.5 260 320 380

  6. 28. Answer: Level 1 H(4/9) H(4/9) H(4/9) H(4/9) [4+,5−] [4+,5−] [4+,5−] [4+,5−] Size Orbit T<=232.5 T<=320 B S F N Y N Y N [2+,2−] [2+,3−] [1+,2−] [3+,3−] [0+,3−] [4+,2−] [3+,3−] [1+,2−] H=1 H(2/5) H(1/3) H=1 H(1/3) H=1 H(1/3) − H=0 = = > > > > � 187 � � 2 IG ( Habitable ; Size ) = H − 0 . 9838 9 + 5 4 = 4 9 + 5 � 400 H ( Habitable | Size ) = 9 · H 9 · 0 . 9709 = 0 . 9838 5 = 0 . 9969 − 0 . 9838 � 1 2 � = 2 = 0 . 0072 H ( Habitable | Temp ≤ 232 . 5) = 3 · H 3 · 0 . 9182 = 0 . 6121 3 IG ( Habitable ; Temp ≤ 232 . 5) = 0 . 3788

  7. 29. Answer: Level 2 H(1/3) H(1/3) H(1/3) [4+,2−] [4+,2−] [4+,2−] Size Orbit T<=320 B S F N Y N [2+,0−] [2+,2−] [1+,0−] [3+,2−] [3+,0−] [1+,2−] H=1 H(2/5) H(1/3) + + + H=0 H=0 H=0 > > > >= Note : The plain lines indicate that both the specific conditional entropies and their coefficients (weights) in the mean conditional entropies satisfy the indicated relationship. (For exam- ple, H (2 / 5) > H (1 / 3) and 5 / 6 > 3 / 6 .) The dotted lines indicate that only the specific conditional entropies satisfy the indicated rela- tionship. (For example, H (2 / 2) = 1 > H (2 / 5) but 4 / 6 < 5 / 6 .)

  8. 30. The final decision tree: [4+,5−] T<=232.5 Y N [0+,3−] [4+,2−] c. According to your decision tree, would a planet with the features T<=320 − (Big, Near, 280) be predicted to be Y N habitable or not habitable? Answer: habitable . [3+,0−] [1+,2−] Size + B S [1+,0−] [0+,2−] + −

  9. 31. Exemplifying the application of the ID3 algorithm on continuous attributes , and in the presence of a noise . Decision surfaces; decision boundaries. The computation of the LOOCV error CMU, 2002 fall, Andrew Moore, midterm, pr. 3

  10. 32. X Y Suppose we are learning a classifier with binary input values Y = 0 and 1 0 Y = 1 . There is one real-valued input X . The training data is given in the 2 0 nearby table. 3 0 4 0 Assume that we learn a decision tree on this data. Assume that when 6 1 the decision tree splits on the real-valued attribute X , it puts the split 7 1 threshold halfway between the attributes that surround the split. For 8 1 example , using information gain as splitting criterion, the decision tree 8 . 5 0 would initially choos to split at X = 5 , which is halfway between X = 4 and 9 1 X = 6 datapoints. 10 1 Let Algorithm DT2 be the method of learning a decision tree with only two leaf nodes (i.e., only one split). Let Algorithm DT ⋆ be the method of learning a decision tree fully, with no prunning. a. What will be the training set error for DT2 and respectively DT ⋆ on our data? b. What will be the leave-one-out cross-validation error (LOOCV) for DT2 and re- spectively DT ⋆ on our data?

  11. 33. • training data: ID3 tree: X 0 1 2 3 4 5 6 7 8 9 10 [5−,5+] • discretization / decision thresholds: X<5 0 Da Nu X 1 2 3 4 6 7 8 9 10 [4−,0+] [1−,5+] 5 8.25 8.75 0 X<8.25 1 • compact representation of the ID3 tree: Da Nu [0−,3+] [1−,2+] 5 X 1 2 3 4 6 7 8 9 10 1 X<8.75 0 1 2 2 Da Nu • decision “surfaces”: − − [1−,0+] [0−,2+] + + 0 1 X 5 8.25 8.75

  12. 34. Level 0: [5−,5+] [5−,5+] [5−,5+] X<5 X<8.25 X<8.75 Da Nu Da Nu Da Nu [4−,0+] [1−,5+] [4−,3+] [1−,2+] [5−,3+] [0−,2+] < < ID3: < = IG computations Level 1: [1−,5+] [1−,5+] X<8.25 X<8.75 Da Nu Da Nu [0−,3+] [1−,2+] [1−,3+] [0−,2+] IG: 0.191 IG: 0.109 − − + + Decision "surfaces": 5 8.25 8.75

  13. 35. − − + + X=1,2,3: 5 8.25 8.75 − − + + X=4: 4.5 8.25 8.75 − − + + X=6: ID3, LOOCV: 5.5 8.25 8.75 Decision surfaces − − + + X=7: 5 8.25 8.75 − − + + X=8: 5 7.75 8.75 LOOCV error: 3/10 − + + + X=8.5: 5 − − + + X=9: 5 8.25 9.25 − − + + X=10: 5 8.25 8.75

  14. 36. DT2 [5−,5+] X<5 Da Nu [4−,0+] [1−,5+] 0 1 Decision "surfaces": − + 5

  15. 37. DT2, LOOCV IG computations [4−,5+] [4−,5+] [4−,5+] X<5 X<8.25 X<8.75 /4.5 Da Nu Da Nu Da Nu Case 1: X=1, 2, 3, 4 [3−,0+] [1−,5+] [3−,3+] [1−,2+] [4−,3+] [0−,2+] < < < = [5−,4+] [5−,4+] [5−,4+] X<5 X<8.25 X<8.75 /5.5 /7.75 Da Nu Da Nu Da Nu Case 2: X=6, 7, 8 [4−,0+] [1−,4+] [4−,2+] [1−,2+] [5−,2+] [0−,2+] < = < =

  16. 38. DT2, CVLOO IG computations (cont’d) [4−,5+] X<5 Case 3: X=8.5 Da Nu [4−,0+] [0−,5+] [5−,4+] [5−,4+] [5−,4+] X<5 X<8.25 X<8.75 /9.25 Da Nu Da Nu Da Nu Case 2: X=9, 10 [4−,0+] [1−,4+] [4−,3+] [1−,1+] [5−,3+] [0−,1+] < < < = CVLOO error: 1/10

  17. 39. Applying ID3 on a dataset with two continuous attributes: decision zones Liviu Ciortuz, 2017

  18. 40. X 2 Consider the training dataset in the nearby figure. 4 X 1 and X 2 are considered countinous at- tributes. 3 Apply the ID3 algorithm on this dataset. 2 Draw the resulting decision tree. Make a graphical representation of the 1 decision areas and decision boundaries determined by ID3. 0 X 1 0 1 2 3 4 5

  19. 41. Solution Level 1: [4+,5−] [4+,5−] [4+,5−] [4+,5−] [4+,5−] X1 < 5/2 X1 < 9/2 X2 < 3/2 X2 < 5/2 X2 < 7/2 Y N Y N Y N Y N Y N [2+,0−] [2+,5−] [2+,4−] [2+,1−] [1+,1−] [3+,4−] [3+,2−] [1+,3−] [4+,2−] [0+,3−] H(2/7) H(1/3) H(1/3) H=1 H(3/7) H(2/5) H(1/4) H(1/3) − − IG=0.091 H=0 H=0 > IG=0.319 > IG=0.378 = < H[Y| . ] = 7/9 H(2/7) H[Y| . ] = 2/3 H(1/3) H[Y| . ] = 5/9 H(2/5) + 4/9 H(1/4)

  20. 42. [4+,2−] [4+,2−] [4+,2−] [4+,2−] Level 2: X1 < 5/2 X1 < 4 X2 < 3/2 X2 < 5/2 Y N Y N Y N Y N [2+,0−] [2+,2−] [2+,2−] [2+,0−] [1+,1−] [3+,1−] [3+,2−] [1+,0−] H=1 H=1 H=1 H(1/4) H(2/5) − − − IG=0.04 H=0 H=0 H=0 IG=0.109 IG=0.251 = IG=0.251 > > = H[Y| . ] = 2/3 H[Y| . ] = 5/6 H(2/5) H[Y| . ] = 1/3 + 2/3 H(1/4) Notes: 1. Split thresholds for continuous attributes must be recomputed at each new iteration, because they may change. (For instance, here above, 4 replaces 4.5 as a threshold for X 1 .) 2. In the current stage, i.e., for the current node in the ID3 tree you may choose (as test) either X 1 < 5 / 2 or X 1 < 4 . 3. Here above we have an example of reverse relationships between weighted and respectively un-weighted specific entropies : H [2+ , 2 − ] > H [3+ , 2 − ] but 4 6 · H [2+ , 2 − ] < 5 6 · H [3+ , 2 − ] .

  21. 43. The final decision tree: Decision areas: [4+,5−] X 2 X2 < 7/2 Y N 4 [4+,2−] [0+,3−] X1 < 5/2 3 + − Y N 2 [2+,0−] [2+,2−] X1 < 4 + + 1 B S 0 [2+,0−] [0+,2−] X 1 0 1 2 3 4 5 + −

  22. 44. Exemplifying pre- and post-puning of decision trees using a threshold for the Information Gain CMU, 2006 spring, Carlos Guestrin, midterm, pr. 4 [ adapted by Liviu Ciortuz ]

  23. 45. Starting from the data in the following table, the ID3 algorithm builds the decision tree shown nearby. X V W X Y 0 1 0 0 0 0 V 0 1 0 1 1 0 1 1 0 0 1 1 1 0 0 W W 0 1 0 1 1 1 1 1 0 1 1 0 a. One idea for pruning such a decision tree would be to start at the root, and prune splits for which the information gain (or some other criterion) is less than some small ε . This is called top- down pruning. What is the decision tree returned for ε = 0.0001? What is the training set error for this tree?

  24. 46. Answer We will first augment the given decision tree with informations regarding the data partitions (i.e., the [3+;2−] number of positive and, respectively, negative in- X stances) which were assigned to each test node during 0 1 the application of ID3 algorithm. [2+;2−] [1+;0−] The information gain yielded by the attribute X in the root node is: V 1 0 1 H [3+; 2 − ] − 1 / 5 · 0 − 4 / 5 · 1 = 0 . 971 − 0 . 8 = 0 . 171 > ε. [1+;1−] [1+;1−] Therefore, this node will not be eliminated from the W W tree. 0 1 0 1 The information gain for the attribute V (in the left- [0+;1−] [1+;0−] [1+;0−] [0+;1−] hand side child of the root node) is: 0 1 1 0 H [2+; 2 − ] − 1 / 2 · 1 − 1 / 2 · 1 = 1 − 1 = 0 < ε. X So, the whole left subtree will be cut off and replaced by a decision 0 1 node, as shown nearby. The training error produced by this tree is 2 / 5 . 0 1

  25. 47. b. Another option would be to start at the leaves, and prune subtrees for which the information gain (or some other criterion) of a split is less than some small ε . In this method, no ancestors of children with high information gain will get pruned. This is called bottom-up pruning. What is the tree returned for ε = 0.0001? What is the training set error for this tree? Answer: The information gain of V is IG ( Y ; V ) = 0 . A step later, the infor- mation gain of W (for either one of the descendent nodes of V ) is IG ( Y ; W ) = 1 . So bottom-up pruning won’t delete any nodes and the tree [given in the problem statement] remains unchanged. The training error is 0 .

  26. 48. c. Discuss when you would want to choose bottom-up pruning over top-down pruning and vice versa. Answer: Top-down pruning is computationally cheaper . When building the tree we can determine when to stop (no need for real pruning). But as we saw top-down pruning prunes too much. On the other hand, bottom-up pruning is more expensive since we have to first build a full tree — which can be exponentially large — and then apply pruning. The second problem with bottom-up pruning is that supperfluous attributes may fullish it (see CMU, CMU, 2009 fall, Carlos Guestrin, HW1, pr. 2.4). The third prob- lem with it is that in the lower levels of the tree the number of examples in the subtree gets smaller so information gain might be an inappropriate criterion for pruning, so one would usually use a statistical test instead.

  27. 49. Exemplifying χ 2 -Based Pruning of Decision Trees CMU, 2010 fall, Ziv Bar-Joseph, HW2, pr. 2.1

  28. 50. In class, we learned a decision tree pruning algorithm that iter- atively visited subtrees and used a validation dataset to decide whether to remove the subtree. However, sometimes it is desir- able to prune the tree after training on all of the available data. One such approach is based on statistical hypothesis testing. After learning the tree, we visit each internal node and test whether the attribute split at that node is actually uncorrelated with the class labels . We hypothesize that the attribute is independent and then use Pearson’s chi-square test to generate a test statistic that may provide evidence that we should reject this “null” hypothesis . If we fail to reject the hypothesis, we prune the subtree at that node.

  29. 51. a. At each internal node we can create a contingency table for the training examples that pass through that node on their paths to the leaves. The table will have the c class labels associated with the columns and the r values the split attribute associated with the rows. Each entry O i,j in the table is the number of times we observe a training sample with that attribute value and label, where i is the row index that corresponds to an attribute value and j is the column index that corresponds to a class label. In order to calculate the chi-square test statistic, we need a similar table of expected counts. The expected count is the number of observations we would expect if the class and attribute are independent. Derive a formula for each expected count E i,j in the table. Hint : What is the probability that a training example that passes through the node has a particular label? Using this probability and the independence assumption, what can you say about how many examples with a specific attribute value are expected to also have the class label?

  30. 52. b. Given these two tables for the split, you can now calculate the chi-square test statistic r c ( O i,j − E i,j ) 2 � � χ 2 = E i,j i =1 j =1 with degrees of freedom ( r − 1)( c − 1) . You can plug the test statistic and degrees of freedom into a software package a or an online calculator b to calculate a p -value. Typically, if p < 0 . 05 we reject the null hypothesis that the attribute and class are independent and say the split is statistically significant. The decision tree given on the next slide was built from the data in the table nearby. For each of the 3 internal nodes in the decision tree, show the p -value for the split and state whether it is statistically significant. How many internal nodes will the tree have if we prune splits with p ≥ 0 . 05 ? a Use 1-chi2cdf(x,df) in MATLAB or CHIDIST(x,df) in Excel. b (https://en.m.wikipedia.org/wiki/Chi-square distribution#Table of .CF.872 value vs p-value.

  31. 53. Input: [4−,8+] X 1 X 2 X 3 X 4 Class X 1 1 0 0 0 4 0 1 1 0 1 0 1 0 1 0 0 0 [4−,2+] [0−,6+] 1 0 1 1 1 X 1 0 1 1 1 1 1 0 1 0 0 1 0 0 1 0 0 0 1 [3−,0+] [1−,2+] 0 1 0 1 1 X 0 2 1 0 0 1 1 0 1 1 0 1 1 1 1 1 1 1 1 [0−,2+] [1−,0+] 0 0 0 0 0 0 1

  32. 54. Idea While traversing the ID3 tree [usually in bottom-up manner], remove the nodes for which there is not enough (“significant”) statistical evidence that there is a dependence between the values of the input attribute tested in that node and the values of the output attribute (the labels), supported by the set of instances assigned to that node.

  33. 55. Contingency tables P ( X 4 = 0) = 6 12 = 1 2 , P ( X 4 = 1) = 1  O X 4 Class = 0 Class = 1  2  N =12 ⇒ X 4 = 0 4 2 P ( Class = 0) = 4 12 = 1 3 , P ( Class = 1) = 2  X 4 = 1 0 6  3 P ( X 1 = 0 | X 4 = 0) = 3 6 = 1   2      P ( X 1 = 1 | X 4 = 0) = 1  O X 1 | X 4 =0 Class = 0 Class = 1    2  N =6 ⇒ X 1 = 0 3 0 P ( Class = 0 | X 4 = 0) = 4 6 = 2  X 1 = 1 1 2   3     P ( Class = 1 | X 4 = 0) = 1     3 P ( X 2 = 0 | X 4 = 0 , X 1 = 1) = 2   3      P ( X 2 = 1 | X 4 = 0 , X 1 = 1) = 1 O X 2 | X 4 =0 ,X 1 =1 Class = 0 Class = 1     3  N =3 X 2 = 0 0 2 ⇒ P ( Class = 0 | X 4 = 0 , X 1 = 1) = 1   X 2 = 1 1 0  3     P ( Class = 1 | X 4 = 0 , X 1 = 1) = 2     3

  34. 56. The reasoning that leads to the computation of the expected number of observations P ( A = i, C = j ) = P ( A = i ) · P ( C = j ) � c � r k =1 O i,k k =1 O k,j P ( A = i ) = and P ( C = j ) = N N ( � c k =1 O i,k ) ( � r k =1 O k,j ) indep. P ( A = i, C = j ) = N 2 E [ A = i, C = j ] = N · P ( A = i, C = j )

  35. 57. Expected number of observations E X 4 Class = 0 Class = 1 E X 1 | X 4 Class = 0 Class = 1 X 4 = 0 2 4 X 1 = 0 2 1 X 4 = 1 2 4 X 1 = 1 2 1 E X 2 | X 4 ,X 1 =1 Class = 0 Class = 1 2 4 X 2 = 0 3 3 1 2 X 2 = 1 3 3 E X 4 ( X 4 = 0 , Class = 0) : N = 12 , P ( X 4 = 0) = 1 si P ( Class = 0) = 1 2 ¸ 3 ⇒ N · P ( X 4 = 0 , Class = 0) = N · P ( X 4 = 0) · P ( Class = 0) = 12 · 1 2 · 1 3 = 2

  36. 58. χ 2 Statistics r c ( O i,j − E i,j ) 2 � � χ 2 = E i,j i =1 j =1 X 4 = (4 − 2) 2 + (0 − 2) 2 + (2 − 4) 2 + (6 − 4) 2 χ 2 = 2 + 2 + 1 + 1 = 6 2 2 4 4 X 1 | X 4=0 = (3 − 2) 2 + (1 − 2) 2 + (0 − 1) 2 + (2 − 1) 2 χ 2 = 3 2 2 1 1 � � 2 � � 2 � � 2 � � 2 0 − 2 1 − 1 2 − 4 0 − 2 = 4 9 · 27 3 3 3 3 χ 2 X 2 | X 4=0 ,X 1=1 = + + + 4 = 3 2 1 4 2 3 3 3 3 p -values: 0 . 0143 , 0 . 0833 , and respectively 0 . 0833 . The first one of these p -values is smaller than ε , therefore the root node ( X 4 ) cannot be prunned.

  37. 59. Chi Squared Pearson test statistics 1.0 1.0 k = 1 k = 2 0.8 0.8 k = 3 k = 4 k = 6 0.6 0.6 k = 9 p−value 0.4 0.4 0.2 0.2 0.0 0.0 0 0 2 2 4 4 6 6 8 8 χ 2 − Pearson’s cumulative test statistic

  38. 60. Output (pruned tree) for 95% confidence level X 4 0 1 0 1

  39. 61. The AdaBoost algorithm: The convergence – in certain conditions to 0 – of the training error CMU, 2015 fall, Ziv Bar-Joseph, Eric Xing, HW4, pr. 2.1-5 CMU, 2009 fall, Carlos Guestrin, HW2, pr. 3.1 CMU, 2009 fall, Eric Xing, HW3, pr. 4.2.2

  40. 62. Consider m training examples S = { ( x 1 , y 1 ) , . . . , ( x m , y m ) } , where x ∈ X and y ∈ {− 1 , 1 } . Suppose we have a weak learning algorithm A which produces a hypothesis h : X → {− 1 , 1 } given any distribution D of examples. AdaBoost is an iterative algorithm which works as follows: • Begin with a uniform distribution D 1 ( i ) = 1 m , i = 1 , . . . , m . • At each round t = 1 , . . . , T , – run the weak learning algorithm A on the distribution D t and produce the hypothsis h t ; Note : Since A is a weak learning algorithm, the produced hypothesis h t at round t is only slightly better than random guessing, say, by a margin γ t : ε t = err D t ( h t ) = Pr x ∼ D t [ y � = h t ( x )] = 1 2 − γ t . [If at a certain iteration t < T the weak classifier A cannot produce a hypothesis better than random guessing (i.e., γ t = 0 ) or it produces a hypothesis for which ε t = 0 , then the AdaBoost algorithm should be stopped.] – update D t +1 ( i ) = 1 · D t ( i ) · e − α t y i h t ( x i ) for i = 1 , . . . , m , Z t = 1 2 ln 1 − ε t not. where α t , and Z t is the normalizer. ε t �� T � • In the end, deliver H = sign t =1 α t h t as the learned hypothesis, which will act as a weighted majority vote .

  41. 63. We will prove that the training error err S ( H ) of AdaBoost decreases at a very fast rate, and in certain cases it converges to 0 . Important Remark The above formulation of the AdaBoost algorithm states no restriction on the h t hypothesis delivered by the weak classifier A at iteration t , except that ε t < 1 / 2 . However, in another formulation of the AdaBoost algorithm (in a more gen- eral setup; see for instance MIT, 2006 fall, Tommi Jaakkola, HW4, problem 3), it is requested / reccommended that hypothesis h t be chosen by (approxi- mately) maximizing the [criterion of] weighted training error on a whole class of hypotheses like, for instance, decision trees of depth 1 (decision stumps). In this problem we will not be concerned with such a request , but we will comply with it for instance in problem CMU, 2015 fall, Ziv Bar-Joseph, Eric Xing, HW4, pr2.6, when showing how AdaBoost works in practice.

  42. 64. a. Show that the [particular] choice of α t = 1 2 ln 1 − ε t implies err D t +1 ( h t ) = 1 / 2 . ε t � � − 1 m · � T e − y i f ( x i ) , where f ( x ) = � T b. Show that D T +1 ( i ) = t =1 Z t t =1 α t h t ( x ) . 1 c. Show that err S ( H ) ≤ � T not. � m t =1 Z t , where err S ( H ) = i =1 1 { H ( x i ) � = y i } is the traing error m produced by AdaBoost. d. Obviously, we would like to minimize test set error produced by AdaBoost, but it is hard to do so directly. We thus settle for greedily optimizing the upper bound on the training error found at part c . Observe that Z 1 , . . . , Z t − 1 are determined by the first t − 1 iterations, and we cannot change them at iteration t . A greedy step we can take to minimize the training set error bound on round t is to minimize Z t . Prove that the value of α t that minimizes Z t (among all possible values for α t ) is indeed α t = 1 2 ln 1 − ε t (see the previous slide). ε t e. Show that � T t =1 Z t ≤ e − 2 � T t =1 γ 2 t . f. From part c and d , we know the training error decreases at exponential rate with respect to T . Assume that there is a number γ > 0 such that γ ≤ γ t for t = 1 , . . . , T . (This is called empirical γ -weak learnability .) How many rounds are needed to achieve a training error ε > 0 ? Please express in big- O notation, T = O ( · ) .

  43. 65. Solution a. If we define the correct set C = { i : y i h t ( x i ) ≥ 0 } and the mistake set M = { i : y i h t ( x i ) < 0 } , we can write: m 1 D t ( i ) e α t = 1 e α t = 1 � � � · ε t · e α t err D t +1 ( h t ) = D t +1 ( i ) · 1 { y i � = h t ( x i ) } = D t ( i ) Z t Z t Z t i =1 i ∈ M i ∈ M � �� � ε t m � � � D t ( i ) e − α t y i h t ( x i ) = D t ( i ) e − α t + D t ( i ) e α t = (1 − ε t ) · e − α t + ε t · e α t Z t = (1) i =1 i ∈ C i ∈ M � � 1 − ε t 1 ln 1 − ε t � � � � ln 1 − ε t 1 ε t ε t e α t = e and e − α t = 2 ε t = e = e α t = ε t 1 − ε t � � ε t 1 − ε t � ⇒ Z t = (1 − ε t ) · + ε t · = 2 ε t (1 − ε t ) (2) 1 − ε t ε t � ⇒ err D t +1 ( h t ) = 1 1 1 − ε t = 1 · ε t · e α t = · ε t · � Z t ε t 2 2 ε t (1 − ε t ) Note that 1 − ε t > 0 because ε t ∈ (0 , 1 / 2) . ε t

  44. 66. b. We will expand D t ( i ) recursively: 1 D T ( i ) e − α T y i h T ( x i ) = D T ( i ) 1 e − α T y i h T ( x i ) D T +1 ( i ) = Z T Z T 1 e − α T − 1 y i h T − 1 ( x i ) 1 e − α T y i h T ( x i ) = D T − 1 ( i ) Z T − 1 Z T . . . 1 1 t =1 α t y i h t ( x i ) = e − � T e − y i f ( x i ) . = D 1 ( i ) � T m · � T t =1 Z t t =1 Z t c. We will make use of the fact that exponential loss upper bounds the 0-1 loss, i.e. 1 { x< 0 } ≤ e − x : m 1 � err S ( H ) = 1 { y i f ( x i ) < 0 } m i =1 m m T m T 1 e − y i f ( x i ) = 1 � � � � � ≤ D T +1 ( i ) · m · Z t = D T +1 ( i ) Z t m m i =1 i =1 t =1 i =1 t =1 � m � T � � T � � � = D T +1 ( i ) · Z t = Z t . i =1 t =1 t =1 � �� � 1

  45. 67. d. We will start from the equation Z t = ε t · e α t + (1 − ε t ) · e − α t , which has been proven at part a . Note that the right-hand side is constant with respect to ε t (the error produced by h t , the hypothesis produced by the weak classifier A at the current step). Then we will proceed as usually, computing the partial derivative w.r.t. ε t : ∂ � ε t · e α t + (1 − ε t ) · e − α t � = 0 ⇔ ε t · e α t − (1 − ε t ) · e − α t = 0 ∂α t ⇔ ε t · ( e α t ) 2 = 1 − ε t ⇔ e 2 α t = 1 − ε t ⇔ 2 α t = ln 1 − ε t ⇔ α t = 1 2 ln 1 − ε t . ε t ε t ε t Note that 1 − ε t > 1 (and therefore α t > 0 ) because ε t ∈ (0 , 1 / 2) . ε t It can also be immediately shown that α t = 1 2 ln 1 − ε t is indeed the value for ε t which we reach the minim of the expression ε t · e α t +(1 − ε t ) · e − α t , and therefore of Z t too: ε t · e α t − (1 − ε t ) · e − α t > 0 ⇔ e 2 α t − 1 − ε t > 0 ⇔ α t > 1 2 ln 1 − ε t > 0 . ε t ε t

  46. 68. e. Making use of the relationship ( 2 ) proven at part a , and using the fact that 1 − x ≤ e − x for all x ∈ R , we can write: �� 1 T T T � � � 1 �� T � � � � � � 1 − 4 γ 2 Z t = 2 · ε t (1 − ε t ) = 2 · 2 − γ t 1 − 2 − γ t = t t =1 t =1 t =1 t =1 T T T � � � � � e − 2 γ 2 t = e − 2 � T t =1 γ 2 t ) 2 = e − 4 γ 2 t = ( e − 2 γ 2 ≤ t t =1 t =1 t =1 f. From the result obtained at parts c and d , we get: err S ( H ) ≤ e − 2 � T t =1 γ 2 t ≤ e − 2 T γ 2 Therefore, err S ( H ) < ε if − 2 T γ 2 < ln ε ⇔ 2 T γ 2 > − ln ε ⇔ 2 T γ 2 > ln 1 2 γ 2 ln 1 1 ε ⇔ T > ε � 1 � γ 2 ln 1 Hence we need T = O . ε Note : It follows that err S ( H ) → 0 as T → ∞ .

  47. 69. Exemplifying the application of AdaBoost algorithm CMU, 2015 fall, Ziv Bar-Joseph, Eric Xing, HW4, pr. 2.6

  48. 70. X 2 Consider the training dataset in the nearby fig- ure. Run T = 3 iterations of AdaBoost with deci- x 3 x 6 x 7 4 sion stumps (axis-aligned separators) as the base x 2 3 learners. Illustrate the learned weak hypotheses h t in this figure and fill in the table given below. x 1 x 4 x 2 8 (For the pseudo-code of the AdaBoost algorithm, see CMU, x x 1 5 9 2015 fall, Ziv Bar-Joseph, Eric Xing, HW4, pr. 2.1-5. Please 0 read the Important Remark that follows that pseudo-code!) X 1 0 1 2 3 4 5 t ε t α t D t (1) D t (2) D t (3) D t (4) D t (5) D t (6) D t (7) D t (8) D t (9) err S ( H ) 1 2 3 Note : The goal of this exercise is to help you understand how AdaBoost works in practice. It is advisable that — after understanding this exercise — you would implement a program / function that calculates the weighted training error produced by a given decision stump, w.r.t. a certain probabilistic distribution ( D ) defined on the training dataset. Later on you will extend this program to a full-fledged implementation of AdaBoost.

  49. 71. Solution Unlike the graphical reprezentation that we used until now for decision stumps (as trees of depth 1), here we will work with the following analit- ical representation : for a continuous attribute X taking values x ∈ R and for any threshold s ∈ R , we can define two decision stumps: � � 1 if x ≥ s − 1 if x ≥ s sign ( x − s ) = and sign ( s − x ) = − 1 if x < s 1 if x < s. For convenience, in the sequel we will denote the first decision stump with X ≥ s and the second with X < s . According to the Important Remark that follows the AdaBoost pseudo-code [see CMU, 2015 fall, Ziv Bar-Joseph, Eric Xing, HW4, pr. 2.1-5], at each iter- ation ( t ) the weak algorithm A selects the/a decision stump which, among all decision stumps, has the minimum weighted training error w.r.t. the current distribution ( D t ) on the training data.

  50. 72. Notes When applying the ID3 algorithm, for each continous attribute X , we used a threshold for each pair of examples ( x i , y i ) , ( x i +1 , y i +1 ) , with y i y i +1 < 0 such that x i < x i +1 , but no x j ∈ Val ( X ) for which x i < x j < x i +1 . We will proceed similarly when applying AdaBoost with decision stumps and continous attributes. [ In the case of ID3 algorithm, there is a theoretical result stating that there is no need to consider other thresholds for a continuous attribute X apart from those situated beteen pairs of successive values ( x i < x i +1 ) having opposite labels ( y i � = y i +1 ), because the Information Gain (IG) for the other thresholds ( x i < x i +1 , with y i = y i +1 ) is provably less than the maximal IG for X . LC: A similar result can be proven, which allows us to simplify the application of the weak classifier ( A ) in the framework of the AdaBoost algorithm. ] Moreover, we will consider also a threshold from the outside of the interval of values taken by the attribute X in the training dataset. [The decision stumps corresponding to this “outside” threshold can be associated with the decision trees of depth 0 that we met in other problems.]

  51. 73. Iteration t = 1 : Therefore, at this stage (i.e, the first iteration of AdaBoost) the thresholds for the two continuous variables ( X 1 and X 2 ) corresponding to the two coordinates of the training instances ( x 1 , . . . , x 9 ) are • 1 2 , 5 2 , and 9 2 for X 1 , and • 1 2 , 3 2 , 5 2 and 7 2 for X 2 . One can easily see that we can get rid of the “outside” threshold 1 2 for X 2 , because the decision stumps corresponding to this threshold act in the same as the decision stumps associated to the “outside” threshold 1 2 for X 1 . The decision stumps corresponding to this iteration together with their as- sociated weighted training errors are shown on the next slide. When filling those tabels, we have used the equalities err D t ( X 1 ≥ s ) = 1 − err D t ( X 1 < s ) and, similarly, err D t ( X 2 ≥ s ) = 1 − err D t ( X 2 < s ) , for any threshold s and every iteration t = 1 , 2 , . . . . These equalities are easy to prove.

  52. 74. 1 5 9 s 2 2 2 4 2 4 9 + 2 9 = 2 err D 1 ( X 1 < s ) 9 9 3 5 7 1 err D 1 ( X 1 ≥ s ) 9 9 3 1 3 5 7 s 2 2 2 2 4 1 9 + 3 9 = 4 2 9 + 1 9 = 1 2 err D 1 ( X 2 < s ) 9 9 3 9 5 5 2 7 err D 1 ( X 2 ≥ s ) 9 9 3 9 It can be seen that the minimal weighted training error ( ε 1 = 2 / 9 ) is obtained for the � 7 � decision stumps X 1 < 5 / 2 and X 2 < 7 / 2 . Therefore we can choose h 1 = sign 2 − X 2 as best hypothesis at iteration t = 1 ; the corresponding separator is the line X 2 = 7 2 . The h 1 hypothesis wrongly classifies the instances x 4 and x 5 . Then �� � � 1 2 − 2 9 = 5 18 and α 1 = 1 2 ln 1 − ε 1 1 − 2 : 2 7 γ 1 = = ln 9 = ln 2 ≈ 0 . 626 ε 1 9

  53. 75. Now the algorithm must get a new distribution ( D 2 ) by altering the old one ( D 1 ) so that the next iteration concentrates more on the misclassified instances.  � 1 · 1 2   9 · for i ∈ { 1 , 2 , 3 , 6 , 7 , 8 , 9 } ;  1  Z 1 7 ) y i h 1 ( x i ) = D 1 ( i )( e − α 1 D 2 ( i ) = � Z 1 � �� � √ 1 · 1 7   9 · for i ∈ { 4 , 5 } .  2 / 7  Z 1 2 Remember that Z 1 is a normalization factor for D 2 . X 2 So, 1/14 1/14 1/14 √ � � � � x 3 x x 1 2 7 = 2 14 4 6 7 − h 1 Z 1 = 7 · 7 + 2 · = 0 . 8315 + 1/14 9 2 9 x 3 2 1/14 1/4 1/14 Therefore, x 1 x x 2 4 8  � 1/4 1/14 9 14 · 1 7 = 1 2 x x  1  √ 9 · for i �∈ { 4 , 5 } ; 5 9   14 2 D 2 ( i ) = � 0 9 14 · 1 7 2 = 1  X 1  √ 9 · for i ∈ { 4 , 5 } .  0 1 2 3 4 5  4 2

  54. 76. Note � 7 � If, instead of sign 2 − X 2 we would have taken, as hypothesis h 1 , the deci- � 5 � sion stump sign 2 − X 1 , the subsequent calculus would have been slightly different (although both decision stumps have the same – minimal – weighted training error, 2 9 ): x 8 and x 9 would have been allocated the weights 1 4 , while si x 5 would have been allocated the weights 1 x 4 ¸ 14 . (Therefore, the output of AdaBoost may not be uniquely determined!)

  55. 77. Iteration t = 2 : 1 5 9 s 2 2 2 4 2 14 + 2 2 4 + 2 14 = 11 err D 2 ( X 1 < s ) 14 14 14 10 12 3 err D 2 ( X 1 ≥ s ) 14 14 14 1 3 5 7 s 2 2 2 2 4 1 4 + 3 14 = 13 2 4 + 1 14 = 8 2 4 = 1 err D 2 ( X 2 < s ) 14 28 14 2 10 15 6 1 err D 2 ( X 2 ≥ s ) 14 28 14 2 Note : According to the theoretical result presented at part a of CMU, 2015 fall, Ziv Bar-Joseph, Eric Xing, HW4, pr. 2.1-5, computing the weighted error rate of the decision stump [corresponding to the test] X 2 < 7 / 2 is now super- fluous, because this decision stump has been chosen as optimal hypothesis at the previous iteration. (Nevertheless, we had placed it into the tabel, for the sake of a thorough presentation.)

  56. 78. � 5 � Now the best hypothesis is h 2 = sign 2 − X 1 ; the corresponding separator is the line X 1 = 5 2 . P D 2 ( { x 8 , x 9 } ) = 2 14 = 1 ⇒ γ 2 = 1 2 − 1 7 = 5 ε 2 = 7 = 0 . 143 14 �� � � √ 1 − ε 2 1 − 1 : 1 α 2 = ln = ln 7 = ln 6 = 0 . 896 ε 2 7  1 · D 2 ( i ) · 1 √ if h 2 ( x i ) = y i ;   Z 2  1 6 ) y i h 2 ( x i ) = · D 2 ( i ) · ( e − α 2 D 3 ( i ) = √ Z 2 1 � �� � √   · D 2 ( i ) · 6 otherwise 1 / 6  Z 2  1 · 1 14 · 1 √ for i ∈ { 1 , 2 , 3 , 6 , 7 } ;    Z 2 6     1 · 1 4 · 1 = √ for i ∈ { 4 , 5 } ; Z 2 6    √ 1 · 1    14 · 6 for i ∈ { 8 , 9 } .  Z 2

  57. 79. √ √ √ 5 · 1 14 · 1 6 + 2 · 1 4 · 1 6 + 2 · 1 5 1 6 = 12 + 12 24 6 = 2 6 √ √ √ √ √ √ Z 2 = 14 · 6 = 6 + 6 + = ≈ 0 . 7 7 7 14 2 14 6 14 h 2 X 2 − + 1/24 1/24 1/24 x 3 x 6 x 7  7 6 · 1 14 · 1 6 = 1 4 − √ √ for i ∈ { 1 , 2 , 3 , 6 , 7 } ; h 1    24 + 2 1/24  x 2   3   7 6 · 1 4 · 1 6 = 7 √ √ for i ∈ { 4 , 5 } ; D 3 ( i ) = 1/24 7/48 1/4 x 1 x 4 x 48 2 2  8    √ 7 · 1 6 = 1 7/48 1/4   x x 9 √ 14 · for i ∈ { 8 , 9 } .  1  4 5 2 6 0 X 1 0 1 2 3 4 5

  58. 80. Iteration t = 3 : 1 5 9 s 2 2 2 24 + 2 2 4 = 7 2 24 + 2 · 7 2 48 + 2 · 1 4 = 21 err D 3 ( X 1 < s ) 12 4 24 5 2 24 = 1 3 err D 3 ( X 1 ≥ s ) 12 4 8 1 3 5 7 s 2 2 2 2 7 48 + 2 7 24 + 1 4 = 23 2 · 7 48 + 1 24 = 1 2 · 7 48 = 7 err D 3 ( X 1 < s ) 12 48 3 24 5 25 2 17 err D 3 ( X 1 ≥ s ) 12 48 3 24

  59. 81. � � X 1 − 9 The new best hypothesis is h 3 = sign ; the corresponding separator is the line 2 X 1 = 9 2 . X h 2 h 3 2 + + − − x x 6 x 7 P D 3 ( { x 1 , x 2 , x 7 } ) = 2 · 1 24 + 1 24 = 3 24 = 1 4 − 3 h 1 ε 3 = + 8 x 2 3 1 2 − 1 8 = 3 γ 3 = x 1 x 4 x 8 8 2 �� � � √ x 5 x 9 1 − ε 3 1 − 1 : 1 1 α 3 = ln = ln 8 = ln 7 = 0 . 973 ε 3 8 0 X 1 0 1 2 3 4 5

  60. 82. Finally, after filling our results in the given table, we get: t ε t α t D t (1) D t (2) D t (3) D t (4) D t (5) D t (6) D t (7) D t (8) D t (9) err S ( H ) � 1 2 / 9 ln 7 / 2 1 / 9 1 / 9 1 / 9 1 / 9 1 / 9 1 / 9 1 / 9 1 / 9 1 / 9 2 / 9 √ 2 2 / 14 ln 6 1 / 14 1 / 14 1 / 14 1 / 4 1 / 4 1 / 14 1 / 14 1 / 14 1 / 14 2 / 9 √ 3 1 / 8 ln 7 1 / 24 1 / 24 1 / 24 7 / 48 7 / 48 1 / 24 1 / 24 1 / 4 1 / 4 0 Note : The following table helps you understand how err S ( H ) was computed; �� T � def. remember that H ( x i ) = sign t =1 α t h t ( x i ) . t α t x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 1 0 . 626 +1 +1 − 1 +1 +1 − 1 − 1 +1 +1 2 0 . 896 +1 +1 − 1 − 1 − 1 − 1 − 1 − 1 − 1 3 0 . 973 − 1 − 1 − 1 − 1 − 1 − 1 +1 +1 +1 H ( x i ) +1 +1 − 1 − 1 − 1 − 1 − 1 +1 +1

  61. 83. X h 2 h 3 Remark : One can immediately see that 2 the [test] instance (1 , 4) will be classified x x 6 x 7 by the hypothesis H learned by AdaBoost 4 3 h 1 as negative (since − α 1 + α 2 − α 3 = − 0 . 626 + x 2 3 0 . 896 − 0 . 973 < 0 ). After making other sim- + ilar calculi, we can conclude that the de- x 1 x 4 x 8 2 cision zones and the decision boundaries produced by AdaBoost for the given train- + x 5 x 9 1 ing data will be as indicated in the nearby figure. 0 X 1 0 1 2 3 4 5 Remark : The execution of AdaBoost could continue (if we would have taken initially T > 3 ...), although we have obtained err S ( H ) = 0 at iteration t = 3 . By elaborating the details, we would see that for t = 4 we would obtain as optimal hypothesis X 2 < 7 / 2 (which has already been selected at iteration t = 1 ). This hypothesis produces now √ the weighted training error ε 4 = 1 / 6 . Therefore, α 4 = ln 5 , and this will be added to � α 1 = ln 7 / 2 in the new output H . In this way, the confidence in the hypothesis X 2 < 7 / 2 would be strenghened. So, we should keep in mind that AdaBoost can select several times a certain weak hypothesis (but never at consecutive iterations, cf. CMU, 2015 fall, E. Xing, Z. Bar- Joseph, HW4, pr. 2.1).

  62. 84. Seeing AdaBoost as an optimization algorithm , w.r.t. the [inverse] exponential loss function CMU, 2008 fall, Eric Xing, HW3, pr. 4.1.1 CMU, 2008 fall, Eric Xing, midterm, pr. 5.1

  63. 85. At CMU, 2015 fall, Ziv Bar-Joseph, Eric Xing, HW4, pr. 2.1-5, part d , we have shown that in AdaBoost, we try to [indirectly] minimize the training error err S ( H ) by sequen- tially minimizing its upper bound � T t =1 Z t , i.e. at each iteration t ( 1 ≤ t ≤ T ) we choose α t so as to minimize Z t (viwed as a function of α t ). Here you will see that another way to explain AdaBoost is by sequentially minimizing the negative exponential loss : m m T � � � def. not. E = exp( − y i f T ( x i )) = exp( − y i α t h t ( x i )) . (3) i =1 i =1 t =1 That is to say, at the t -th iteration ( 1 ≤ t ≤ T ) we want to choose besides the appropriate classifier h t the corresponding weight α t so that the overall loss E (accumulated up to the t -th iteration) is minimized. Prove that this [new] strategy will lead to the same update rule for α t used in AdaBoost, i.e., α t = 1 2 ln 1 − ε t . ε t Hint : You can use the fact that D t ( i ) ∝ exp( − y i f t − 1 ( x i )) , and it [LC: the proportionality factor] can be viewed as constant when we try to optimize E with respect to α t in the t -th iteration.

  64. 86. Solution At the t -th iteration, we have � t − 1 � � � m m � � � E = exp( − y i f t ( x i )) = exp − y i α t ′ h t ′ ( x i ) − y i α t h t ( x i ) i =1 i =1 t ′ =1 m � = exp( − y i f t − 1 ( x i )) · exp( − y i α t h t ( x i )) i =1 m � not. = E ′ (see CMU, 2015 fall, Z. Bar-Joseph, E. Xing, HW4, pr. 2.1-5, part b ) ∝ D t ( i ) · exp( − y i α t h t ( x i )) i =1 Further on, we can rewrite E ′ as m � � � E ′ = D t ( i ) · exp( − y i α t h t ( x i )) = D t ( i ) exp( − α t ) + D t ( i ) exp( α t ) i =1 i ∈ C i ∈ M (1 − ε t ) · e − α t + ε t · e α t , = (4) where C is the set of examples which are correctly classified by h t , and M is the set of examples which are mis-classified by h t .

  65. 87. The relation ( 4 ) is identical with the expression ( 1 ) from part a of CMU, 2015 fall, Ziv Bar-Joseph, Eric Xing, HW4, pr. 2.1-5 (see the solution). Therefore, E will reach its minim for α t = 1 2 ln 1 − ε t . ε t

  66. 88. AdaBoost algorithm: the notion of [ voting ] margin ; some properties CMU, 2016 spring, W. Cohen, N. Balcan, HW4, pr. 3.3

  67. 89. Despite that model complexity increases with each iteration, AdaBoost does not usually overfit . The reason behind this is that the model becomes more “confident” as we increase the number of iterations. The “confidence” can be expressed mathematically as the [ voting ] margin . Recall that after the algorithm AdaBoost terminates with T iterations the [output] classifier is � T � � H T ( x ) = sign α t h t ( x ) . t =1 Similarly, we can define the intermediate weighted classifier after k iterations as: � k � � H k ( x ) = sign α t h t ( x ) . t =1 As its output is either − 1 or 1 , it does not tell the confidence of its judgement. Here, without changing the decision rule, let � k � � H k ( x ) = sign α t h t ( x ) ¯ , t =1 α t where ¯ α t = so that the weights on each weak classifier are normalized. � k t ′ =1 α t ′

  68. 90. Define the margin after the k -th iteration as [the sum of] the [normalized] weights of h t voting correctly minus [the sum of] the [normalized] weights of h t voting incorrectly. � � Margin k ( x ) = α t − ¯ α t . ¯ t : h t ( x )= y t : h t ( x ) � = y not. = � k a. Let f k ( x ) t =1 ¯ α t h t ( x ) . Show that Margin k ( x i ) = y i f k ( x i ) for all training instances x i , with i = 1 , . . . , m . b. If Margin k ( x i ) > Margin k ( x j ) , which of the samples x i and x j will receive a higher weight in iteration k + 1 ? 1 Hint : Use the relation D k +1 ( i ) = · exp( − y i f k ( x i )) which was proven m · � k t =1 Z t at CMU, 2015 fall, Z. Bar-Joseph, E. Xing, HW4, pr. 2.2.

  69. 91. Solution a. We will prove the equality starting from its right hand side: k k � � � � y i f k ( x i ) = y i α t h t ( x i ) = ¯ α t y i h t ( x i ) = ¯ α t − ¯ α t ¯ t =1 t =1 t : h t ( x i )= y i t : h t ( x i ) � = y i = Margin k ( x i ) . b. According to the relationship already proven at part a , Margin k ( x i ) > Margin k ( x j ) ⇔ y i f k ( x i ) > y j f k ( x j ) ⇔ − y i f k ( x i ) < − y j f k ( x j ) ⇔ exp( − y i f k ( x i )) < exp( − y j f k ( x j )) . Based on the given Hint , it follows that D k +1 ( i ) < D k +1 ( j ) .

  70. 92. Important Remark It can be shown mathematically that boosting tends to increase the margins of training examples — see the relation ( 3 ) at CMU, 2008 fall, Eric Xing, HW3, pr. 4.1.1 —, and that a large margin on training examples reduces the generalization error. Thus we can explain why, although the number of “parameters” of the model created by AdaBoost increases with 2 at every iteration — therefore complexity rises —, it usually doesn’t overfit.

  71. 93. AdaBoost: a sufficient condition for γ -weak learnability, based on the voting margin CMU, 2016 spring, W. Cohen, N. Balcan, HW4, pr. 3.1.4

  72. 94. At CMU, 2015 fall, Z. Bar-Joseph, E. Xing, HW4, pr. 2.5 we encountered the notion of empirical γ -weak learnability. When this condition — γ ≤ γ t for = 1 def. all t , where γ t 2 − ε t , with ε t being the weighted training error produced by the weak hypothesis h t — is met, it ensures that AdaBoost will drive down the training error quickly. However, this condition does not hold all the time. In this problem we will prove a sufficient condition for empirical weak learn- ability [to hold]. This condition refers to the notion of voting margin which was presented in CMU, 2016 spring, W. Cohen, N. Balcan, HW4, pr. 3.3. Namely, we will prove that if there is a constant θ > 0 such that the [voting] margins of all training instances are lower-bounded by θ at each iteration of the AdaBoost algorithm, then the property of empirical γ -weak learnability is “guaranteed”, with γ = θ/ 2 .

  73. 95. [Formalisation] Suppose we are given a training set S = { ( x 1 , y 1 ) , . . . , ( x m , y m ) } , such that for some weak hypotheses h 1 , . . . , h k from the hypothesis space H , and some non- negative coefficients α 1 , . . . , α k with � k j =1 α j = 1 , there exists θ > 0 such that k � y i ( α j h j ( x i )) ≥ θ, ∀ ( x i , y i ) ∈ S. j =1 Note : according to CMU, 2016 spring, W. Cohen, N. Balcan, HW4, pr. 3.3, k k � � not. y i ( α j h j ( x i )) = Margin k ( x i ) = f k ( x i ) , where f k ( x i ) = α j h j ( x i ) . j =1 j =1 Key idea: We will show that if the condition above is satisfied (for a given k ), then for any distribution D over S , there exists a hypothesis h l ∈ { h 1 , . . . , h k } with weighted training error at most 1 2 − θ 2 over the distribution D . It will follow that when the condition above is satisfied for any k , the training set S is empirically γ -weak learnable, with γ = θ 2 .

  74. 96. a. Show that — if the condition stated above is met — there exists a weak hypothesis h l from { h 1 , . . . , h k } such that E i ∼ D [ y i h l ( x i )] ≥ θ . Hint : Taking expectation under the same distribution does not change the inequality conditions. b. Show that the inequality E i ∼ D [ y i h l ( x i )] ≥ θ is equivalent to Pr i ∼ D [ y i � = h l ( x i )] ≤ 1 2 − θ 2 , meaning that the weighted training error of h l is at most 1 2 − θ 2 , and therefore γ t ≥ θ 2 .

  75. 97. Solution a. Since y i ( � k j =1 α j h j ( x i )) ≥ θ ⇔ y i f k ( x i ) ≥ θ for i = 1 , . . . , m , it follows (according to the Hint ) that k � not. E i ∼ D [ y i f k ( x i )] ≥ θ where f k ( x i ) = α j h j ( x i ) . (5) j =1 def. ⇔ � m On the other side, E i ∼ D [ y i h l ( x i )] ≥ θ i =1 y i h l ( x i ) · D ( i ) ≥ θ . Suppose, on contrary, that E i ∼ D [ y i h l ( x i )] < θ , that is � m i =1 y i h l ( x i ) · D ( i ) < θ for l = 1 , . . . , k . Then � m i =1 y i h l ( x i ) · D ( i ) · α l < θ · α l for l = 1 , . . . , k . By summing up these inequations for l = 1 , . . . , k we get � k � k m k m k � � � � � � y i h l ( x i ) · D ( i ) · α l < θ · α l ⇔ y i D ( i ) h l ( x i ) α l < θ α l ⇔ l =1 i =1 l =1 i =1 l =1 l =1 m � y i f k ( x i ) · D ( i ) < θ, (6) i =1 because � k = � k not. j =1 α j = 1 ¸ si f k ( x i ) l =1 α l h l ( x i ) . The inequation ( 6 ) can be written as E i ∼ D [ y i f k ( x i )] < θ . Obviously, it contradicts the relationship ( 5 ). Therefore, the previous supposition is false. In conclusion, there exist l ∈ { 1 , . . . , k } such that E i ∼ D [ y i h l ( x i )] ≥ θ .

  76. 98. Solution (cont’d) b. We already said that E i ∼ D [ y i h l ( x i )] ≥ θ ⇔ � m i =1 y i h l ( x i ) · D ( i ) ≥ θ . Since y i ∈ {− 1 , +1 } and h l ( x i ) ∈ {− 1 , +1 } for i = 1 , . . . , m and l = 1 , . . . , k , we thave m � � � y i h l ( x i ) · D ( i ) ≥ θ ⇔ D ( x i ) − D ( x i ) ≥ θ ⇔ (1 − ε l ) − ε l ≥ θ ⇔ i =1 i : y i = h l ( x i ) i : y i � = h l ( x i ) 1 − 2 ε l ≥ θ ⇔ 2 ε l ≤ 1 − θ ⇔ ε l ≤ 1 2 − θ ⇔ Pr i ∼ D [ y i � = h l ( x i )] ≤ 1 2 − θ def. 2 . 2

  77. 99. AdaBoost: Any set of consistently labelled instances from R is empirically γ -weak learnable by using decision stumps Stanford, 2016 fall, Andrew Ng, John Duchi, HW2, pr. 6.abc

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend