diff --git a/doc/pub/week44/html/._week44-bs000.html b/doc/pub/week44/html/._week44-bs000.html index 92c1fb661..3e5f1d17a 100644 --- a/doc/pub/week44/html/._week44-bs000.html +++ b/doc/pub/week44/html/._week44-bs000.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -365,7 +348,7 @@ MathJax.Hub.Config({
  • 9
  • 10
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs001.html b/doc/pub/week44/html/._week44-bs001.html index 716de7717..3730c5b7b 100644 --- a/doc/pub/week44/html/._week44-bs001.html +++ b/doc/pub/week44/html/._week44-bs001.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -364,7 +347,7 @@ MathJax.Hub.Config({
  • 10
  • 11
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs002.html b/doc/pub/week44/html/._week44-bs002.html index 8fe804379..e7f878b6c 100644 --- a/doc/pub/week44/html/._week44-bs002.html +++ b/doc/pub/week44/html/._week44-bs002.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -350,7 +333,7 @@ accelerate scientific discovery.
  • 11
  • 12
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs003.html b/doc/pub/week44/html/._week44-bs003.html index f83f3c213..f319426e6 100644 --- a/doc/pub/week44/html/._week44-bs003.html +++ b/doc/pub/week44/html/._week44-bs003.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -472,7 +455,7 @@ plt.show()
  • 12
  • 13
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs004.html b/doc/pub/week44/html/._week44-bs004.html index a5d9e9772..107f8f6cf 100644 --- a/doc/pub/week44/html/._week44-bs004.html +++ b/doc/pub/week44/html/._week44-bs004.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -368,7 +351,7 @@ where we then finally end up in so called leaf nodes.
  • 13
  • 14
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs005.html b/doc/pub/week44/html/._week44-bs005.html index 6fe538681..d4ad36e0c 100644 --- a/doc/pub/week44/html/._week44-bs005.html +++ b/doc/pub/week44/html/._week44-bs005.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -356,7 +339,7 @@ given some assumptions, make predictions about the target feature value
  • 14
  • 15
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs006.html b/doc/pub/week44/html/._week44-bs006.html index 112773922..cf8779366 100644 --- a/doc/pub/week44/html/._week44-bs006.html +++ b/doc/pub/week44/html/._week44-bs006.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -349,7 +332,7 @@ MathJax.Hub.Config({
  • 15
  • 16
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs007.html b/doc/pub/week44/html/._week44-bs007.html index 703ce2714..76b727c85 100644 --- a/doc/pub/week44/html/._week44-bs007.html +++ b/doc/pub/week44/html/._week44-bs007.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -349,7 +332,7 @@ MathJax.Hub.Config({
  • 16
  • 17
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs008.html b/doc/pub/week44/html/._week44-bs008.html index ca8d39f5e..e6b3d6750 100644 --- a/doc/pub/week44/html/._week44-bs008.html +++ b/doc/pub/week44/html/._week44-bs008.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -355,7 +338,7 @@ MathJax.Hub.Config({
  • 17
  • 18
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs009.html b/doc/pub/week44/html/._week44-bs009.html index f609dff37..77fbd6ce9 100644 --- a/doc/pub/week44/html/._week44-bs009.html +++ b/doc/pub/week44/html/._week44-bs009.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -360,7 +343,7 @@ node.
  • 18
  • 19
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs010.html b/doc/pub/week44/html/._week44-bs010.html index f9f727bf2..bbfacdf4a 100644 --- a/doc/pub/week44/html/._week44-bs010.html +++ b/doc/pub/week44/html/._week44-bs010.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -361,7 +344,7 @@ predicting the target features of query instances is as follows:
  • 19
  • 20
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs011.html b/doc/pub/week44/html/._week44-bs011.html index 5c2838305..7cfb3db64 100644 --- a/doc/pub/week44/html/._week44-bs011.html +++ b/doc/pub/week44/html/._week44-bs011.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -459,7 +442,7 @@ plt.show()
  • 20
  • 21
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs012.html b/doc/pub/week44/html/._week44-bs012.html index eb3a5c1ca..dadc9f73d 100644 --- a/doc/pub/week44/html/._week44-bs012.html +++ b/doc/pub/week44/html/._week44-bs012.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -370,7 +353,7 @@ within box \( j \).
  • 21
  • 22
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs013.html b/doc/pub/week44/html/._week44-bs013.html index aabdd563e..be779f14d 100644 --- a/doc/pub/week44/html/._week44-bs013.html +++ b/doc/pub/week44/html/._week44-bs013.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -363,7 +346,7 @@ better tree in some future step.
  • 22
  • 23
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs014.html b/doc/pub/week44/html/._week44-bs014.html index 8939866e0..09cec7341 100644 --- a/doc/pub/week44/html/._week44-bs014.html +++ b/doc/pub/week44/html/._week44-bs014.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -395,7 +378,7 @@ region contains more than five observations.
  • 23
  • 24
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs015.html b/doc/pub/week44/html/._week44-bs015.html index bb9627d63..a8ebc13cb 100644 --- a/doc/pub/week44/html/._week44-bs015.html +++ b/doc/pub/week44/html/._week44-bs015.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -365,7 +348,7 @@ parameter \( \alpha \).
  • 24
  • 25
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs016.html b/doc/pub/week44/html/._week44-bs016.html index f225cfcb8..7559c19df 100644 --- a/doc/pub/week44/html/._week44-bs016.html +++ b/doc/pub/week44/html/._week44-bs016.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -377,7 +360,7 @@ subtree corresponding to \( \alpha \).
  • 25
  • 26
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs017.html b/doc/pub/week44/html/._week44-bs017.html index e3ba0e7a5..62f7f9bb9 100644 --- a/doc/pub/week44/html/._week44-bs017.html +++ b/doc/pub/week44/html/._week44-bs017.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -368,7 +351,7 @@ MathJax.Hub.Config({
  • 26
  • 27
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs018.html b/doc/pub/week44/html/._week44-bs018.html index 6902cb2e7..c72401ef4 100644 --- a/doc/pub/week44/html/._week44-bs018.html +++ b/doc/pub/week44/html/._week44-bs018.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -363,7 +346,7 @@ fall into that region.
  • 27
  • 28
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs019.html b/doc/pub/week44/html/._week44-bs019.html index 36411ae98..101df1a26 100644 --- a/doc/pub/week44/html/._week44-bs019.html +++ b/doc/pub/week44/html/._week44-bs019.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -368,7 +351,7 @@ than is the classification error rate.
  • 28
  • 29
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs020.html b/doc/pub/week44/html/._week44-bs020.html index dbb37a450..39dbdd403 100644 --- a/doc/pub/week44/html/._week44-bs020.html +++ b/doc/pub/week44/html/._week44-bs020.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -390,7 +373,7 @@ $$
  • 29
  • 30
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs021.html b/doc/pub/week44/html/._week44-bs021.html index fed5ab44c..85862f1b1 100644 --- a/doc/pub/week44/html/._week44-bs021.html +++ b/doc/pub/week44/html/._week44-bs021.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -404,7 +387,7 @@ os.system(cmd)
  • 30
  • 31
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs022.html b/doc/pub/week44/html/._week44-bs022.html index 0dc1fddaa..fa4c302b5 100644 --- a/doc/pub/week44/html/._week44-bs022.html +++ b/doc/pub/week44/html/._week44-bs022.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -395,7 +378,7 @@ os.system(cmd)
  • 31
  • 32
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs023.html b/doc/pub/week44/html/._week44-bs023.html index 017563060..210a473cc 100644 --- a/doc/pub/week44/html/._week44-bs023.html +++ b/doc/pub/week44/html/._week44-bs023.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -381,7 +364,7 @@ tree.plot_tree(tree_clf)
  • 32
  • 33
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs024.html b/doc/pub/week44/html/._week44-bs024.html index 4cdc7278f..29ec88d8e 100644 --- a/doc/pub/week44/html/._week44-bs024.html +++ b/doc/pub/week44/html/._week44-bs024.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -384,7 +367,7 @@ r = export_text(decision_tree, feature_names
  • 33
  • 34
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs025.html b/doc/pub/week44/html/._week44-bs025.html index 63a9ed9c7..ef5028144 100644 --- a/doc/pub/week44/html/._week44-bs025.html +++ b/doc/pub/week44/html/._week44-bs025.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -360,7 +343,7 @@ in two branches.
  • 34
  • 35
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs026.html b/doc/pub/week44/html/._week44-bs026.html index a31697b6c..bd47288bc 100644 --- a/doc/pub/week44/html/._week44-bs026.html +++ b/doc/pub/week44/html/._week44-bs026.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -372,7 +355,7 @@ hyperparameters control additional stopping conditions such as the \( min\_sampl
  • 35
  • 36
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs027.html b/doc/pub/week44/html/._week44-bs027.html index 8f71607cf..0f0c80e95 100644 --- a/doc/pub/week44/html/._week44-bs027.html +++ b/doc/pub/week44/html/._week44-bs027.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -372,7 +355,7 @@ just like for classification tasks, is prone to overfitting.
  • 36
  • 37
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs028.html b/doc/pub/week44/html/._week44-bs028.html index b02c9a173..eb477c5ad 100644 --- a/doc/pub/week44/html/._week44-bs028.html +++ b/doc/pub/week44/html/._week44-bs028.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -355,7 +338,7 @@ achieved by a series of binary split and this is normally preferred.
  • 37
  • 38
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs029.html b/doc/pub/week44/html/._week44-bs029.html index 11a6339c2..23ad1a72b 100644 --- a/doc/pub/week44/html/._week44-bs029.html +++ b/doc/pub/week44/html/._week44-bs029.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -364,7 +347,7 @@ recently has gotten grades below average or above.
  • 38
  • 39
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs030.html b/doc/pub/week44/html/._week44-bs030.html index 3c49e8595..1961ab5ab 100644 --- a/doc/pub/week44/html/._week44-bs030.html +++ b/doc/pub/week44/html/._week44-bs030.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -371,7 +354,7 @@ MathJax.Hub.Config({
  • 39
  • 40
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs031.html b/doc/pub/week44/html/._week44-bs031.html index fd11620f2..ed37b9b1d 100644 --- a/doc/pub/week44/html/._week44-bs031.html +++ b/doc/pub/week44/html/._week44-bs031.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -361,7 +344,7 @@ these binary classes, they can easily be split into ones and zeros.
  • 40
  • 41
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs032.html b/doc/pub/week44/html/._week44-bs032.html index eb57c5458..ea026f262 100644 --- a/doc/pub/week44/html/._week44-bs032.html +++ b/doc/pub/week44/html/._week44-bs032.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -357,7 +340,7 @@ MathJax.Hub.Config({
  • 41
  • 42
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs033.html b/doc/pub/week44/html/._week44-bs033.html index 5805bb00c..4200e2683 100644 --- a/doc/pub/week44/html/._week44-bs033.html +++ b/doc/pub/week44/html/._week44-bs033.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -359,7 +342,7 @@ MathJax.Hub.Config({
  • 42
  • 43
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs034.html b/doc/pub/week44/html/._week44-bs034.html index 5dfb7617e..bd8cd704b 100644 --- a/doc/pub/week44/html/._week44-bs034.html +++ b/doc/pub/week44/html/._week44-bs034.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -439,7 +422,7 @@ os.system(cmd)
  • 43
  • 44
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs035.html b/doc/pub/week44/html/._week44-bs035.html index d9b335dc3..76fb08fec 100644 --- a/doc/pub/week44/html/._week44-bs035.html +++ b/doc/pub/week44/html/._week44-bs035.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -388,7 +371,7 @@ humidity and weak and strong for wind.
  • 44
  • 45
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs036.html b/doc/pub/week44/html/._week44-bs036.html index 66c5bc1d0..740385067 100644 --- a/doc/pub/week44/html/._week44-bs036.html +++ b/doc/pub/week44/html/._week44-bs036.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -439,7 +422,7 @@ os.system(cmd)
  • 45
  • 46
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs037.html b/doc/pub/week44/html/._week44-bs037.html index bbc473dd8..ccb44cc35 100644 --- a/doc/pub/week44/html/._week44-bs037.html +++ b/doc/pub/week44/html/._week44-bs037.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -440,7 +423,7 @@ split = get_split(dataset)
  • 46
  • 47
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs038.html b/doc/pub/week44/html/._week44-bs038.html index 9e2985237..f89d772cb 100644 --- a/doc/pub/week44/html/._week44-bs038.html +++ b/doc/pub/week44/html/._week44-bs038.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -322,7 +305,7 @@ MathJax.Hub.Config({

     

     

     

    -

    Another example, the moons again

    +

    Another example, the moons

    @@ -435,7 +418,7 @@ plt.show()
  • 47
  • 48
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs039.html b/doc/pub/week44/html/._week44-bs039.html index 05d91922c..864ed77e2 100644 --- a/doc/pub/week44/html/._week44-bs039.html +++ b/doc/pub/week44/html/._week44-bs039.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -391,7 +374,7 @@ plt.show()
  • 48
  • 49
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs040.html b/doc/pub/week44/html/._week44-bs040.html index 438069235..377ba341d 100644 --- a/doc/pub/week44/html/._week44-bs040.html +++ b/doc/pub/week44/html/._week44-bs040.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -400,7 +383,7 @@ tree_reg.fit(X, y)
  • 49
  • 50
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs041.html b/doc/pub/week44/html/._week44-bs041.html index a2a9621db..edb2e465d 100644 --- a/doc/pub/week44/html/._week44-bs041.html +++ b/doc/pub/week44/html/._week44-bs041.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -456,7 +439,7 @@ plt.show()
  • 50
  • 51
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs042.html b/doc/pub/week44/html/._week44-bs042.html index 09540c31e..5fea18cbb 100644 --- a/doc/pub/week44/html/._week44-bs042.html +++ b/doc/pub/week44/html/._week44-bs042.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -358,7 +341,7 @@ MathJax.Hub.Config({
  • 51
  • 52
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs043.html b/doc/pub/week44/html/._week44-bs043.html index a6049a48e..6411991f9 100644 --- a/doc/pub/week44/html/._week44-bs043.html +++ b/doc/pub/week44/html/._week44-bs043.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -363,7 +346,7 @@ trees can be substantially improved.
  • 52
  • 53
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs044.html b/doc/pub/week44/html/._week44-bs044.html index 9468b22c1..a2931b9cd 100644 --- a/doc/pub/week44/html/._week44-bs044.html +++ b/doc/pub/week44/html/._week44-bs044.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -370,7 +353,7 @@ try to explain here. These are
  • 53
  • 54
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs045.html b/doc/pub/week44/html/._week44-bs045.html index a4ca9f438..45d91dfb0 100644 --- a/doc/pub/week44/html/._week44-bs045.html +++ b/doc/pub/week44/html/._week44-bs045.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -355,7 +338,7 @@ MathJax.Hub.Config({
  • 54
  • 55
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs046.html b/doc/pub/week44/html/._week44-bs046.html index bb1b2c84d..48c3c978a 100644 --- a/doc/pub/week44/html/._week44-bs046.html +++ b/doc/pub/week44/html/._week44-bs046.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -322,22 +305,25 @@ MathJax.Hub.Config({

     

     

     

    -

    Bagging

    +

    Why Voting?

    -

    The plain decision trees suffer from high -variance. This means that if we split the training data into two parts -at random, and fit a decision tree to both halves, the results that we -get could be quite different. In contrast, a procedure with low -variance will yield similar results if applied repeatedly to distinct -data sets; linear regression tends to have low variance, if the ratio -of \( n \) to \( p \) is moderately large. +

    The idea behind boosting, and voting as well can be phrased as follows: +Can a group of people somehow arrive at highly +reasoned decisions, despite the weak judgement of the individual +members?

    -

    Bootstrap aggregation, or just bagging, is a -general-purpose procedure for reducing the variance of a statistical -learning method. +

    The aim is to create a good classifier by combining several weak classifiers. +A weak classifier is a classifier which is able to produce results that are only slightly better than guessing at random.

    +

    The basic approach is to apply repeatedly (in boosting this is done in an iterative way) a weak classifier to modifications of the data. +In voting we simply apply the law of large numbers while in boosting we give more weight to misclassified data in +each iteration. +

    + +

    Decision trees play an important role as our weak classifier. They serve as the basic method.

    +

    diff --git a/doc/pub/week44/html/._week44-bs047.html b/doc/pub/week44/html/._week44-bs047.html index 1037eafcb..0bcd1ac63 100644 --- a/doc/pub/week44/html/._week44-bs047.html +++ b/doc/pub/week44/html/._week44-bs047.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -322,30 +305,31 @@ MathJax.Hub.Config({

     

     

     

    -

    More bagging

    +

    Tossing coins

    -

    Bagging typically results in improved accuracy -over prediction using a single tree. Unfortunately, however, it can be -difficult to interpret the resulting model. Recall that one of the -advantages of decision trees is the attractive and easily interpreted -diagram that results. +

    The simplest case is a so-called voting ensemble. To illustrate this, +think of yourself tossing coins with a biased outcome of 51 per cent +for heads and 49% for tails. With only few tosses, +you may not clearly see this distribution for heads and tails. However, after some +thousands of tosses, there will be a clear majority of heads. With 2000 tosses +you should see approximately 1020 heads and 980 tails.

    -

    However, when we bag a large number of trees, it is no longer -possible to represent the resulting statistical learning procedure -using a single tree, and it is no longer clear which variables are -most important to the procedure. Thus, bagging improves prediction -accuracy at the expense of interpretability. Although the collection -of bagged trees is much more difficult to interpret than a single -tree, one can obtain an overall summary of the importance of each -predictor using the MSE (for bagging regression trees) or the Gini -index (for bagging classification trees). In the case of bagging -regression trees, we can record the total amount that the MSE is -decreased due to splits over a given predictor, averaged over all \( B \) possible -trees. A large value indicates an important predictor. Similarly, in -the context of bagging classification trees, we can add up the total -amount that the Gini index is decreased by splits over a given -predictor, averaged over all \( B \) trees. +

    We can then state that the outcome is a clear majority of heads. If +you do this ten thousand times, it is easy to see that there is a 97% +likelihood of a majority of heads. +

    + +

    Another example would be to collect all polls before an +election. Different polls may show different likelihoods for a +candidate winning with say a majority of the popular vote. The majority vote +would then consist in many polls indicating that this candidate will +actually win. +

    + +

    The example here shows how we can implement the coin tossing case, +clealry demostrating that after some tosses we see the law of large +numbers kicking in.

    @@ -373,7 +357,7 @@ predictor, averaged over all \( B \) trees.

  • 56
  • 57
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs048.html b/doc/pub/week44/html/._week44-bs048.html index bdd8c2ad8..ff0369469 100644 --- a/doc/pub/week44/html/._week44-bs048.html +++ b/doc/pub/week44/html/._week44-bs048.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -322,7 +305,8 @@ MathJax.Hub.Config({

     

     

     

    -

    Simple Voting Example, head or tail

    +

    Standard imports first

    +
    @@ -330,19 +314,43 @@ MathJax.Hub.Config({
    -
    heads_proba = 0.51
    -coin_tosses = (np.random.rand(10000, 10) < heads_proba).astype(np.int32)
    -cumulative_heads_ratio = np.cumsum(coin_tosses, axis=0) / np.arange(1, 10001).reshape(-1, 1)
    -plt.figure(figsize=(8,3.5))
    -plt.plot(cumulative_heads_ratio)
    -plt.plot([0, 10000], [0.51, 0.51], "k--", linewidth=2, label="51%")
    -plt.plot([0, 10000], [0.5, 0.5], "k-", label="50%")
    -plt.xlabel("Number of coin tosses")
    -plt.ylabel("Heads ratio")
    -plt.legend(loc="lower right")
    -plt.axis([0, 10000, 0.42, 0.58])
    -save_fig("votingsimple")
    -plt.show()
    +  
    # Common imports
    +from IPython.display import Image 
    +from pydot import graph_from_dot_data
    +import pandas as pd
    +import numpy as np
    +import matplotlib.pyplot as plt
    +from sklearn.tree import DecisionTreeClassifier
    +from sklearn.model_selection import train_test_split
    +from sklearn.tree import export_graphviz
    +from sklearn.preprocessing import StandardScaler, OneHotEncoder
    +from sklearn.compose import ColumnTransformer
    +from IPython.display import Image 
    +from pydot import graph_from_dot_data
    +import os
    +
    +# Where to save the figures and data files
    +PROJECT_ROOT_DIR = "Results"
    +FIGURE_ID = "Results/FigureFiles"
    +DATA_ID = "DataFiles/"
    +
    +if not os.path.exists(PROJECT_ROOT_DIR):
    +    os.mkdir(PROJECT_ROOT_DIR)
    +
    +if not os.path.exists(FIGURE_ID):
    +    os.makedirs(FIGURE_ID)
    +
    +if not os.path.exists(DATA_ID):
    +    os.makedirs(DATA_ID)
    +
    +def image_path(fig_id):
    +    return os.path.join(FIGURE_ID, fig_id)
    +
    +def data_path(dat_id):
    +    return os.path.join(DATA_ID, dat_id)
    +
    +def save_fig(fig_id):
    +    plt.savefig(image_path(fig_id) + ".png", format='png')
     
    @@ -384,7 +392,7 @@ plt.show()
  • 57
  • 58
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs049.html b/doc/pub/week44/html/._week44-bs049.html index 326548bba..0cd4c5906 100644 --- a/doc/pub/week44/html/._week44-bs049.html +++ b/doc/pub/week44/html/._week44-bs049.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -322,7 +305,7 @@ MathJax.Hub.Config({

     

     

     

    -

    Using the Voting Classifier

    +

    Simple Voting Example, head or tail

    @@ -330,49 +313,28 @@ MathJax.Hub.Config({
    -
    from sklearn.model_selection import train_test_split
    -from sklearn.datasets import make_moons
    +  
    # Common imports
    +import numpy as np
    +import matplotlib
    +import matplotlib.pyplot as plt
    +from matplotlib.colors import ListedColormap
    +plt.rcParams['axes.labelsize'] = 14
    +plt.rcParams['xtick.labelsize'] = 12
    +plt.rcParams['ytick.labelsize'] = 12
     
    -X, y = make_moons(n_samples=500, noise=0.30, random_state=42)
    -X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
    -
    -from sklearn.ensemble import RandomForestClassifier
    -from sklearn.ensemble import VotingClassifier
    -from sklearn.linear_model import LogisticRegression
    -from sklearn.svm import SVC
    -
    -log_clf = LogisticRegression(solver="liblinear", random_state=42)
    -rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)
    -svm_clf = SVC(gamma="auto", random_state=42)
    -
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='hard')
    -
    -voting_clf.fit(X_train, y_train)
    -
    -from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    -
    -log_clf = LogisticRegression(solver="liblinear", random_state=42)
    -rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)
    -svm_clf = SVC(gamma="auto", probability=True, random_state=42)
    -
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='soft')
    -voting_clf.fit(X_train, y_train)
    -
    -from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    +heads_proba = 0.51
    +coin_tosses = (np.random.rand(10000, 10) < heads_proba).astype(np.int32)
    +cumulative_heads_ratio = np.cumsum(coin_tosses, axis=0) / np.arange(1, 10001).reshape(-1, 1)
    +plt.figure(figsize=(8,3.5))
    +plt.plot(cumulative_heads_ratio)
    +plt.plot([0, 10000], [0.51, 0.51], "k--", linewidth=2, label="51%")
    +plt.plot([0, 10000], [0.5, 0.5], "k-", label="50%")
    +plt.xlabel("Number of coin tosses")
    +plt.ylabel("Heads ratio")
    +plt.legend(loc="lower right")
    +plt.axis([0, 10000, 0.42, 0.58])
    +save_fig("votingsimple")
    +plt.show()
     
    @@ -413,8 +375,6 @@ voting_clf.fit(X_train, y_train)
  • 57
  • 58
  • 59
  • -
  • ...
  • -
  • 63
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs050.html b/doc/pub/week44/html/._week44-bs050.html index ab4a6a7ef..8d79ac3fc 100644 --- a/doc/pub/week44/html/._week44-bs050.html +++ b/doc/pub/week44/html/._week44-bs050.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -322,8 +305,9 @@ MathJax.Hub.Config({

     

     

     

    -

    Please, not the moons again! Voting and Bagging

    +

    Using the Voting Classifier

    +

    We can use the voting classifier on other data sets, here the exciting binary case of two distinct objects using the make moons functionality of Scikit-Learn.

    @@ -336,91 +320,38 @@ MathJax.Hub.Config({ X, y = make_moons(n_samples=500, noise=0.30, random_state=42) X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42) + from sklearn.ensemble import RandomForestClassifier from sklearn.ensemble import VotingClassifier from sklearn.linear_model import LogisticRegression from sklearn.svm import SVC -log_clf = LogisticRegression(random_state=42) -rnd_clf = RandomForestClassifier(random_state=42) -svm_clf = SVC(random_state=42) +log_clf = LogisticRegression(solver="liblinear", random_state=42) +rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42) +svm_clf = SVC(gamma="auto", random_state=42) voting_clf = VotingClassifier( estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)], voting='hard') + voting_clf.fit(X_train, y_train) - -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from sklearn.metrics import accuracy_score
    +
    +from sklearn.metrics import accuracy_score
     
     for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
         clf.fit(X_train, y_train)
         y_pred = clf.predict(X_test)
         print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    log_clf = LogisticRegression(random_state=42)
    -rnd_clf = RandomForestClassifier(random_state=42)
    -svm_clf = SVC(probability=True, random_state=42)
     
    +log_clf = LogisticRegression(solver="liblinear", random_state=42)
    +rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)
    +svm_clf = SVC(gamma="auto", probability=True, random_state=42)
     voting_clf = VotingClassifier(
         estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
         voting='soft')
     voting_clf.fit(X_train, y_train)
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from sklearn.metrics import accuracy_score
    +
    +from sklearn.metrics import accuracy_score
     
     for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
         clf.fit(X_train, y_train)
    @@ -465,9 +396,6 @@ voting_clf.fit(X_train, y_train)
       
  • 57
  • 58
  • 59
  • -
  • 60
  • -
  • ...
  • -
  • 63
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs051.html b/doc/pub/week44/html/._week44-bs051.html index 605d3a960..ed0e6fa22 100644 --- a/doc/pub/week44/html/._week44-bs051.html +++ b/doc/pub/week44/html/._week44-bs051.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -322,7 +305,7 @@ MathJax.Hub.Config({

     

     

     

    -

    Bagging Examples

    +

    Voting and Bagging

    @@ -331,14 +314,24 @@ MathJax.Hub.Config({
    -
    from sklearn.ensemble import BaggingClassifier
    -from sklearn.tree import DecisionTreeClassifier
    +  
    from sklearn.model_selection import train_test_split
    +from sklearn.datasets import make_moons
     
    -bag_clf = BaggingClassifier(
    -    DecisionTreeClassifier(random_state=42), n_estimators=500,
    -    max_samples=100, bootstrap=True, n_jobs=-1, random_state=42)
    -bag_clf.fit(X_train, y_train)
    -y_pred = bag_clf.predict(X_test)
    +X, y = make_moons(n_samples=500, noise=0.30, random_state=42)
    +X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
    +from sklearn.ensemble import RandomForestClassifier
    +from sklearn.ensemble import VotingClassifier
    +from sklearn.linear_model import LogisticRegression
    +from sklearn.svm import SVC
    +
    +log_clf = LogisticRegression(random_state=42)
    +rnd_clf = RandomForestClassifier(random_state=42)
    +svm_clf = SVC(random_state=42)
    +
    +voting_clf = VotingClassifier(
    +    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    +    voting='hard')
    +voting_clf.fit(X_train, y_train)
     
    @@ -359,76 +352,63 @@ y_pred = bag_clf
    from sklearn.metrics import accuracy_score
    -print(accuracy_score(y_test, y_pred))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    tree_clf = DecisionTreeClassifier(random_state=42)
    -tree_clf.fit(X_train, y_train)
    -y_pred_tree = tree_clf.predict(X_test)
    -print(accuracy_score(y_test, y_pred_tree))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from matplotlib.colors import ListedColormap
     
    -def plot_decision_boundary(clf, X, y, axes=[-1.5, 2.5, -1, 1.5], alpha=0.5, contour=True):
    -    x1s = np.linspace(axes[0], axes[1], 100)
    -    x2s = np.linspace(axes[2], axes[3], 100)
    -    x1, x2 = np.meshgrid(x1s, x2s)
    -    X_new = np.c_[x1.ravel(), x2.ravel()]
    -    y_pred = clf.predict(X_new).reshape(x1.shape)
    -    custom_cmap = ListedColormap(['#fafab0','#9898ff','#a0faa0'])
    -    plt.contourf(x1, x2, y_pred, alpha=0.3, cmap=custom_cmap)
    -    if contour:
    -        custom_cmap2 = ListedColormap(['#7d7d58','#4c4c7f','#507d50'])
    -        plt.contour(x1, x2, y_pred, cmap=custom_cmap2, alpha=0.8)
    -    plt.plot(X[:, 0][y==0], X[:, 1][y==0], "yo", alpha=alpha)
    -    plt.plot(X[:, 0][y==1], X[:, 1][y==1], "bs", alpha=alpha)
    -    plt.axis(axes)
    -    plt.xlabel(r"$x_1$", fontsize=18)
    -    plt.ylabel(r"$x_2$", fontsize=18, rotation=0)
    -plt.figure(figsize=(11,4))
    -plt.subplot(121)
    -plot_decision_boundary(tree_clf, X, y)
    -plt.title("Decision Tree", fontsize=14)
    -plt.subplot(122)
    -plot_decision_boundary(bag_clf, X, y)
    -plt.title("Decision Trees with Bagging", fontsize=14)
    -save_fig("baggingtree")
    -plt.show()
    +for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    +    clf.fit(X_train, y_train)
    +    y_pred = clf.predict(X_test)
    +    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    log_clf = LogisticRegression(random_state=42)
    +rnd_clf = RandomForestClassifier(random_state=42)
    +svm_clf = SVC(probability=True, random_state=42)
    +
    +voting_clf = VotingClassifier(
    +    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    +    voting='soft')
    +voting_clf.fit(X_train, y_train)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    from sklearn.metrics import accuracy_score
    +
    +for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    +    clf.fit(X_train, y_train)
    +    y_pred = clf.predict(X_test)
    +    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
     
    @@ -467,10 +447,6 @@ plt.show()
  • 57
  • 58
  • 59
  • -
  • 60
  • -
  • 61
  • -
  • ...
  • -
  • 63
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs052.html b/doc/pub/week44/html/._week44-bs052.html index 2f1904656..b2e4cafcf 100644 --- a/doc/pub/week44/html/._week44-bs052.html +++ b/doc/pub/week44/html/._week44-bs052.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -322,90 +305,21 @@ MathJax.Hub.Config({

     

     

     

    -

    Making your own Bootstrap: Changing the Level of the Decision Tree

    +

    Bagging

    -

    Let us bring up our good old boostrap example from the linear regression lectures. We change the linerar regression algorithm with -a decision tree wth different depths and perform a bootstrap aggregate (in this case we perform as many bootstraps as data points \( n \)). +

    The plain decision trees suffer from high +variance. This means that if we split the training data into two parts +at random, and fit a decision tree to both halves, the results that we +get could be quite different. In contrast, a procedure with low +variance will yield similar results if applied repeatedly to distinct +data sets; linear regression tends to have low variance, if the ratio +of \( n \) to \( p \) is moderately large.

    - -
    -
    -
    -
    -
    -
    import matplotlib.pyplot as plt
    -import numpy as np
    -from sklearn.model_selection import train_test_split
    -from sklearn.pipeline import make_pipeline
    -from sklearn.utils import resample
    -from sklearn.tree import DecisionTreeRegressor
    -
    -n = 100
    -n_boostraps = 100
    -maxdepth = 8
    -
    -# Make data set.
    -x = np.linspace(-3, 3, n).reshape(-1, 1)
    -y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)
    -error = np.zeros(maxdepth)
    -bias = np.zeros(maxdepth)
    -variance = np.zeros(maxdepth)
    -polydegree = np.zeros(maxdepth)
    -X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
    -
    -from sklearn.preprocessing import StandardScaler
    -scaler = StandardScaler()
    -scaler.fit(X_train)
    -X_train_scaled = scaler.transform(X_train)
    -X_test_scaled = scaler.transform(X_test)
    -
    -# we produce a simple tree first as benchmark
    -simpletree = DecisionTreeRegressor(max_depth=3) 
    -simpletree.fit(X_train_scaled, y_train)
    -simpleprediction = simpletree.predict(X_test_scaled)
    -for degree in range(1,maxdepth):
    -    model = DecisionTreeRegressor(max_depth=degree) 
    -    y_pred = np.empty((y_test.shape[0], n_boostraps))
    -    for i in range(n_boostraps):
    -        x_, y_ = resample(X_train_scaled, y_train)
    -        model.fit(x_, y_)
    -        y_pred[:, i] = model.predict(X_test_scaled)#.ravel()
    -
    -    polydegree[degree] = degree
    -    error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )
    -    bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )
    -    variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) )
    -    print('Polynomial degree:', degree)
    -    print('Error:', error[degree])
    -    print('Bias^2:', bias[degree])
    -    print('Var:', variance[degree])
    -    print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree]))
    - 
    -mse_simpletree= np.mean( np.mean((y_test - simpleprediction)**2)
    -print(mse_simpletree)
    -plt.xlim(1,maxdepth)
    -plt.plot(polydegree, error, label='MSE')
    -plt.plot(polydegree, bias, label='bias')
    -plt.plot(polydegree, variance, label='Variance')
    -plt.legend()
    -save_fig("baggingboot")
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - +

    Bootstrap aggregation, or just bagging, is a +general-purpose procedure for reducing the variance of a statistical +learning method. +

    @@ -428,11 +342,6 @@ plt.show()

  • 57
  • 58
  • 59
  • -
  • 60
  • -
  • 61
  • -
  • 62
  • -
  • ...
  • -
  • 63
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs053.html b/doc/pub/week44/html/._week44-bs053.html index 0be974ee1..c52d4c778 100644 --- a/doc/pub/week44/html/._week44-bs053.html +++ b/doc/pub/week44/html/._week44-bs053.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -322,25 +305,32 @@ MathJax.Hub.Config({

     

     

     

    -

    Why Voting?

    +

    More bagging

    -

    The idea behind boosting, and voting as well can be phrased as follows: -Can a group of people somehow arrive at highly -reasoned decisions, despite the weak judgement of the individual -members? +

    Bagging typically results in improved accuracy +over prediction using a single tree. Unfortunately, however, it can be +difficult to interpret the resulting model. Recall that one of the +advantages of decision trees is the attractive and easily interpreted +diagram that results.

    -

    The aim is to create a good classifier by combining several weak classifiers. -A weak classifier is a classifier which is able to produce results that are only slightly better than guessing at random. +

    However, when we bag a large number of trees, it is no longer +possible to represent the resulting statistical learning procedure +using a single tree, and it is no longer clear which variables are +most important to the procedure. Thus, bagging improves prediction +accuracy at the expense of interpretability. Although the collection +of bagged trees is much more difficult to interpret than a single +tree, one can obtain an overall summary of the importance of each +predictor using the MSE (for bagging regression trees) or the Gini +index (for bagging classification trees). In the case of bagging +regression trees, we can record the total amount that the MSE is +decreased due to splits over a given predictor, averaged over all \( B \) possible +trees. A large value indicates an important predictor. Similarly, in +the context of bagging classification trees, we can add up the total +amount that the Gini index is decreased by splits over a given +predictor, averaged over all \( B \) trees.

    -

    The basic approach is to apply repeatedly (in boosting this is done in an iterative way) a weak classifier to modifications of the data. -In voting we simply apply the law of large numbers while in boosting we give more weight to misclassified data in -each iteration. -

    - -

    Decision trees play an important role as our weak classifier. They serve as the basic method.

    -

    diff --git a/doc/pub/week44/html/._week44-bs054.html b/doc/pub/week44/html/._week44-bs054.html index 32b0cbca1..d0f433fb8 100644 --- a/doc/pub/week44/html/._week44-bs054.html +++ b/doc/pub/week44/html/._week44-bs054.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -322,32 +305,90 @@ MathJax.Hub.Config({

     

     

     

    -

    Tossing coins

    +

    Making your own Bootstrap: Changing the Level of the Decision Tree

    -

    The simplest case is a so-called voting ensemble. To illustrate this, -think of yourself tossing coins with a biased outcome of 51 per cent -for heads and 49% for tails. With only few tosses, -you may not clearly see this distribution for heads and tails. However, after some -thousands of tosses, there will be a clear majority of heads. With 2000 tosses -you should see approximately 1020 heads and 980 tails. +

    Let us bring up our good old boostrap example from the linear regression lectures. We change the linerar regression algorithm with +a decision tree wth different depths and perform a bootstrap aggregate (in this case we perform as many bootstraps as data points \( n \)).

    -

    We can then state that the outcome is a clear majority of heads. If -you do this ten thousand times, it is easy to see that there is a 97% -likelihood of a majority of heads. -

    + +
    +
    +
    +
    +
    +
    import matplotlib.pyplot as plt
    +import numpy as np
    +from sklearn.model_selection import train_test_split
    +from sklearn.pipeline import make_pipeline
    +from sklearn.utils import resample
    +from sklearn.tree import DecisionTreeRegressor
     
    -

    Another example would be to collect all polls before an -election. Different polls may show different likelihoods for a -candidate winning with say a majority of the popular vote. The majority vote -would then consist in many polls indicating that this candidate will -actually win. -

    +n = 100 +n_boostraps = 100 +maxdepth = 8 + +# Make data set. +x = np.linspace(-3, 3, n).reshape(-1, 1) +y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape) +error = np.zeros(maxdepth) +bias = np.zeros(maxdepth) +variance = np.zeros(maxdepth) +polydegree = np.zeros(maxdepth) +X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2) + +from sklearn.preprocessing import StandardScaler +scaler = StandardScaler() +scaler.fit(X_train) +X_train_scaled = scaler.transform(X_train) +X_test_scaled = scaler.transform(X_test) + +# we produce a simple tree first as benchmark +simpletree = DecisionTreeRegressor(max_depth=3) +simpletree.fit(X_train_scaled, y_train) +simpleprediction = simpletree.predict(X_test_scaled) +for degree in range(1,maxdepth): + model = DecisionTreeRegressor(max_depth=degree) + y_pred = np.empty((y_test.shape[0], n_boostraps)) + for i in range(n_boostraps): + x_, y_ = resample(X_train_scaled, y_train) + model.fit(x_, y_) + y_pred[:, i] = model.predict(X_test_scaled)#.ravel() + + polydegree[degree] = degree + error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) ) + bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 ) + variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) ) + print('Polynomial degree:', degree) + print('Error:', error[degree]) + print('Bias^2:', bias[degree]) + print('Var:', variance[degree]) + print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree])) + +mse_simpletree= np.mean( np.mean((y_test - simpleprediction)**2) +print(mse_simpletree) +plt.xlim(1,maxdepth) +plt.plot(polydegree, error, label='MSE') +plt.plot(polydegree, bias, label='bias') +plt.plot(polydegree, variance, label='Variance') +plt.legend() +save_fig("baggingboot") +plt.show() +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    -

    The example here shows how we can implement the coin tossing case, -clealry demostrating that after some tosses we see the law of large -numbers kicking in. -

    @@ -368,10 +409,6 @@ numbers kicking in.

  • 57
  • 58
  • 59
  • -
  • 60
  • -
  • 61
  • -
  • 62
  • -
  • 63
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs055.html b/doc/pub/week44/html/._week44-bs055.html index 99c47597c..43aff53b8 100644 --- a/doc/pub/week44/html/._week44-bs055.html +++ b/doc/pub/week44/html/._week44-bs055.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -322,67 +305,46 @@ MathJax.Hub.Config({

     

     

     

    -

    Standard imports first

    +

    Random forests

    +

    Random forests provide an improvement over bagged trees by way of a +small tweak that decorrelates the trees. +

    - -
    -
    -
    -
    -
    -
    # Common imports
    -from IPython.display import Image 
    -from pydot import graph_from_dot_data
    -import pandas as pd
    -import numpy as np
    -import matplotlib.pyplot as plt
    -from sklearn.tree import DecisionTreeClassifier
    -from sklearn.model_selection import train_test_split
    -from sklearn.tree import export_graphviz
    -from sklearn.preprocessing import StandardScaler, OneHotEncoder
    -from sklearn.compose import ColumnTransformer
    -from IPython.display import Image 
    -from pydot import graph_from_dot_data
    -import os
    +

    As in bagging, we build a +number of decision trees on bootstrapped training samples. But when +building these decision trees, each time a split in a tree is +considered, a random sample of \( m \) predictors is chosen as split +candidates from the full set of \( p \) predictors. The split is allowed to +use only one of those \( m \) predictors. +

    -# Where to save the figures and data files -PROJECT_ROOT_DIR = "Results" -FIGURE_ID = "Results/FigureFiles" -DATA_ID = "DataFiles/" +

    A fresh sample of \( m \) predictors is +taken at each split, and typically we choose +

    -if not os.path.exists(PROJECT_ROOT_DIR): - os.mkdir(PROJECT_ROOT_DIR) +$$ +m\approx \sqrt{p}. +$$ -if not os.path.exists(FIGURE_ID): - os.makedirs(FIGURE_ID) - -if not os.path.exists(DATA_ID): - os.makedirs(DATA_ID) - -def image_path(fig_id): - return os.path.join(FIGURE_ID, fig_id) - -def data_path(dat_id): - return os.path.join(DATA_ID, dat_id) - -def save_fig(fig_id): - plt.savefig(image_path(fig_id) + ".png", format='png') -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    +

    In building a random forest, at +each split in the tree, the algorithm is not even allowed to consider +a majority of the available predictors. +

    +

    The reason for this is rather clever. Suppose that there is one very +strong predictor in the data set, along with a number of other +moderately strong predictors. Then in the collection of bagged +variable importance random forest trees, most or all of the trees will +use this strong predictor in the top split. Consequently, all of the +bagged trees will look quite similar to each other. Hence the +predictions from the bagged trees will be highly correlated. +Unfortunately, averaging many highly correlated quantities does not +lead to as large of a reduction in variance as averaging many +uncorrelated quantities. In particular, this means that bagging will +not lead to a substantial reduction in variance over a single tree in +this setting. +

    @@ -402,10 +364,6 @@ DATA_ID = "

  • 57
  • 58
  • 59
  • -
  • 60
  • -
  • 61
  • -
  • 62
  • -
  • 63
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs056.html b/doc/pub/week44/html/._week44-bs056.html index 82cf23993..cd6f9d103 100644 --- a/doc/pub/week44/html/._week44-bs056.html +++ b/doc/pub/week44/html/._week44-bs056.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -322,52 +305,23 @@ MathJax.Hub.Config({

     

     

     

    -

    Simple Voting Example, head or tail

    - - -
    -
    -
    -
    -
    -
    # Common imports
    -import numpy as np
    -import matplotlib
    -import matplotlib.pyplot as plt
    -from matplotlib.colors import ListedColormap
    -plt.rcParams['axes.labelsize'] = 14
    -plt.rcParams['xtick.labelsize'] = 12
    -plt.rcParams['ytick.labelsize'] = 12
    -
    -heads_proba = 0.51
    -coin_tosses = (np.random.rand(10000, 10) < heads_proba).astype(np.int32)
    -cumulative_heads_ratio = np.cumsum(coin_tosses, axis=0) / np.arange(1, 10001).reshape(-1, 1)
    -plt.figure(figsize=(8,3.5))
    -plt.plot(cumulative_heads_ratio)
    -plt.plot([0, 10000], [0.51, 0.51], "k--", linewidth=2, label="51%")
    -plt.plot([0, 10000], [0.5, 0.5], "k-", label="50%")
    -plt.xlabel("Number of coin tosses")
    -plt.ylabel("Heads ratio")
    -plt.legend(loc="lower right")
    -plt.axis([0, 10000, 0.42, 0.58])
    -save_fig("votingsimple")
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - +

    Random Forest Algorithm

    +

    The algorithm described here can be applied to both classification and regression problems.

    +

    We will grow of forest of say \( B \) trees.

    +
      +
    1. For \( b=1:B \)
    2. +
        +
      • Draw a bootstrap sample from the training data organized in our \( \boldsymbol{X} \) matrix.
      • +
      • We grow then a random forest tree \( T_b \) based on the bootstrapped data by repeating the steps outlined till we reach the maximum node size is reached
      • +
          +
        1. we select \( m \le p \) variables at random from the \( p \) predictors/features
        2. +
        3. pick the best split point among the \( m \) features using for example the CART algorithm and create a new node
        4. +
        5. split the node into daughter nodes
        6. +
        +
      +
    3. Output then the ensemble of trees \( \{T_b\}_1^{B} \) and make predictions for either a regression type of problem or a classification type of problem.
    4. +

    diff --git a/doc/pub/week44/html/._week44-bs057.html b/doc/pub/week44/html/._week44-bs057.html index e225a08be..acc2c0c56 100644 --- a/doc/pub/week44/html/._week44-bs057.html +++ b/doc/pub/week44/html/._week44-bs057.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -322,9 +305,7 @@ MathJax.Hub.Config({

     

     

     

    -

    Using the Voting Classifier

    - -

    We can use the voting classifier on other data sets, here the exciting binary case of two distinct objects using the make moons functionality of Scikit-Learn.

    +

    Random Forests Compared with other Methods on the Cancer Data

    @@ -332,48 +313,67 @@ MathJax.Hub.Config({
    -
    from sklearn.model_selection import train_test_split
    -from sklearn.datasets import make_moons
    +  
    import matplotlib.pyplot as plt
    +import numpy as np
    +from sklearn.model_selection import  train_test_split 
    +from sklearn.datasets import load_breast_cancer
    +from sklearn.svm import SVC
    +from sklearn.linear_model import LogisticRegression
    +from sklearn.tree import DecisionTreeClassifier
    +from sklearn.ensemble import BaggingClassifier
    +
    +# Load the data
    +cancer = load_breast_cancer()
    +
    +X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0)
    +print(X_train.shape)
    +print(X_test.shape)
    +#define methods
    +# Logistic Regression
    +logreg = LogisticRegression(solver='lbfgs')
    +# Support vector machine
    +svm = SVC(gamma='auto', C=100)
    +# Decision Trees
    +deep_tree_clf = DecisionTreeClassifier(max_depth=None)
    +#Scale the data
    +from sklearn.preprocessing import StandardScaler
    +scaler = StandardScaler()
    +scaler.fit(X_train)
    +X_train_scaled = scaler.transform(X_train)
    +X_test_scaled = scaler.transform(X_test)
    +# Logistic Regression
    +logreg.fit(X_train_scaled, y_train)
    +print("Test set accuracy Logistic Regression with scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
    +# Support Vector Machine
    +svm.fit(X_train_scaled, y_train)
    +print("Test set accuracy SVM with scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
    +# Decision Trees
    +deep_tree_clf.fit(X_train_scaled, y_train)
    +print("Test set accuracy with Decision Trees and scaled data: {:.2f}".format(deep_tree_clf.score(X_test_scaled,y_test)))
     
    -X, y = make_moons(n_samples=500, noise=0.30, random_state=42)
    -X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
     
     from sklearn.ensemble import RandomForestClassifier
    -from sklearn.ensemble import VotingClassifier
    -from sklearn.linear_model import LogisticRegression
    -from sklearn.svm import SVC
    +from sklearn.preprocessing import LabelEncoder
    +from sklearn.model_selection import cross_validate
    +# Data set not specificied
    +#Instantiate the model with 500 trees and entropy as splitting criteria
    +Random_Forest_model = RandomForestClassifier(n_estimators=500,criterion="entropy")
    +Random_Forest_model.fit(X_train_scaled, y_train)
    +#Cross validation
    +accuracy = cross_validate(Random_Forest_model,X_test_scaled,y_test,cv=10)['test_score']
    +print(accuracy)
    +print("Test set accuracy with Random Forests and scaled data: {:.2f}".format(Random_Forest_model.score(X_test_scaled,y_test)))
     
    -log_clf = LogisticRegression(solver="liblinear", random_state=42)
    -rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)
    -svm_clf = SVC(gamma="auto", random_state=42)
     
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='hard')
    -
    -voting_clf.fit(X_train, y_train)
    -
    -from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    -
    -log_clf = LogisticRegression(solver="liblinear", random_state=42)
    -rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)
    -svm_clf = SVC(gamma="auto", probability=True, random_state=42)
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='soft')
    -voting_clf.fit(X_train, y_train)
    -
    -from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    +import scikitplot as skplt
    +y_pred = Random_Forest_model.predict(X_test_scaled)
    +skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)
    +plt.show()
    +y_probas = Random_Forest_model.predict_proba(X_test_scaled)
    +skplt.metrics.plot_roc(y_test, y_probas)
    +plt.show()
    +skplt.metrics.plot_cumulative_gain(y_test, y_probas)
    +plt.show()
     
    @@ -389,6 +389,15 @@ voting_clf.fit(X_train, y_train)
    +

    Recall that the cumulative gains curve shows the percentage of the +overall number of cases in a given category gained by targeting a +percentage of the total number of cases. +

    + +

    Similarly, the receiver operating characteristic curve, or ROC curve, +displays the diagnostic ability of a binary classifier system as its +discrimination threshold is varied. It plots the true positive rate against the false positive rate. +

    @@ -406,10 +415,6 @@ voting_clf.fit(X_train, y_train)

  • 57
  • 58
  • 59
  • -
  • 60
  • -
  • 61
  • -
  • 62
  • -
  • 63
  • »
  • diff --git a/doc/pub/week44/html/._week44-bs058.html b/doc/pub/week44/html/._week44-bs058.html index 6e13b7819..f8c397c4d 100644 --- a/doc/pub/week44/html/._week44-bs058.html +++ b/doc/pub/week44/html/._week44-bs058.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -322,8 +305,7 @@ MathJax.Hub.Config({

     

     

     

    -

    Voting and Bagging

    - +

    Compare Bagging on Trees with Random Forests

    @@ -331,101 +313,35 @@ MathJax.Hub.Config({
    -
    from sklearn.model_selection import train_test_split
    -from sklearn.datasets import make_moons
    -
    -X, y = make_moons(n_samples=500, noise=0.30, random_state=42)
    -X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
    +  
    bag_clf = BaggingClassifier(
    +    DecisionTreeClassifier(splitter="random", max_leaf_nodes=16, random_state=42),
    +    n_estimators=500, max_samples=1.0, bootstrap=True, n_jobs=-1, random_state=42)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    bag_clf.fit(X_train, y_train)
    +y_pred = bag_clf.predict(X_test)
     from sklearn.ensemble import RandomForestClassifier
    -from sklearn.ensemble import VotingClassifier
    -from sklearn.linear_model import LogisticRegression
    -from sklearn.svm import SVC
    -
    -log_clf = LogisticRegression(random_state=42)
    -rnd_clf = RandomForestClassifier(random_state=42)
    -svm_clf = SVC(random_state=42)
    -
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='hard')
    -voting_clf.fit(X_train, y_train)
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    log_clf = LogisticRegression(random_state=42)
    -rnd_clf = RandomForestClassifier(random_state=42)
    -svm_clf = SVC(probability=True, random_state=42)
    -
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='soft')
    -voting_clf.fit(X_train, y_train)
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    +rnd_clf = RandomForestClassifier(n_estimators=500, max_leaf_nodes=16, n_jobs=-1, random_state=42)
    +rnd_clf.fit(X_train, y_train)
    +y_pred_rf = rnd_clf.predict(X_test)
    +np.sum(y_pred == y_pred_rf) / len(y_pred) 
     
    @@ -457,11 +373,6 @@ voting_clf.fit(X_train, y_train)
  • 57
  • 58
  • 59
  • -
  • 60
  • -
  • 61
  • -
  • 62
  • -
  • 63
  • -
  • »
  • diff --git a/doc/pub/week44/html/week44-bs.html b/doc/pub/week44/html/week44-bs.html index 92c1fb661..3e5f1d17a 100644 --- a/doc/pub/week44/html/week44-bs.html +++ b/doc/pub/week44/html/week44-bs.html @@ -149,10 +149,10 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -173,26 +173,6 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -205,6 +185,13 @@ doconce format html week44.do.txt --html_style=bootstrap --pygments_html_style=d None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -286,7 +273,7 @@ MathJax.Hub.Config({
  • Further example: Computing the Gini index
  • Simple Python Code to read in Data and perform Classification
  • Computing the Gini Factor
  • -
  • Another example, the moons again
  • +
  • Another example, the moons
  • Playing around with regions
  • Regression trees
  • Final regressor code
  • @@ -294,23 +281,19 @@ MathJax.Hub.Config({
  • Disadvantages
  • Ensemble Methods: From a Single Tree to Many Trees and Extreme Boosting, Meet the Jungle of Methods
  • An Overview of Ensemble Methods
  • -
  • Bagging
  • -
  • More bagging
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Please, not the moons again! Voting and Bagging
  • -
  • Bagging Examples
  • -
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • -
  • Why Voting?
  • -
  • Tossing coins
  • -
  • Standard imports first
  • -
  • Simple Voting Example, head or tail
  • -
  • Using the Voting Classifier
  • -
  • Voting and Bagging
  • -
  • Random forests
  • -
  • Random Forest Algorithm
  • -
  • Random Forests Compared with other Methods on the Cancer Data
  • -
  • Compare Bagging on Trees with Random Forests
  • +
  • Why Voting?
  • +
  • Tossing coins
  • +
  • Standard imports first
  • +
  • Simple Voting Example, head or tail
  • +
  • Using the Voting Classifier
  • +
  • Voting and Bagging
  • +
  • Bagging
  • +
  • More bagging
  • +
  • Making your own Bootstrap: Changing the Level of the Decision Tree
  • +
  • Random forests
  • +
  • Random Forest Algorithm
  • +
  • Random Forests Compared with other Methods on the Cancer Data
  • +
  • Compare Bagging on Trees with Random Forests
  • @@ -365,7 +348,7 @@ MathJax.Hub.Config({
  • 9
  • 10
  • ...
  • -
  • 63
  • +
  • 59
  • »
  • diff --git a/doc/pub/week44/html/week44-reveal.html b/doc/pub/week44/html/week44-reveal.html index 45e63c6ab..34ebdda45 100644 --- a/doc/pub/week44/html/week44-reveal.html +++ b/doc/pub/week44/html/week44-reveal.html @@ -1530,7 +1530,7 @@ split = get_split(dataset)
    -

    Another example, the moons again

    +

    Another example, the moons

    @@ -1896,489 +1896,6 @@ try to explain here. These are

    -
    -

    Bagging

    - -

    The plain decision trees suffer from high -variance. This means that if we split the training data into two parts -at random, and fit a decision tree to both halves, the results that we -get could be quite different. In contrast, a procedure with low -variance will yield similar results if applied repeatedly to distinct -data sets; linear regression tends to have low variance, if the ratio -of \( n \) to \( p \) is moderately large. -

    - -

    Bootstrap aggregation, or just bagging, is a -general-purpose procedure for reducing the variance of a statistical -learning method. -

    -
    - -
    -

    More bagging

    - -

    Bagging typically results in improved accuracy -over prediction using a single tree. Unfortunately, however, it can be -difficult to interpret the resulting model. Recall that one of the -advantages of decision trees is the attractive and easily interpreted -diagram that results. -

    - -

    However, when we bag a large number of trees, it is no longer -possible to represent the resulting statistical learning procedure -using a single tree, and it is no longer clear which variables are -most important to the procedure. Thus, bagging improves prediction -accuracy at the expense of interpretability. Although the collection -of bagged trees is much more difficult to interpret than a single -tree, one can obtain an overall summary of the importance of each -predictor using the MSE (for bagging regression trees) or the Gini -index (for bagging classification trees). In the case of bagging -regression trees, we can record the total amount that the MSE is -decreased due to splits over a given predictor, averaged over all \( B \) possible -trees. A large value indicates an important predictor. Similarly, in -the context of bagging classification trees, we can add up the total -amount that the Gini index is decreased by splits over a given -predictor, averaged over all \( B \) trees. -

    -
    - -
    -

    Simple Voting Example, head or tail

    - - -
    -
    -
    -
    -
    -
    heads_proba = 0.51
    -coin_tosses = (np.random.rand(10000, 10) < heads_proba).astype(np.int32)
    -cumulative_heads_ratio = np.cumsum(coin_tosses, axis=0) / np.arange(1, 10001).reshape(-1, 1)
    -plt.figure(figsize=(8,3.5))
    -plt.plot(cumulative_heads_ratio)
    -plt.plot([0, 10000], [0.51, 0.51], "k--", linewidth=2, label="51%")
    -plt.plot([0, 10000], [0.5, 0.5], "k-", label="50%")
    -plt.xlabel("Number of coin tosses")
    -plt.ylabel("Heads ratio")
    -plt.legend(loc="lower right")
    -plt.axis([0, 10000, 0.42, 0.58])
    -save_fig("votingsimple")
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -

    Using the Voting Classifier

    - - -
    -
    -
    -
    -
    -
    from sklearn.model_selection import train_test_split
    -from sklearn.datasets import make_moons
    -
    -X, y = make_moons(n_samples=500, noise=0.30, random_state=42)
    -X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
    -
    -from sklearn.ensemble import RandomForestClassifier
    -from sklearn.ensemble import VotingClassifier
    -from sklearn.linear_model import LogisticRegression
    -from sklearn.svm import SVC
    -
    -log_clf = LogisticRegression(solver="liblinear", random_state=42)
    -rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)
    -svm_clf = SVC(gamma="auto", random_state=42)
    -
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='hard')
    -
    -voting_clf.fit(X_train, y_train)
    -
    -from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    -
    -log_clf = LogisticRegression(solver="liblinear", random_state=42)
    -rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)
    -svm_clf = SVC(gamma="auto", probability=True, random_state=42)
    -
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='soft')
    -voting_clf.fit(X_train, y_train)
    -
    -from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -

    Please, not the moons again! Voting and Bagging

    - - - -
    -
    -
    -
    -
    -
    from sklearn.model_selection import train_test_split
    -from sklearn.datasets import make_moons
    -
    -X, y = make_moons(n_samples=500, noise=0.30, random_state=42)
    -X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
    -from sklearn.ensemble import RandomForestClassifier
    -from sklearn.ensemble import VotingClassifier
    -from sklearn.linear_model import LogisticRegression
    -from sklearn.svm import SVC
    -
    -log_clf = LogisticRegression(random_state=42)
    -rnd_clf = RandomForestClassifier(random_state=42)
    -svm_clf = SVC(random_state=42)
    -
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='hard')
    -voting_clf.fit(X_train, y_train)
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    log_clf = LogisticRegression(random_state=42)
    -rnd_clf = RandomForestClassifier(random_state=42)
    -svm_clf = SVC(probability=True, random_state=42)
    -
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='soft')
    -voting_clf.fit(X_train, y_train)
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -

    Bagging Examples

    - - - -
    -
    -
    -
    -
    -
    from sklearn.ensemble import BaggingClassifier
    -from sklearn.tree import DecisionTreeClassifier
    -
    -bag_clf = BaggingClassifier(
    -    DecisionTreeClassifier(random_state=42), n_estimators=500,
    -    max_samples=100, bootstrap=True, n_jobs=-1, random_state=42)
    -bag_clf.fit(X_train, y_train)
    -y_pred = bag_clf.predict(X_test)
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from sklearn.metrics import accuracy_score
    -print(accuracy_score(y_test, y_pred))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    tree_clf = DecisionTreeClassifier(random_state=42)
    -tree_clf.fit(X_train, y_train)
    -y_pred_tree = tree_clf.predict(X_test)
    -print(accuracy_score(y_test, y_pred_tree))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from matplotlib.colors import ListedColormap
    -
    -def plot_decision_boundary(clf, X, y, axes=[-1.5, 2.5, -1, 1.5], alpha=0.5, contour=True):
    -    x1s = np.linspace(axes[0], axes[1], 100)
    -    x2s = np.linspace(axes[2], axes[3], 100)
    -    x1, x2 = np.meshgrid(x1s, x2s)
    -    X_new = np.c_[x1.ravel(), x2.ravel()]
    -    y_pred = clf.predict(X_new).reshape(x1.shape)
    -    custom_cmap = ListedColormap(['#fafab0','#9898ff','#a0faa0'])
    -    plt.contourf(x1, x2, y_pred, alpha=0.3, cmap=custom_cmap)
    -    if contour:
    -        custom_cmap2 = ListedColormap(['#7d7d58','#4c4c7f','#507d50'])
    -        plt.contour(x1, x2, y_pred, cmap=custom_cmap2, alpha=0.8)
    -    plt.plot(X[:, 0][y==0], X[:, 1][y==0], "yo", alpha=alpha)
    -    plt.plot(X[:, 0][y==1], X[:, 1][y==1], "bs", alpha=alpha)
    -    plt.axis(axes)
    -    plt.xlabel(r"$x_1$", fontsize=18)
    -    plt.ylabel(r"$x_2$", fontsize=18, rotation=0)
    -plt.figure(figsize=(11,4))
    -plt.subplot(121)
    -plot_decision_boundary(tree_clf, X, y)
    -plt.title("Decision Tree", fontsize=14)
    -plt.subplot(122)
    -plot_decision_boundary(bag_clf, X, y)
    -plt.title("Decision Trees with Bagging", fontsize=14)
    -save_fig("baggingtree")
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -

    Making your own Bootstrap: Changing the Level of the Decision Tree

    - -

    Let us bring up our good old boostrap example from the linear regression lectures. We change the linerar regression algorithm with -a decision tree wth different depths and perform a bootstrap aggregate (in this case we perform as many bootstraps as data points \( n \)). -

    - - -
    -
    -
    -
    -
    -
    import matplotlib.pyplot as plt
    -import numpy as np
    -from sklearn.model_selection import train_test_split
    -from sklearn.pipeline import make_pipeline
    -from sklearn.utils import resample
    -from sklearn.tree import DecisionTreeRegressor
    -
    -n = 100
    -n_boostraps = 100
    -maxdepth = 8
    -
    -# Make data set.
    -x = np.linspace(-3, 3, n).reshape(-1, 1)
    -y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)
    -error = np.zeros(maxdepth)
    -bias = np.zeros(maxdepth)
    -variance = np.zeros(maxdepth)
    -polydegree = np.zeros(maxdepth)
    -X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
    -
    -from sklearn.preprocessing import StandardScaler
    -scaler = StandardScaler()
    -scaler.fit(X_train)
    -X_train_scaled = scaler.transform(X_train)
    -X_test_scaled = scaler.transform(X_test)
    -
    -# we produce a simple tree first as benchmark
    -simpletree = DecisionTreeRegressor(max_depth=3) 
    -simpletree.fit(X_train_scaled, y_train)
    -simpleprediction = simpletree.predict(X_test_scaled)
    -for degree in range(1,maxdepth):
    -    model = DecisionTreeRegressor(max_depth=degree) 
    -    y_pred = np.empty((y_test.shape[0], n_boostraps))
    -    for i in range(n_boostraps):
    -        x_, y_ = resample(X_train_scaled, y_train)
    -        model.fit(x_, y_)
    -        y_pred[:, i] = model.predict(X_test_scaled)#.ravel()
    -
    -    polydegree[degree] = degree
    -    error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )
    -    bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )
    -    variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) )
    -    print('Polynomial degree:', degree)
    -    print('Error:', error[degree])
    -    print('Bias^2:', bias[degree])
    -    print('Var:', variance[degree])
    -    print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree]))
    - 
    -mse_simpletree= np.mean( np.mean((y_test - simpleprediction)**2)
    -print(mse_simpletree)
    -plt.xlim(1,maxdepth)
    -plt.plot(polydegree, error, label='MSE')
    -plt.plot(polydegree, bias, label='bias')
    -plt.plot(polydegree, variance, label='Variance')
    -plt.legend()
    -save_fig("baggingboot")
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -

    Why Voting?

    @@ -2729,6 +2246,138 @@ voting_clf.fit(X_train, y_train)
    +
    +

    Bagging

    + +

    The plain decision trees suffer from high +variance. This means that if we split the training data into two parts +at random, and fit a decision tree to both halves, the results that we +get could be quite different. In contrast, a procedure with low +variance will yield similar results if applied repeatedly to distinct +data sets; linear regression tends to have low variance, if the ratio +of \( n \) to \( p \) is moderately large. +

    + +

    Bootstrap aggregation, or just bagging, is a +general-purpose procedure for reducing the variance of a statistical +learning method. +

    +
    + +
    +

    More bagging

    + +

    Bagging typically results in improved accuracy +over prediction using a single tree. Unfortunately, however, it can be +difficult to interpret the resulting model. Recall that one of the +advantages of decision trees is the attractive and easily interpreted +diagram that results. +

    + +

    However, when we bag a large number of trees, it is no longer +possible to represent the resulting statistical learning procedure +using a single tree, and it is no longer clear which variables are +most important to the procedure. Thus, bagging improves prediction +accuracy at the expense of interpretability. Although the collection +of bagged trees is much more difficult to interpret than a single +tree, one can obtain an overall summary of the importance of each +predictor using the MSE (for bagging regression trees) or the Gini +index (for bagging classification trees). In the case of bagging +regression trees, we can record the total amount that the MSE is +decreased due to splits over a given predictor, averaged over all \( B \) possible +trees. A large value indicates an important predictor. Similarly, in +the context of bagging classification trees, we can add up the total +amount that the Gini index is decreased by splits over a given +predictor, averaged over all \( B \) trees. +

    +
    + +
    +

    Making your own Bootstrap: Changing the Level of the Decision Tree

    + +

    Let us bring up our good old boostrap example from the linear regression lectures. We change the linerar regression algorithm with +a decision tree wth different depths and perform a bootstrap aggregate (in this case we perform as many bootstraps as data points \( n \)). +

    + + +
    +
    +
    +
    +
    +
    import matplotlib.pyplot as plt
    +import numpy as np
    +from sklearn.model_selection import train_test_split
    +from sklearn.pipeline import make_pipeline
    +from sklearn.utils import resample
    +from sklearn.tree import DecisionTreeRegressor
    +
    +n = 100
    +n_boostraps = 100
    +maxdepth = 8
    +
    +# Make data set.
    +x = np.linspace(-3, 3, n).reshape(-1, 1)
    +y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)
    +error = np.zeros(maxdepth)
    +bias = np.zeros(maxdepth)
    +variance = np.zeros(maxdepth)
    +polydegree = np.zeros(maxdepth)
    +X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
    +
    +from sklearn.preprocessing import StandardScaler
    +scaler = StandardScaler()
    +scaler.fit(X_train)
    +X_train_scaled = scaler.transform(X_train)
    +X_test_scaled = scaler.transform(X_test)
    +
    +# we produce a simple tree first as benchmark
    +simpletree = DecisionTreeRegressor(max_depth=3) 
    +simpletree.fit(X_train_scaled, y_train)
    +simpleprediction = simpletree.predict(X_test_scaled)
    +for degree in range(1,maxdepth):
    +    model = DecisionTreeRegressor(max_depth=degree) 
    +    y_pred = np.empty((y_test.shape[0], n_boostraps))
    +    for i in range(n_boostraps):
    +        x_, y_ = resample(X_train_scaled, y_train)
    +        model.fit(x_, y_)
    +        y_pred[:, i] = model.predict(X_test_scaled)#.ravel()
    +
    +    polydegree[degree] = degree
    +    error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )
    +    bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )
    +    variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) )
    +    print('Polynomial degree:', degree)
    +    print('Error:', error[degree])
    +    print('Bias^2:', bias[degree])
    +    print('Var:', variance[degree])
    +    print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree]))
    + 
    +mse_simpletree= np.mean( np.mean((y_test - simpleprediction)**2)
    +print(mse_simpletree)
    +plt.xlim(1,maxdepth)
    +plt.plot(polydegree, error, label='MSE')
    +plt.plot(polydegree, bias, label='bias')
    +plt.plot(polydegree, variance, label='Variance')
    +plt.legend()
    +save_fig("baggingboot")
    +plt.show()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Random forests

    @@ -2825,19 +2474,14 @@ cancer = load_breast_cancer() X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0) print(X_train.shape) print(X_test.shape) +#define methods # Logistic Regression logreg = LogisticRegression(solver='lbfgs') -logreg.fit(X_train, y_train) -print("Test set accuracy with Logistic Regression: {:.2f}".format(logreg.score(X_test,y_test))) # Support vector machine svm = SVC(gamma='auto', C=100) -svm.fit(X_train, y_train) -print("Test set accuracy with SVM: {:.2f}".format(svm.score(X_test,y_test))) # Decision Trees deep_tree_clf = DecisionTreeClassifier(max_depth=None) -deep_tree_clf.fit(X_train, y_train) -print("Test set accuracy with Decision Trees: {:.2f}".format(deep_tree_clf.score(X_test,y_test))) -#now scale the data +#Scale the data from sklearn.preprocessing import StandardScaler scaler = StandardScaler() scaler.fit(X_train) diff --git a/doc/pub/week44/html/week44-solarized.html b/doc/pub/week44/html/week44-solarized.html index bcfd96b38..cfb9094ee 100644 --- a/doc/pub/week44/html/week44-solarized.html +++ b/doc/pub/week44/html/week44-solarized.html @@ -176,10 +176,10 @@ div.toc p,a { 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -200,26 +200,6 @@ div.toc p,a { 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -232,6 +212,13 @@ div.toc p,a { None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -1556,7 +1543,7 @@ split = get_split(dataset)









    -

    Another example, the moons again

    +

    Another example, the moons

    @@ -1915,487 +1902,6 @@ try to explain here. These are

    -









    -

    Bagging

    - -

    The plain decision trees suffer from high -variance. This means that if we split the training data into two parts -at random, and fit a decision tree to both halves, the results that we -get could be quite different. In contrast, a procedure with low -variance will yield similar results if applied repeatedly to distinct -data sets; linear regression tends to have low variance, if the ratio -of \( n \) to \( p \) is moderately large. -

    - -

    Bootstrap aggregation, or just bagging, is a -general-purpose procedure for reducing the variance of a statistical -learning method. -

    - -









    -

    More bagging

    - -

    Bagging typically results in improved accuracy -over prediction using a single tree. Unfortunately, however, it can be -difficult to interpret the resulting model. Recall that one of the -advantages of decision trees is the attractive and easily interpreted -diagram that results. -

    - -

    However, when we bag a large number of trees, it is no longer -possible to represent the resulting statistical learning procedure -using a single tree, and it is no longer clear which variables are -most important to the procedure. Thus, bagging improves prediction -accuracy at the expense of interpretability. Although the collection -of bagged trees is much more difficult to interpret than a single -tree, one can obtain an overall summary of the importance of each -predictor using the MSE (for bagging regression trees) or the Gini -index (for bagging classification trees). In the case of bagging -regression trees, we can record the total amount that the MSE is -decreased due to splits over a given predictor, averaged over all \( B \) possible -trees. A large value indicates an important predictor. Similarly, in -the context of bagging classification trees, we can add up the total -amount that the Gini index is decreased by splits over a given -predictor, averaged over all \( B \) trees. -

    - -









    -

    Simple Voting Example, head or tail

    - - -
    -
    -
    -
    -
    -
    heads_proba = 0.51
    -coin_tosses = (np.random.rand(10000, 10) < heads_proba).astype(np.int32)
    -cumulative_heads_ratio = np.cumsum(coin_tosses, axis=0) / np.arange(1, 10001).reshape(-1, 1)
    -plt.figure(figsize=(8,3.5))
    -plt.plot(cumulative_heads_ratio)
    -plt.plot([0, 10000], [0.51, 0.51], "k--", linewidth=2, label="51%")
    -plt.plot([0, 10000], [0.5, 0.5], "k-", label="50%")
    -plt.xlabel("Number of coin tosses")
    -plt.ylabel("Heads ratio")
    -plt.legend(loc="lower right")
    -plt.axis([0, 10000, 0.42, 0.58])
    -save_fig("votingsimple")
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Using the Voting Classifier

    - - -
    -
    -
    -
    -
    -
    from sklearn.model_selection import train_test_split
    -from sklearn.datasets import make_moons
    -
    -X, y = make_moons(n_samples=500, noise=0.30, random_state=42)
    -X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
    -
    -from sklearn.ensemble import RandomForestClassifier
    -from sklearn.ensemble import VotingClassifier
    -from sklearn.linear_model import LogisticRegression
    -from sklearn.svm import SVC
    -
    -log_clf = LogisticRegression(solver="liblinear", random_state=42)
    -rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)
    -svm_clf = SVC(gamma="auto", random_state=42)
    -
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='hard')
    -
    -voting_clf.fit(X_train, y_train)
    -
    -from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    -
    -log_clf = LogisticRegression(solver="liblinear", random_state=42)
    -rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)
    -svm_clf = SVC(gamma="auto", probability=True, random_state=42)
    -
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='soft')
    -voting_clf.fit(X_train, y_train)
    -
    -from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Please, not the moons again! Voting and Bagging

    - - - -
    -
    -
    -
    -
    -
    from sklearn.model_selection import train_test_split
    -from sklearn.datasets import make_moons
    -
    -X, y = make_moons(n_samples=500, noise=0.30, random_state=42)
    -X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
    -from sklearn.ensemble import RandomForestClassifier
    -from sklearn.ensemble import VotingClassifier
    -from sklearn.linear_model import LogisticRegression
    -from sklearn.svm import SVC
    -
    -log_clf = LogisticRegression(random_state=42)
    -rnd_clf = RandomForestClassifier(random_state=42)
    -svm_clf = SVC(random_state=42)
    -
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='hard')
    -voting_clf.fit(X_train, y_train)
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    log_clf = LogisticRegression(random_state=42)
    -rnd_clf = RandomForestClassifier(random_state=42)
    -svm_clf = SVC(probability=True, random_state=42)
    -
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='soft')
    -voting_clf.fit(X_train, y_train)
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Bagging Examples

    - - - -
    -
    -
    -
    -
    -
    from sklearn.ensemble import BaggingClassifier
    -from sklearn.tree import DecisionTreeClassifier
    -
    -bag_clf = BaggingClassifier(
    -    DecisionTreeClassifier(random_state=42), n_estimators=500,
    -    max_samples=100, bootstrap=True, n_jobs=-1, random_state=42)
    -bag_clf.fit(X_train, y_train)
    -y_pred = bag_clf.predict(X_test)
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from sklearn.metrics import accuracy_score
    -print(accuracy_score(y_test, y_pred))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    tree_clf = DecisionTreeClassifier(random_state=42)
    -tree_clf.fit(X_train, y_train)
    -y_pred_tree = tree_clf.predict(X_test)
    -print(accuracy_score(y_test, y_pred_tree))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from matplotlib.colors import ListedColormap
    -
    -def plot_decision_boundary(clf, X, y, axes=[-1.5, 2.5, -1, 1.5], alpha=0.5, contour=True):
    -    x1s = np.linspace(axes[0], axes[1], 100)
    -    x2s = np.linspace(axes[2], axes[3], 100)
    -    x1, x2 = np.meshgrid(x1s, x2s)
    -    X_new = np.c_[x1.ravel(), x2.ravel()]
    -    y_pred = clf.predict(X_new).reshape(x1.shape)
    -    custom_cmap = ListedColormap(['#fafab0','#9898ff','#a0faa0'])
    -    plt.contourf(x1, x2, y_pred, alpha=0.3, cmap=custom_cmap)
    -    if contour:
    -        custom_cmap2 = ListedColormap(['#7d7d58','#4c4c7f','#507d50'])
    -        plt.contour(x1, x2, y_pred, cmap=custom_cmap2, alpha=0.8)
    -    plt.plot(X[:, 0][y==0], X[:, 1][y==0], "yo", alpha=alpha)
    -    plt.plot(X[:, 0][y==1], X[:, 1][y==1], "bs", alpha=alpha)
    -    plt.axis(axes)
    -    plt.xlabel(r"$x_1$", fontsize=18)
    -    plt.ylabel(r"$x_2$", fontsize=18, rotation=0)
    -plt.figure(figsize=(11,4))
    -plt.subplot(121)
    -plot_decision_boundary(tree_clf, X, y)
    -plt.title("Decision Tree", fontsize=14)
    -plt.subplot(122)
    -plot_decision_boundary(bag_clf, X, y)
    -plt.title("Decision Trees with Bagging", fontsize=14)
    -save_fig("baggingtree")
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Making your own Bootstrap: Changing the Level of the Decision Tree

    - -

    Let us bring up our good old boostrap example from the linear regression lectures. We change the linerar regression algorithm with -a decision tree wth different depths and perform a bootstrap aggregate (in this case we perform as many bootstraps as data points \( n \)). -

    - - -
    -
    -
    -
    -
    -
    import matplotlib.pyplot as plt
    -import numpy as np
    -from sklearn.model_selection import train_test_split
    -from sklearn.pipeline import make_pipeline
    -from sklearn.utils import resample
    -from sklearn.tree import DecisionTreeRegressor
    -
    -n = 100
    -n_boostraps = 100
    -maxdepth = 8
    -
    -# Make data set.
    -x = np.linspace(-3, 3, n).reshape(-1, 1)
    -y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)
    -error = np.zeros(maxdepth)
    -bias = np.zeros(maxdepth)
    -variance = np.zeros(maxdepth)
    -polydegree = np.zeros(maxdepth)
    -X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
    -
    -from sklearn.preprocessing import StandardScaler
    -scaler = StandardScaler()
    -scaler.fit(X_train)
    -X_train_scaled = scaler.transform(X_train)
    -X_test_scaled = scaler.transform(X_test)
    -
    -# we produce a simple tree first as benchmark
    -simpletree = DecisionTreeRegressor(max_depth=3) 
    -simpletree.fit(X_train_scaled, y_train)
    -simpleprediction = simpletree.predict(X_test_scaled)
    -for degree in range(1,maxdepth):
    -    model = DecisionTreeRegressor(max_depth=degree) 
    -    y_pred = np.empty((y_test.shape[0], n_boostraps))
    -    for i in range(n_boostraps):
    -        x_, y_ = resample(X_train_scaled, y_train)
    -        model.fit(x_, y_)
    -        y_pred[:, i] = model.predict(X_test_scaled)#.ravel()
    -
    -    polydegree[degree] = degree
    -    error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )
    -    bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )
    -    variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) )
    -    print('Polynomial degree:', degree)
    -    print('Error:', error[degree])
    -    print('Bias^2:', bias[degree])
    -    print('Var:', variance[degree])
    -    print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree]))
    - 
    -mse_simpletree= np.mean( np.mean((y_test - simpleprediction)**2)
    -print(mse_simpletree)
    -plt.xlim(1,maxdepth)
    -plt.plot(polydegree, error, label='MSE')
    -plt.plot(polydegree, bias, label='bias')
    -plt.plot(polydegree, variance, label='Variance')
    -plt.legend()
    -save_fig("baggingboot")
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -









    Why Voting?

    @@ -2744,6 +2250,136 @@ voting_clf.fit(X_train, y_train)
    +









    +

    Bagging

    + +

    The plain decision trees suffer from high +variance. This means that if we split the training data into two parts +at random, and fit a decision tree to both halves, the results that we +get could be quite different. In contrast, a procedure with low +variance will yield similar results if applied repeatedly to distinct +data sets; linear regression tends to have low variance, if the ratio +of \( n \) to \( p \) is moderately large. +

    + +

    Bootstrap aggregation, or just bagging, is a +general-purpose procedure for reducing the variance of a statistical +learning method. +

    + +









    +

    More bagging

    + +

    Bagging typically results in improved accuracy +over prediction using a single tree. Unfortunately, however, it can be +difficult to interpret the resulting model. Recall that one of the +advantages of decision trees is the attractive and easily interpreted +diagram that results. +

    + +

    However, when we bag a large number of trees, it is no longer +possible to represent the resulting statistical learning procedure +using a single tree, and it is no longer clear which variables are +most important to the procedure. Thus, bagging improves prediction +accuracy at the expense of interpretability. Although the collection +of bagged trees is much more difficult to interpret than a single +tree, one can obtain an overall summary of the importance of each +predictor using the MSE (for bagging regression trees) or the Gini +index (for bagging classification trees). In the case of bagging +regression trees, we can record the total amount that the MSE is +decreased due to splits over a given predictor, averaged over all \( B \) possible +trees. A large value indicates an important predictor. Similarly, in +the context of bagging classification trees, we can add up the total +amount that the Gini index is decreased by splits over a given +predictor, averaged over all \( B \) trees. +

    + +









    +

    Making your own Bootstrap: Changing the Level of the Decision Tree

    + +

    Let us bring up our good old boostrap example from the linear regression lectures. We change the linerar regression algorithm with +a decision tree wth different depths and perform a bootstrap aggregate (in this case we perform as many bootstraps as data points \( n \)). +

    + + +
    +
    +
    +
    +
    +
    import matplotlib.pyplot as plt
    +import numpy as np
    +from sklearn.model_selection import train_test_split
    +from sklearn.pipeline import make_pipeline
    +from sklearn.utils import resample
    +from sklearn.tree import DecisionTreeRegressor
    +
    +n = 100
    +n_boostraps = 100
    +maxdepth = 8
    +
    +# Make data set.
    +x = np.linspace(-3, 3, n).reshape(-1, 1)
    +y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)
    +error = np.zeros(maxdepth)
    +bias = np.zeros(maxdepth)
    +variance = np.zeros(maxdepth)
    +polydegree = np.zeros(maxdepth)
    +X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
    +
    +from sklearn.preprocessing import StandardScaler
    +scaler = StandardScaler()
    +scaler.fit(X_train)
    +X_train_scaled = scaler.transform(X_train)
    +X_test_scaled = scaler.transform(X_test)
    +
    +# we produce a simple tree first as benchmark
    +simpletree = DecisionTreeRegressor(max_depth=3) 
    +simpletree.fit(X_train_scaled, y_train)
    +simpleprediction = simpletree.predict(X_test_scaled)
    +for degree in range(1,maxdepth):
    +    model = DecisionTreeRegressor(max_depth=degree) 
    +    y_pred = np.empty((y_test.shape[0], n_boostraps))
    +    for i in range(n_boostraps):
    +        x_, y_ = resample(X_train_scaled, y_train)
    +        model.fit(x_, y_)
    +        y_pred[:, i] = model.predict(X_test_scaled)#.ravel()
    +
    +    polydegree[degree] = degree
    +    error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )
    +    bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )
    +    variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) )
    +    print('Polynomial degree:', degree)
    +    print('Error:', error[degree])
    +    print('Bias^2:', bias[degree])
    +    print('Var:', variance[degree])
    +    print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree]))
    + 
    +mse_simpletree= np.mean( np.mean((y_test - simpleprediction)**2)
    +print(mse_simpletree)
    +plt.xlim(1,maxdepth)
    +plt.plot(polydegree, error, label='MSE')
    +plt.plot(polydegree, bias, label='bias')
    +plt.plot(polydegree, variance, label='Variance')
    +plt.legend()
    +save_fig("baggingboot")
    +plt.show()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +









    Random forests

    @@ -2828,19 +2464,14 @@ cancer = load_breast_cancer() X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0) print(X_train.shape) print(X_test.shape) +#define methods # Logistic Regression logreg = LogisticRegression(solver='lbfgs') -logreg.fit(X_train, y_train) -print("Test set accuracy with Logistic Regression: {:.2f}".format(logreg.score(X_test,y_test))) # Support vector machine svm = SVC(gamma='auto', C=100) -svm.fit(X_train, y_train) -print("Test set accuracy with SVM: {:.2f}".format(svm.score(X_test,y_test))) # Decision Trees deep_tree_clf = DecisionTreeClassifier(max_depth=None) -deep_tree_clf.fit(X_train, y_train) -print("Test set accuracy with Decision Trees: {:.2f}".format(deep_tree_clf.score(X_test,y_test))) -#now scale the data +#Scale the data from sklearn.preprocessing import StandardScaler scaler = StandardScaler() scaler.fit(X_train) diff --git a/doc/pub/week44/html/week44.html b/doc/pub/week44/html/week44.html index 3d7b78d9f..9b2b756de 100644 --- a/doc/pub/week44/html/week44.html +++ b/doc/pub/week44/html/week44.html @@ -253,10 +253,10 @@ div.toc p,a { 2, None, 'computing-the-gini-factor'), - ('Another example, the moons again', + ('Another example, the moons', 2, None, - 'another-example-the-moons-again'), + 'another-example-the-moons'), ('Playing around with regions', 2, None, @@ -277,26 +277,6 @@ div.toc p,a { 2, None, 'an-overview-of-ensemble-methods'), - ('Bagging', 2, None, 'bagging'), - ('More bagging', 2, None, 'more-bagging'), - ('Simple Voting Example, head or tail', - 2, - None, - 'simple-voting-example-head-or-tail'), - ('Using the Voting Classifier', - 2, - None, - 'using-the-voting-classifier'), - ('Please, not the moons again! Voting and Bagging', - 2, - None, - 'please-not-the-moons-again-voting-and-bagging'), - ('Bagging Examples', 2, None, 'bagging-examples'), - ('Making your own Bootstrap: Changing the Level of the Decision ' - 'Tree', - 2, - None, - 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Why Voting?', 2, None, 'why-voting'), ('Tossing coins', 2, None, 'tossing-coins'), ('Standard imports first', 2, None, 'standard-imports-first'), @@ -309,6 +289,13 @@ div.toc p,a { None, 'using-the-voting-classifier'), ('Voting and Bagging', 2, None, 'voting-and-bagging'), + ('Bagging', 2, None, 'bagging'), + ('More bagging', 2, None, 'more-bagging'), + ('Making your own Bootstrap: Changing the Level of the Decision ' + 'Tree', + 2, + None, + 'making-your-own-bootstrap-changing-the-level-of-the-decision-tree'), ('Random forests', 2, None, 'random-forests'), ('Random Forest Algorithm', 2, None, 'random-forest-algorithm'), ('Random Forests Compared with other Methods on the Cancer Data', @@ -1633,7 +1620,7 @@ split = get_split(dataset)









    -

    Another example, the moons again

    +

    Another example, the moons

    @@ -1992,487 +1979,6 @@ try to explain here. These are

    -









    -

    Bagging

    - -

    The plain decision trees suffer from high -variance. This means that if we split the training data into two parts -at random, and fit a decision tree to both halves, the results that we -get could be quite different. In contrast, a procedure with low -variance will yield similar results if applied repeatedly to distinct -data sets; linear regression tends to have low variance, if the ratio -of \( n \) to \( p \) is moderately large. -

    - -

    Bootstrap aggregation, or just bagging, is a -general-purpose procedure for reducing the variance of a statistical -learning method. -

    - -









    -

    More bagging

    - -

    Bagging typically results in improved accuracy -over prediction using a single tree. Unfortunately, however, it can be -difficult to interpret the resulting model. Recall that one of the -advantages of decision trees is the attractive and easily interpreted -diagram that results. -

    - -

    However, when we bag a large number of trees, it is no longer -possible to represent the resulting statistical learning procedure -using a single tree, and it is no longer clear which variables are -most important to the procedure. Thus, bagging improves prediction -accuracy at the expense of interpretability. Although the collection -of bagged trees is much more difficult to interpret than a single -tree, one can obtain an overall summary of the importance of each -predictor using the MSE (for bagging regression trees) or the Gini -index (for bagging classification trees). In the case of bagging -regression trees, we can record the total amount that the MSE is -decreased due to splits over a given predictor, averaged over all \( B \) possible -trees. A large value indicates an important predictor. Similarly, in -the context of bagging classification trees, we can add up the total -amount that the Gini index is decreased by splits over a given -predictor, averaged over all \( B \) trees. -

    - -









    -

    Simple Voting Example, head or tail

    - - -
    -
    -
    -
    -
    -
    heads_proba = 0.51
    -coin_tosses = (np.random.rand(10000, 10) < heads_proba).astype(np.int32)
    -cumulative_heads_ratio = np.cumsum(coin_tosses, axis=0) / np.arange(1, 10001).reshape(-1, 1)
    -plt.figure(figsize=(8,3.5))
    -plt.plot(cumulative_heads_ratio)
    -plt.plot([0, 10000], [0.51, 0.51], "k--", linewidth=2, label="51%")
    -plt.plot([0, 10000], [0.5, 0.5], "k-", label="50%")
    -plt.xlabel("Number of coin tosses")
    -plt.ylabel("Heads ratio")
    -plt.legend(loc="lower right")
    -plt.axis([0, 10000, 0.42, 0.58])
    -save_fig("votingsimple")
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Using the Voting Classifier

    - - -
    -
    -
    -
    -
    -
    from sklearn.model_selection import train_test_split
    -from sklearn.datasets import make_moons
    -
    -X, y = make_moons(n_samples=500, noise=0.30, random_state=42)
    -X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
    -
    -from sklearn.ensemble import RandomForestClassifier
    -from sklearn.ensemble import VotingClassifier
    -from sklearn.linear_model import LogisticRegression
    -from sklearn.svm import SVC
    -
    -log_clf = LogisticRegression(solver="liblinear", random_state=42)
    -rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)
    -svm_clf = SVC(gamma="auto", random_state=42)
    -
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='hard')
    -
    -voting_clf.fit(X_train, y_train)
    -
    -from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    -
    -log_clf = LogisticRegression(solver="liblinear", random_state=42)
    -rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)
    -svm_clf = SVC(gamma="auto", probability=True, random_state=42)
    -
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='soft')
    -voting_clf.fit(X_train, y_train)
    -
    -from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Please, not the moons again! Voting and Bagging

    - - - -
    -
    -
    -
    -
    -
    from sklearn.model_selection import train_test_split
    -from sklearn.datasets import make_moons
    -
    -X, y = make_moons(n_samples=500, noise=0.30, random_state=42)
    -X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
    -from sklearn.ensemble import RandomForestClassifier
    -from sklearn.ensemble import VotingClassifier
    -from sklearn.linear_model import LogisticRegression
    -from sklearn.svm import SVC
    -
    -log_clf = LogisticRegression(random_state=42)
    -rnd_clf = RandomForestClassifier(random_state=42)
    -svm_clf = SVC(random_state=42)
    -
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='hard')
    -voting_clf.fit(X_train, y_train)
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    log_clf = LogisticRegression(random_state=42)
    -rnd_clf = RandomForestClassifier(random_state=42)
    -svm_clf = SVC(probability=True, random_state=42)
    -
    -voting_clf = VotingClassifier(
    -    estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],
    -    voting='soft')
    -voting_clf.fit(X_train, y_train)
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from sklearn.metrics import accuracy_score
    -
    -for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
    -    clf.fit(X_train, y_train)
    -    y_pred = clf.predict(X_test)
    -    print(clf.__class__.__name__, accuracy_score(y_test, y_pred))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Bagging Examples

    - - - -
    -
    -
    -
    -
    -
    from sklearn.ensemble import BaggingClassifier
    -from sklearn.tree import DecisionTreeClassifier
    -
    -bag_clf = BaggingClassifier(
    -    DecisionTreeClassifier(random_state=42), n_estimators=500,
    -    max_samples=100, bootstrap=True, n_jobs=-1, random_state=42)
    -bag_clf.fit(X_train, y_train)
    -y_pred = bag_clf.predict(X_test)
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from sklearn.metrics import accuracy_score
    -print(accuracy_score(y_test, y_pred))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    tree_clf = DecisionTreeClassifier(random_state=42)
    -tree_clf.fit(X_train, y_train)
    -y_pred_tree = tree_clf.predict(X_test)
    -print(accuracy_score(y_test, y_pred_tree))
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    from matplotlib.colors import ListedColormap
    -
    -def plot_decision_boundary(clf, X, y, axes=[-1.5, 2.5, -1, 1.5], alpha=0.5, contour=True):
    -    x1s = np.linspace(axes[0], axes[1], 100)
    -    x2s = np.linspace(axes[2], axes[3], 100)
    -    x1, x2 = np.meshgrid(x1s, x2s)
    -    X_new = np.c_[x1.ravel(), x2.ravel()]
    -    y_pred = clf.predict(X_new).reshape(x1.shape)
    -    custom_cmap = ListedColormap(['#fafab0','#9898ff','#a0faa0'])
    -    plt.contourf(x1, x2, y_pred, alpha=0.3, cmap=custom_cmap)
    -    if contour:
    -        custom_cmap2 = ListedColormap(['#7d7d58','#4c4c7f','#507d50'])
    -        plt.contour(x1, x2, y_pred, cmap=custom_cmap2, alpha=0.8)
    -    plt.plot(X[:, 0][y==0], X[:, 1][y==0], "yo", alpha=alpha)
    -    plt.plot(X[:, 0][y==1], X[:, 1][y==1], "bs", alpha=alpha)
    -    plt.axis(axes)
    -    plt.xlabel(r"$x_1$", fontsize=18)
    -    plt.ylabel(r"$x_2$", fontsize=18, rotation=0)
    -plt.figure(figsize=(11,4))
    -plt.subplot(121)
    -plot_decision_boundary(tree_clf, X, y)
    -plt.title("Decision Tree", fontsize=14)
    -plt.subplot(122)
    -plot_decision_boundary(bag_clf, X, y)
    -plt.title("Decision Trees with Bagging", fontsize=14)
    -save_fig("baggingtree")
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - -









    -

    Making your own Bootstrap: Changing the Level of the Decision Tree

    - -

    Let us bring up our good old boostrap example from the linear regression lectures. We change the linerar regression algorithm with -a decision tree wth different depths and perform a bootstrap aggregate (in this case we perform as many bootstraps as data points \( n \)). -

    - - -
    -
    -
    -
    -
    -
    import matplotlib.pyplot as plt
    -import numpy as np
    -from sklearn.model_selection import train_test_split
    -from sklearn.pipeline import make_pipeline
    -from sklearn.utils import resample
    -from sklearn.tree import DecisionTreeRegressor
    -
    -n = 100
    -n_boostraps = 100
    -maxdepth = 8
    -
    -# Make data set.
    -x = np.linspace(-3, 3, n).reshape(-1, 1)
    -y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)
    -error = np.zeros(maxdepth)
    -bias = np.zeros(maxdepth)
    -variance = np.zeros(maxdepth)
    -polydegree = np.zeros(maxdepth)
    -X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
    -
    -from sklearn.preprocessing import StandardScaler
    -scaler = StandardScaler()
    -scaler.fit(X_train)
    -X_train_scaled = scaler.transform(X_train)
    -X_test_scaled = scaler.transform(X_test)
    -
    -# we produce a simple tree first as benchmark
    -simpletree = DecisionTreeRegressor(max_depth=3) 
    -simpletree.fit(X_train_scaled, y_train)
    -simpleprediction = simpletree.predict(X_test_scaled)
    -for degree in range(1,maxdepth):
    -    model = DecisionTreeRegressor(max_depth=degree) 
    -    y_pred = np.empty((y_test.shape[0], n_boostraps))
    -    for i in range(n_boostraps):
    -        x_, y_ = resample(X_train_scaled, y_train)
    -        model.fit(x_, y_)
    -        y_pred[:, i] = model.predict(X_test_scaled)#.ravel()
    -
    -    polydegree[degree] = degree
    -    error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )
    -    bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )
    -    variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) )
    -    print('Polynomial degree:', degree)
    -    print('Error:', error[degree])
    -    print('Bias^2:', bias[degree])
    -    print('Var:', variance[degree])
    -    print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree]))
    - 
    -mse_simpletree= np.mean( np.mean((y_test - simpleprediction)**2)
    -print(mse_simpletree)
    -plt.xlim(1,maxdepth)
    -plt.plot(polydegree, error, label='MSE')
    -plt.plot(polydegree, bias, label='bias')
    -plt.plot(polydegree, variance, label='Variance')
    -plt.legend()
    -save_fig("baggingboot")
    -plt.show()
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -









    Why Voting?

    @@ -2821,6 +2327,136 @@ voting_clf.fit(X_train, y_train)
    +









    +

    Bagging

    + +

    The plain decision trees suffer from high +variance. This means that if we split the training data into two parts +at random, and fit a decision tree to both halves, the results that we +get could be quite different. In contrast, a procedure with low +variance will yield similar results if applied repeatedly to distinct +data sets; linear regression tends to have low variance, if the ratio +of \( n \) to \( p \) is moderately large. +

    + +

    Bootstrap aggregation, or just bagging, is a +general-purpose procedure for reducing the variance of a statistical +learning method. +

    + +









    +

    More bagging

    + +

    Bagging typically results in improved accuracy +over prediction using a single tree. Unfortunately, however, it can be +difficult to interpret the resulting model. Recall that one of the +advantages of decision trees is the attractive and easily interpreted +diagram that results. +

    + +

    However, when we bag a large number of trees, it is no longer +possible to represent the resulting statistical learning procedure +using a single tree, and it is no longer clear which variables are +most important to the procedure. Thus, bagging improves prediction +accuracy at the expense of interpretability. Although the collection +of bagged trees is much more difficult to interpret than a single +tree, one can obtain an overall summary of the importance of each +predictor using the MSE (for bagging regression trees) or the Gini +index (for bagging classification trees). In the case of bagging +regression trees, we can record the total amount that the MSE is +decreased due to splits over a given predictor, averaged over all \( B \) possible +trees. A large value indicates an important predictor. Similarly, in +the context of bagging classification trees, we can add up the total +amount that the Gini index is decreased by splits over a given +predictor, averaged over all \( B \) trees. +

    + +









    +

    Making your own Bootstrap: Changing the Level of the Decision Tree

    + +

    Let us bring up our good old boostrap example from the linear regression lectures. We change the linerar regression algorithm with +a decision tree wth different depths and perform a bootstrap aggregate (in this case we perform as many bootstraps as data points \( n \)). +

    + + +
    +
    +
    +
    +
    +
    import matplotlib.pyplot as plt
    +import numpy as np
    +from sklearn.model_selection import train_test_split
    +from sklearn.pipeline import make_pipeline
    +from sklearn.utils import resample
    +from sklearn.tree import DecisionTreeRegressor
    +
    +n = 100
    +n_boostraps = 100
    +maxdepth = 8
    +
    +# Make data set.
    +x = np.linspace(-3, 3, n).reshape(-1, 1)
    +y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)
    +error = np.zeros(maxdepth)
    +bias = np.zeros(maxdepth)
    +variance = np.zeros(maxdepth)
    +polydegree = np.zeros(maxdepth)
    +X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
    +
    +from sklearn.preprocessing import StandardScaler
    +scaler = StandardScaler()
    +scaler.fit(X_train)
    +X_train_scaled = scaler.transform(X_train)
    +X_test_scaled = scaler.transform(X_test)
    +
    +# we produce a simple tree first as benchmark
    +simpletree = DecisionTreeRegressor(max_depth=3) 
    +simpletree.fit(X_train_scaled, y_train)
    +simpleprediction = simpletree.predict(X_test_scaled)
    +for degree in range(1,maxdepth):
    +    model = DecisionTreeRegressor(max_depth=degree) 
    +    y_pred = np.empty((y_test.shape[0], n_boostraps))
    +    for i in range(n_boostraps):
    +        x_, y_ = resample(X_train_scaled, y_train)
    +        model.fit(x_, y_)
    +        y_pred[:, i] = model.predict(X_test_scaled)#.ravel()
    +
    +    polydegree[degree] = degree
    +    error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )
    +    bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )
    +    variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) )
    +    print('Polynomial degree:', degree)
    +    print('Error:', error[degree])
    +    print('Bias^2:', bias[degree])
    +    print('Var:', variance[degree])
    +    print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree]))
    + 
    +mse_simpletree= np.mean( np.mean((y_test - simpleprediction)**2)
    +print(mse_simpletree)
    +plt.xlim(1,maxdepth)
    +plt.plot(polydegree, error, label='MSE')
    +plt.plot(polydegree, bias, label='bias')
    +plt.plot(polydegree, variance, label='Variance')
    +plt.legend()
    +save_fig("baggingboot")
    +plt.show()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +









    Random forests

    @@ -2905,19 +2541,14 @@ cancer = load_breast_cancer() X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0) print(X_train.shape) print(X_test.shape) +#define methods # Logistic Regression logreg = LogisticRegression(solver='lbfgs') -logreg.fit(X_train, y_train) -print("Test set accuracy with Logistic Regression: {:.2f}".format(logreg.score(X_test,y_test))) # Support vector machine svm = SVC(gamma='auto', C=100) -svm.fit(X_train, y_train) -print("Test set accuracy with SVM: {:.2f}".format(svm.score(X_test,y_test))) # Decision Trees deep_tree_clf = DecisionTreeClassifier(max_depth=None) -deep_tree_clf.fit(X_train, y_train) -print("Test set accuracy with Decision Trees: {:.2f}".format(deep_tree_clf.score(X_test,y_test))) -#now scale the data +#Scale the data from sklearn.preprocessing import StandardScaler scaler = StandardScaler() scaler.fit(X_train) diff --git a/doc/pub/week44/ipynb/Datafiles/cancer.dot b/doc/pub/week44/ipynb/Datafiles/cancer.dot index c000d8c4c..75af04abe 100644 --- a/doc/pub/week44/ipynb/Datafiles/cancer.dot +++ b/doc/pub/week44/ipynb/Datafiles/cancer.dot @@ -1,22 +1,22 @@ digraph Tree { -node [shape=box, style="filled, rounded", color="black", fontname=helvetica] ; -edge [fontname=helvetica] ; +node [shape=box, style="filled, rounded", color="black", fontname="helvetica"] ; +edge [fontname="helvetica"] ; 0 [label="worst perimeter <= 106.05\ngini = 0.465\nsamples = 426\nvalue = [[269, 157]\n[157, 269]]", fillcolor="#fefbf9"] ; 1 [label="worst concave points <= 0.159\ngini = 0.067\nsamples = 259\nvalue = [[250, 9]\n[9, 250]]", fillcolor="#e99355"] ; 0 -> 1 [labeldistance=2.5, labelangle=45, headlabel="True"] ; 2 [label="worst concave points <= 0.135\ngini = 0.031\nsamples = 253\nvalue = [[249, 4]\n[4, 249]]", fillcolor="#e78946"] ; 1 -> 2 ; -3 [label="radius error <= 0.643\ngini = 0.008\nsamples = 242\nvalue = [[241, 1]\n[1, 241]]", fillcolor="#e5833c"] ; +3 [label="area error <= 48.975\ngini = 0.008\nsamples = 242\nvalue = [[241, 1]\n[1, 241]]", fillcolor="#e5833c"] ; 2 -> 3 ; 4 [label="gini = 0.0\nsamples = 239\nvalue = [[239, 0]\n[0, 239]]", fillcolor="#e58139"] ; 3 -> 4 ; -5 [label="concavity error <= 0.017\ngini = 0.444\nsamples = 3\nvalue = [[2, 1]\n[1, 2]]", fillcolor="#fdf6f0"] ; +5 [label="perimeter error <= 4.249\ngini = 0.444\nsamples = 3\nvalue = [[2, 1]\n[1, 2]]", fillcolor="#fdf6f0"] ; 3 -> 5 ; 6 [label="gini = 0.0\nsamples = 1\nvalue = [[0, 1]\n[1, 0]]", fillcolor="#e58139"] ; 5 -> 6 ; 7 [label="gini = 0.0\nsamples = 2\nvalue = [[2, 0]\n[0, 2]]", fillcolor="#e58139"] ; 5 -> 7 ; -8 [label="worst texture <= 29.455\ngini = 0.397\nsamples = 11\nvalue = [[8, 3]\n[3, 8]]", fillcolor="#fae9dd"] ; +8 [label="mean texture <= 20.84\ngini = 0.397\nsamples = 11\nvalue = [[8, 3]\n[3, 8]]", fillcolor="#fae9dd"] ; 2 -> 8 ; 9 [label="gini = 0.0\nsamples = 8\nvalue = [[8, 0]\n[0, 8]]", fillcolor="#e58139"] ; 8 -> 9 ; @@ -48,10 +48,10 @@ edge [fontname=helvetica] ; 21 -> 22 ; 23 [label="gini = 0.0\nsamples = 6\nvalue = [[6, 0]\n[0, 6]]", fillcolor="#e58139"] ; 21 -> 23 ; -24 [label="fractal dimension error <= 0.013\ngini = 0.015\nsamples = 136\nvalue = [[1, 135]\n[135, 1]]", fillcolor="#e6853f"] ; +24 [label="mean smoothness <= 0.079\ngini = 0.015\nsamples = 136\nvalue = [[1, 135]\n[135, 1]]", fillcolor="#e6853f"] ; 20 -> 24 ; -25 [label="gini = 0.0\nsamples = 135\nvalue = [[0, 135]\n[135, 0]]", fillcolor="#e58139"] ; +25 [label="gini = 0.0\nsamples = 1\nvalue = [[1, 0]\n[0, 1]]", fillcolor="#e58139"] ; 24 -> 25 ; -26 [label="gini = 0.0\nsamples = 1\nvalue = [[1, 0]\n[0, 1]]", fillcolor="#e58139"] ; +26 [label="gini = 0.0\nsamples = 135\nvalue = [[0, 135]\n[135, 0]]", fillcolor="#e58139"] ; 24 -> 26 ; } \ No newline at end of file diff --git a/doc/pub/week44/ipynb/Datafiles/cancer.png b/doc/pub/week44/ipynb/Datafiles/cancer.png index 5f003c0bb..c0f1f7548 100644 Binary files a/doc/pub/week44/ipynb/Datafiles/cancer.png and b/doc/pub/week44/ipynb/Datafiles/cancer.png differ diff --git a/doc/pub/week44/ipynb/Datafiles/moons.dot b/doc/pub/week44/ipynb/Datafiles/moons.dot index 05d91c44c..b06d0a543 100644 --- a/doc/pub/week44/ipynb/Datafiles/moons.dot +++ b/doc/pub/week44/ipynb/Datafiles/moons.dot @@ -1,6 +1,6 @@ digraph Tree { -node [shape=box, style="filled, rounded", color="black", fontname=helvetica] ; -edge [fontname=helvetica] ; +node [shape=box, style="filled, rounded", color="black", fontname="helvetica"] ; +edge [fontname="helvetica"] ; 0 [label="X[1] <= 0.115\ngini = 0.5\nsamples = 75\nvalue = [37, 38]", fillcolor="#fafcfe"] ; 1 [label="X[0] <= -0.686\ngini = 0.225\nsamples = 31\nvalue = [4, 27]", fillcolor="#56ace9"] ; 0 -> 1 [labeldistance=2.5, labelangle=45, headlabel="True"] ; diff --git a/doc/pub/week44/ipynb/Datafiles/ride.dot b/doc/pub/week44/ipynb/Datafiles/ride.dot index b9d720cda..4e3b65b18 100644 --- a/doc/pub/week44/ipynb/Datafiles/ride.dot +++ b/doc/pub/week44/ipynb/Datafiles/ride.dot @@ -1,6 +1,6 @@ digraph Tree { -node [shape=box, style="filled, rounded", color="black", fontname=helvetica] ; -edge [fontname=helvetica] ; +node [shape=box, style="filled, rounded", color="black", fontname="helvetica"] ; +edge [fontname="helvetica"] ; 0 [label="X[9] <= 0.5\ngini = 0.48\nsamples = 15\nvalue = [4, 10, 1]", fillcolor="#93f1ba"] ; 1 [label="X[1] <= 0.5\ngini = 0.408\nsamples = 14\nvalue = [4, 10, 0]", fillcolor="#88efb3"] ; 0 -> 1 [labeldistance=2.5, labelangle=45, headlabel="True"] ; diff --git a/doc/pub/week44/ipynb/Results/FigureFiles/baggingboot.png b/doc/pub/week44/ipynb/Results/FigureFiles/baggingboot.png index d1e3e934f..512a5a20f 100644 Binary files a/doc/pub/week44/ipynb/Results/FigureFiles/baggingboot.png and b/doc/pub/week44/ipynb/Results/FigureFiles/baggingboot.png differ diff --git a/doc/pub/week44/ipynb/Results/FigureFiles/baggingtree.png b/doc/pub/week44/ipynb/Results/FigureFiles/baggingtree.png index 5c83b6226..29aa92b46 100644 Binary files a/doc/pub/week44/ipynb/Results/FigureFiles/baggingtree.png and b/doc/pub/week44/ipynb/Results/FigureFiles/baggingtree.png differ diff --git a/doc/pub/week44/ipynb/Results/FigureFiles/votingsimple.png b/doc/pub/week44/ipynb/Results/FigureFiles/votingsimple.png index 7fa095803..7ba47edbc 100644 Binary files a/doc/pub/week44/ipynb/Results/FigureFiles/votingsimple.png and b/doc/pub/week44/ipynb/Results/FigureFiles/votingsimple.png differ diff --git a/doc/pub/week44/ipynb/ipynb-week44-src.tar.gz b/doc/pub/week44/ipynb/ipynb-week44-src.tar.gz index ede2ebeca..d1a5e31f5 100644 Binary files a/doc/pub/week44/ipynb/ipynb-week44-src.tar.gz and b/doc/pub/week44/ipynb/ipynb-week44-src.tar.gz differ diff --git a/doc/pub/week44/ipynb/week44.ipynb b/doc/pub/week44/ipynb/week44.ipynb index 51a466001..23dd53ac1 100644 --- a/doc/pub/week44/ipynb/week44.ipynb +++ b/doc/pub/week44/ipynb/week44.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "5c948236", + "id": "4c7a5155", "metadata": { "editable": true }, @@ -14,7 +14,7 @@ }, { "cell_type": "markdown", - "id": "2e712ddb", + "id": "4ac9d0cb", "metadata": { "editable": true }, @@ -29,7 +29,7 @@ }, { "cell_type": "markdown", - "id": "ce77630c", + "id": "e0a4b5a7", "metadata": { "editable": true }, @@ -51,7 +51,7 @@ }, { "cell_type": "markdown", - "id": "fbc49098", + "id": "3d46e4eb", "metadata": { "editable": true }, @@ -69,7 +69,7 @@ }, { "cell_type": "markdown", - "id": "99be5592", + "id": "b7dc5b6f", "metadata": { "editable": true }, @@ -83,7 +83,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "321af0c0", + "id": "b2d6c39b", "metadata": { "collapsed": false, "editable": true @@ -199,7 +199,7 @@ }, { "cell_type": "markdown", - "id": "b8f4d755", + "id": "741b7207", "metadata": { "editable": true }, @@ -230,7 +230,7 @@ }, { "cell_type": "markdown", - "id": "0477ca95", + "id": "7c2e0aec", "metadata": { "editable": true }, @@ -250,7 +250,7 @@ }, { "cell_type": "markdown", - "id": "96526d34", + "id": "d6ebe102", "metadata": { "editable": true }, @@ -264,7 +264,7 @@ }, { "cell_type": "markdown", - "id": "f1d105d9", + "id": "d9789025", "metadata": { "editable": true }, @@ -277,7 +277,7 @@ }, { "cell_type": "markdown", - "id": "6def974b", + "id": "b21ba8d6", "metadata": { "editable": true }, @@ -295,7 +295,7 @@ }, { "cell_type": "markdown", - "id": "4cee402a", + "id": "84826586", "metadata": { "editable": true }, @@ -318,7 +318,7 @@ }, { "cell_type": "markdown", - "id": "b0ae8c62", + "id": "b7b60eb0", "metadata": { "editable": true }, @@ -341,7 +341,7 @@ }, { "cell_type": "markdown", - "id": "5cc2e727", + "id": "c2729e10", "metadata": { "editable": true }, @@ -352,7 +352,7 @@ { "cell_type": "code", "execution_count": 2, - "id": "2fa9aac3", + "id": "7879427c", "metadata": { "collapsed": false, "editable": true @@ -451,7 +451,7 @@ }, { "cell_type": "markdown", - "id": "2bb0ea43", + "id": "64a60119", "metadata": { "editable": true }, @@ -473,7 +473,7 @@ }, { "cell_type": "markdown", - "id": "f7fd9801", + "id": "aef71098", "metadata": { "editable": true }, @@ -485,7 +485,7 @@ }, { "cell_type": "markdown", - "id": "77d8e179", + "id": "c1819a6f", "metadata": { "editable": true }, @@ -496,7 +496,7 @@ }, { "cell_type": "markdown", - "id": "90b48cd5", + "id": "b2aa9527", "metadata": { "editable": true }, @@ -518,7 +518,7 @@ }, { "cell_type": "markdown", - "id": "1c1ee9be", + "id": "3bd07e22", "metadata": { "editable": true }, @@ -531,7 +531,7 @@ }, { "cell_type": "markdown", - "id": "b3540862", + "id": "d087d425", "metadata": { "editable": true }, @@ -543,7 +543,7 @@ }, { "cell_type": "markdown", - "id": "412be88b", + "id": "6dddbbe4", "metadata": { "editable": true }, @@ -553,7 +553,7 @@ }, { "cell_type": "markdown", - "id": "26943d25", + "id": "a53486a7", "metadata": { "editable": true }, @@ -565,7 +565,7 @@ }, { "cell_type": "markdown", - "id": "238ef636", + "id": "ed5534f3", "metadata": { "editable": true }, @@ -575,7 +575,7 @@ }, { "cell_type": "markdown", - "id": "7d1f6683", + "id": "bfbb12ea", "metadata": { "editable": true }, @@ -587,7 +587,7 @@ }, { "cell_type": "markdown", - "id": "ed814361", + "id": "254338e6", "metadata": { "editable": true }, @@ -620,7 +620,7 @@ }, { "cell_type": "markdown", - "id": "b0389394", + "id": "57be982b", "metadata": { "editable": true }, @@ -644,7 +644,7 @@ }, { "cell_type": "markdown", - "id": "d7428112", + "id": "9fbb4348", "metadata": { "editable": true }, @@ -656,7 +656,7 @@ }, { "cell_type": "markdown", - "id": "365f30ff", + "id": "bd62b866", "metadata": { "editable": true }, @@ -668,7 +668,7 @@ }, { "cell_type": "markdown", - "id": "ba0684e8", + "id": "7d8fbd88", "metadata": { "editable": true }, @@ -696,7 +696,7 @@ }, { "cell_type": "markdown", - "id": "61e97043", + "id": "4ff5152f", "metadata": { "editable": true }, @@ -722,7 +722,7 @@ }, { "cell_type": "markdown", - "id": "7970c5bc", + "id": "1a23ea40", "metadata": { "editable": true }, @@ -745,7 +745,7 @@ }, { "cell_type": "markdown", - "id": "9d478b04", + "id": "a80b8a59", "metadata": { "editable": true }, @@ -772,7 +772,7 @@ }, { "cell_type": "markdown", - "id": "d11cb0d7", + "id": "bb0ced76", "metadata": { "editable": true }, @@ -791,7 +791,7 @@ }, { "cell_type": "markdown", - "id": "46022c8c", + "id": "087aecb8", "metadata": { "editable": true }, @@ -803,7 +803,7 @@ }, { "cell_type": "markdown", - "id": "0166e45a", + "id": "b1dfaa5d", "metadata": { "editable": true }, @@ -816,7 +816,7 @@ }, { "cell_type": "markdown", - "id": "f65fada9", + "id": "5d9e1c22", "metadata": { "editable": true }, @@ -828,7 +828,7 @@ }, { "cell_type": "markdown", - "id": "078674e5", + "id": "834faf0f", "metadata": { "editable": true }, @@ -838,7 +838,7 @@ }, { "cell_type": "markdown", - "id": "a1ac2fe9", + "id": "9bd81347", "metadata": { "editable": true }, @@ -850,7 +850,7 @@ }, { "cell_type": "markdown", - "id": "1a4f2f62", + "id": "017dd22e", "metadata": { "editable": true }, @@ -860,7 +860,7 @@ }, { "cell_type": "markdown", - "id": "00f8b061", + "id": "cd04c09c", "metadata": { "editable": true }, @@ -872,7 +872,7 @@ }, { "cell_type": "markdown", - "id": "360ff461", + "id": "5cf9df71", "metadata": { "editable": true }, @@ -883,7 +883,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "35297e26", + "id": "53b53796", "metadata": { "collapsed": false, "editable": true @@ -927,7 +927,7 @@ }, { "cell_type": "markdown", - "id": "cb145416", + "id": "5ddb1789", "metadata": { "editable": true }, @@ -938,7 +938,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "6dc54743", + "id": "65092d3a", "metadata": { "collapsed": false, "editable": true @@ -973,7 +973,7 @@ }, { "cell_type": "markdown", - "id": "af20ea2d", + "id": "f014d974", "metadata": { "editable": true }, @@ -986,7 +986,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "0c09dfdf", + "id": "43829fb1", "metadata": { "collapsed": false, "editable": true @@ -1004,7 +1004,7 @@ }, { "cell_type": "markdown", - "id": "7b3c3bcb", + "id": "3602edc7", "metadata": { "editable": true }, @@ -1018,7 +1018,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "fb0cc872", + "id": "db8f56d7", "metadata": { "collapsed": false, "editable": true @@ -1037,7 +1037,7 @@ }, { "cell_type": "markdown", - "id": "8d8d8d82", + "id": "79548471", "metadata": { "editable": true }, @@ -1057,7 +1057,7 @@ }, { "cell_type": "markdown", - "id": "306a610b", + "id": "d0b42d59", "metadata": { "editable": true }, @@ -1074,7 +1074,7 @@ }, { "cell_type": "markdown", - "id": "39ece8a3", + "id": "b5a14a97", "metadata": { "editable": true }, @@ -1086,7 +1086,7 @@ }, { "cell_type": "markdown", - "id": "4bdf6600", + "id": "9a774778", "metadata": { "editable": true }, @@ -1103,7 +1103,7 @@ }, { "cell_type": "markdown", - "id": "aef73f0c", + "id": "be8b5c64", "metadata": { "editable": true }, @@ -1116,7 +1116,7 @@ }, { "cell_type": "markdown", - "id": "31810fc0", + "id": "84b496a4", "metadata": { "editable": true }, @@ -1128,7 +1128,7 @@ }, { "cell_type": "markdown", - "id": "d08aca8f", + "id": "10223626", "metadata": { "editable": true }, @@ -1138,7 +1138,7 @@ }, { "cell_type": "markdown", - "id": "ddd28bbd", + "id": "bdc0ba64", "metadata": { "editable": true }, @@ -1150,7 +1150,7 @@ }, { "cell_type": "markdown", - "id": "a12364d0", + "id": "8fbc3414", "metadata": { "editable": true }, @@ -1160,7 +1160,7 @@ }, { "cell_type": "markdown", - "id": "4946666e", + "id": "d4d2fcd8", "metadata": { "editable": true }, @@ -1172,7 +1172,7 @@ }, { "cell_type": "markdown", - "id": "b4d030a4", + "id": "ce399959", "metadata": { "editable": true }, @@ -1185,7 +1185,7 @@ }, { "cell_type": "markdown", - "id": "c7b6da02", + "id": "6faf3fd5", "metadata": { "editable": true }, @@ -1200,7 +1200,7 @@ }, { "cell_type": "markdown", - "id": "f6aa3363", + "id": "f309b16f", "metadata": { "editable": true }, @@ -1226,7 +1226,7 @@ }, { "cell_type": "markdown", - "id": "e7a581e8", + "id": "186e0731", "metadata": { "editable": true }, @@ -1254,7 +1254,7 @@ }, { "cell_type": "markdown", - "id": "13b84c42", + "id": "6c94c555", "metadata": { "editable": true }, @@ -1271,7 +1271,7 @@ }, { "cell_type": "markdown", - "id": "7ae7c7ea", + "id": "e606b67d", "metadata": { "editable": true }, @@ -1285,7 +1285,7 @@ }, { "cell_type": "markdown", - "id": "fc8a3e67", + "id": "5c656c54", "metadata": { "editable": true }, @@ -1301,7 +1301,7 @@ }, { "cell_type": "markdown", - "id": "53850a13", + "id": "d6a5f46c", "metadata": { "editable": true }, @@ -1312,7 +1312,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "4be4a43d", + "id": "68650507", "metadata": { "collapsed": false, "editable": true @@ -1390,7 +1390,7 @@ }, { "cell_type": "markdown", - "id": "90e95d49", + "id": "994250a4", "metadata": { "editable": true }, @@ -1434,7 +1434,7 @@ }, { "cell_type": "markdown", - "id": "4e8a69a8", + "id": "dc7f6fc5", "metadata": { "editable": true }, @@ -1445,7 +1445,7 @@ { "cell_type": "code", "execution_count": 8, - "id": "3f6340fc", + "id": "121d45cf", "metadata": { "collapsed": false, "editable": true @@ -1523,7 +1523,7 @@ }, { "cell_type": "markdown", - "id": "9a18ffbd", + "id": "9c174840", "metadata": { "editable": true }, @@ -1541,7 +1541,7 @@ { "cell_type": "code", "execution_count": 9, - "id": "dc01ad75", + "id": "b077c4d1", "metadata": { "collapsed": false, "editable": true @@ -1612,18 +1612,18 @@ }, { "cell_type": "markdown", - "id": "a3d846cd", + "id": "fb1a615b", "metadata": { "editable": true }, "source": [ - "## Another example, the moons again" + "## Another example, the moons" ] }, { "cell_type": "code", "execution_count": 10, - "id": "f41353c4", + "id": "7cdd567c", "metadata": { "collapsed": false, "editable": true @@ -1698,7 +1698,7 @@ }, { "cell_type": "markdown", - "id": "0d75cb36", + "id": "c74c9eaf", "metadata": { "editable": true }, @@ -1709,7 +1709,7 @@ { "cell_type": "code", "execution_count": 11, - "id": "270db370", + "id": "4f3c7805", "metadata": { "collapsed": false, "editable": true @@ -1740,7 +1740,7 @@ }, { "cell_type": "markdown", - "id": "944dd7a5", + "id": "5eeaf397", "metadata": { "editable": true }, @@ -1751,7 +1751,7 @@ { "cell_type": "code", "execution_count": 12, - "id": "6f9de8a4", + "id": "cd9e1562", "metadata": { "collapsed": false, "editable": true @@ -1769,7 +1769,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "e8c9f095", + "id": "1f11a97f", "metadata": { "collapsed": false, "editable": true @@ -1784,7 +1784,7 @@ }, { "cell_type": "markdown", - "id": "67f0f549", + "id": "c39125c9", "metadata": { "editable": true }, @@ -1795,7 +1795,7 @@ { "cell_type": "code", "execution_count": 14, - "id": "4587efe8", + "id": "f999098e", "metadata": { "collapsed": false, "editable": true @@ -1845,7 +1845,7 @@ { "cell_type": "code", "execution_count": 15, - "id": "5e036165", + "id": "5c31d316", "metadata": { "collapsed": false, "editable": true @@ -1884,7 +1884,7 @@ }, { "cell_type": "markdown", - "id": "08cb1573", + "id": "a72112df", "metadata": { "editable": true }, @@ -1908,7 +1908,7 @@ }, { "cell_type": "markdown", - "id": "44b5f52e", + "id": "3a11c269", "metadata": { "editable": true }, @@ -1936,7 +1936,7 @@ }, { "cell_type": "markdown", - "id": "daf142b0", + "id": "1fdc0348", "metadata": { "editable": true }, @@ -1967,7 +1967,7 @@ }, { "cell_type": "markdown", - "id": "038cda56", + "id": "9e124da2", "metadata": { "editable": true }, @@ -1983,61 +1983,121 @@ }, { "cell_type": "markdown", - "id": "d6881d19", + "id": "1f9afd64", "metadata": { "editable": true }, "source": [ - "## Bagging\n", + "## Why Voting?\n", "\n", - "The **plain** decision trees suffer from high\n", - "variance. This means that if we split the training data into two parts\n", - "at random, and fit a decision tree to both halves, the results that we\n", - "get could be quite different. In contrast, a procedure with low\n", - "variance will yield similar results if applied repeatedly to distinct\n", - "data sets; linear regression tends to have low variance, if the ratio\n", - "of $n$ to $p$ is moderately large. \n", + "The idea behind boosting, and voting as well can be phrased as follows:\n", + "**Can a group of people somehow arrive at highly\n", + "reasoned decisions, despite the weak judgement of the individual\n", + "members?**\n", "\n", - "**Bootstrap aggregation**, or just **bagging**, is a\n", - "general-purpose procedure for reducing the variance of a statistical\n", - "learning method." + "The aim is to create a good classifier by combining several weak classifiers.\n", + "**A weak classifier is a classifier which is able to produce results that are only slightly better than guessing at random.**\n", + "\n", + "The basic approach is to apply repeatedly (in boosting this is done in an iterative way) a weak classifier to modifications of the data.\n", + "In voting we simply apply the law of large numbers while in boosting we give more weight to misclassified data in\n", + "each iteration. \n", + "\n", + "Decision trees play an important role as our weak classifier. They serve as the basic method." ] }, { "cell_type": "markdown", - "id": "6ca7617f", + "id": "72766be2", "metadata": { "editable": true }, "source": [ - "## More bagging\n", + "## Tossing coins\n", "\n", - "Bagging typically results in improved accuracy\n", - "over prediction using a single tree. Unfortunately, however, it can be\n", - "difficult to interpret the resulting model. Recall that one of the\n", - "advantages of decision trees is the attractive and easily interpreted\n", - "diagram that results.\n", + "The simplest case is a so-called voting ensemble. To illustrate this,\n", + "think of yourself tossing coins with a biased outcome of 51 per cent\n", + "for heads and 49% for tails. With only few tosses,\n", + "you may not clearly see this distribution for heads and tails. However, after some\n", + "thousands of tosses, there will be a clear majority of heads. With 2000 tosses\n", + "you should see approximately 1020 heads and 980 tails.\n", "\n", - "However, when we bag a large number of trees, it is no longer\n", - "possible to represent the resulting statistical learning procedure\n", - "using a single tree, and it is no longer clear which variables are\n", - "most important to the procedure. Thus, bagging improves prediction\n", - "accuracy at the expense of interpretability. Although the collection\n", - "of bagged trees is much more difficult to interpret than a single\n", - "tree, one can obtain an overall summary of the importance of each\n", - "predictor using the MSE (for bagging regression trees) or the Gini\n", - "index (for bagging classification trees). In the case of bagging\n", - "regression trees, we can record the total amount that the MSE is\n", - "decreased due to splits over a given predictor, averaged over all $B$ possible\n", - "trees. A large value indicates an important predictor. Similarly, in\n", - "the context of bagging classification trees, we can add up the total\n", - "amount that the Gini index is decreased by splits over a given\n", - "predictor, averaged over all $B$ trees." + "We can then state that the outcome is a clear majority of heads. If\n", + "you do this ten thousand times, it is easy to see that there is a 97%\n", + "likelihood of a majority of heads.\n", + "\n", + "Another example would be to collect all polls before an\n", + "election. Different polls may show different likelihoods for a\n", + "candidate winning with say a majority of the popular vote. The majority vote\n", + "would then consist in many polls indicating that this candidate will\n", + "actually win.\n", + "\n", + "The example here shows how we can implement the coin tossing case,\n", + "clealry demostrating that after some tosses we see the [law of large](https://en.wikipedia.org/wiki/Law_of_large_numbers)\n", + "numbers kicking in." ] }, { "cell_type": "markdown", - "id": "ccab6c19", + "id": "31fd7020", + "metadata": { + "editable": true + }, + "source": [ + "## Standard imports first" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "8f3556b4", + "metadata": { + "collapsed": false, + "editable": true + }, + "outputs": [], + "source": [ + "# Common imports\n", + "from IPython.display import Image \n", + "from pydot import graph_from_dot_data\n", + "import pandas as pd\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "from sklearn.tree import DecisionTreeClassifier\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.tree import export_graphviz\n", + "from sklearn.preprocessing import StandardScaler, OneHotEncoder\n", + "from sklearn.compose import ColumnTransformer\n", + "from IPython.display import Image \n", + "from pydot import graph_from_dot_data\n", + "import os\n", + "\n", + "# Where to save the figures and data files\n", + "PROJECT_ROOT_DIR = \"Results\"\n", + "FIGURE_ID = \"Results/FigureFiles\"\n", + "DATA_ID = \"DataFiles/\"\n", + "\n", + "if not os.path.exists(PROJECT_ROOT_DIR):\n", + " os.mkdir(PROJECT_ROOT_DIR)\n", + "\n", + "if not os.path.exists(FIGURE_ID):\n", + " os.makedirs(FIGURE_ID)\n", + "\n", + "if not os.path.exists(DATA_ID):\n", + " os.makedirs(DATA_ID)\n", + "\n", + "def image_path(fig_id):\n", + " return os.path.join(FIGURE_ID, fig_id)\n", + "\n", + "def data_path(dat_id):\n", + " return os.path.join(DATA_ID, dat_id)\n", + "\n", + "def save_fig(fig_id):\n", + " plt.savefig(image_path(fig_id) + \".png\", format='png')" + ] + }, + { + "cell_type": "markdown", + "id": "7e4f5d08", "metadata": { "editable": true }, @@ -2047,14 +2107,24 @@ }, { "cell_type": "code", - "execution_count": 16, - "id": "ee9af3b9", + "execution_count": 17, + "id": "4b2a27f1", "metadata": { "collapsed": false, "editable": true }, "outputs": [], "source": [ + "\n", + "# Common imports\n", + "import numpy as np\n", + "import matplotlib\n", + "import matplotlib.pyplot as plt\n", + "from matplotlib.colors import ListedColormap\n", + "plt.rcParams['axes.labelsize'] = 14\n", + "plt.rcParams['xtick.labelsize'] = 12\n", + "plt.rcParams['ytick.labelsize'] = 12\n", + "\n", "heads_proba = 0.51\n", "coin_tosses = (np.random.rand(10000, 10) < heads_proba).astype(np.int32)\n", "cumulative_heads_ratio = np.cumsum(coin_tosses, axis=0) / np.arange(1, 10001).reshape(-1, 1)\n", @@ -2072,18 +2142,20 @@ }, { "cell_type": "markdown", - "id": "cd895813", + "id": "facdb6a9", "metadata": { "editable": true }, "source": [ - "## Using the Voting Classifier" + "## Using the Voting Classifier\n", + "\n", + "We can use the voting classifier on other data sets, here the exciting binary case of two distinct objects using the make moons functionality of **Scikit-Learn**." ] }, { "cell_type": "code", - "execution_count": 17, - "id": "d5e48af3", + "execution_count": 18, + "id": "c7986569", "metadata": { "collapsed": false, "editable": true @@ -2121,7 +2193,6 @@ "log_clf = LogisticRegression(solver=\"liblinear\", random_state=42)\n", "rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)\n", "svm_clf = SVC(gamma=\"auto\", probability=True, random_state=42)\n", - "\n", "voting_clf = VotingClassifier(\n", " estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],\n", " voting='soft')\n", @@ -2137,18 +2208,18 @@ }, { "cell_type": "markdown", - "id": "c64b5374", + "id": "090cc2cf", "metadata": { "editable": true }, "source": [ - "## Please, not the moons again! Voting and Bagging" + "## Voting and Bagging" ] }, { "cell_type": "code", - "execution_count": 18, - "id": "76d0f2ea", + "execution_count": 19, + "id": "44f30cb2", "metadata": { "collapsed": false, "editable": true @@ -2177,8 +2248,8 @@ }, { "cell_type": "code", - "execution_count": 19, - "id": "7fcccf7d", + "execution_count": 20, + "id": "d28826ab", "metadata": { "collapsed": false, "editable": true @@ -2195,8 +2266,8 @@ }, { "cell_type": "code", - "execution_count": 20, - "id": "e380253c", + "execution_count": 21, + "id": "b02c5322", "metadata": { "collapsed": false, "editable": true @@ -2215,8 +2286,8 @@ }, { "cell_type": "code", - "execution_count": 21, - "id": "f90ec503", + "execution_count": 22, + "id": "d542a2be", "metadata": { "collapsed": false, "editable": true @@ -2233,106 +2304,61 @@ }, { "cell_type": "markdown", - "id": "23aac3ac", + "id": "a7cdad96", "metadata": { "editable": true }, "source": [ - "## Bagging Examples" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "id": "de7988eb", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "from sklearn.ensemble import BaggingClassifier\n", - "from sklearn.tree import DecisionTreeClassifier\n", + "## Bagging\n", "\n", - "bag_clf = BaggingClassifier(\n", - " DecisionTreeClassifier(random_state=42), n_estimators=500,\n", - " max_samples=100, bootstrap=True, n_jobs=-1, random_state=42)\n", - "bag_clf.fit(X_train, y_train)\n", - "y_pred = bag_clf.predict(X_test)" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "id": "6c8ee680", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "from sklearn.metrics import accuracy_score\n", - "print(accuracy_score(y_test, y_pred))" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "id": "6c08a9b3", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "tree_clf = DecisionTreeClassifier(random_state=42)\n", - "tree_clf.fit(X_train, y_train)\n", - "y_pred_tree = tree_clf.predict(X_test)\n", - "print(accuracy_score(y_test, y_pred_tree))" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "id": "a2365657", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "from matplotlib.colors import ListedColormap\n", + "The **plain** decision trees suffer from high\n", + "variance. This means that if we split the training data into two parts\n", + "at random, and fit a decision tree to both halves, the results that we\n", + "get could be quite different. In contrast, a procedure with low\n", + "variance will yield similar results if applied repeatedly to distinct\n", + "data sets; linear regression tends to have low variance, if the ratio\n", + "of $n$ to $p$ is moderately large. \n", "\n", - "def plot_decision_boundary(clf, X, y, axes=[-1.5, 2.5, -1, 1.5], alpha=0.5, contour=True):\n", - " x1s = np.linspace(axes[0], axes[1], 100)\n", - " x2s = np.linspace(axes[2], axes[3], 100)\n", - " x1, x2 = np.meshgrid(x1s, x2s)\n", - " X_new = np.c_[x1.ravel(), x2.ravel()]\n", - " y_pred = clf.predict(X_new).reshape(x1.shape)\n", - " custom_cmap = ListedColormap(['#fafab0','#9898ff','#a0faa0'])\n", - " plt.contourf(x1, x2, y_pred, alpha=0.3, cmap=custom_cmap)\n", - " if contour:\n", - " custom_cmap2 = ListedColormap(['#7d7d58','#4c4c7f','#507d50'])\n", - " plt.contour(x1, x2, y_pred, cmap=custom_cmap2, alpha=0.8)\n", - " plt.plot(X[:, 0][y==0], X[:, 1][y==0], \"yo\", alpha=alpha)\n", - " plt.plot(X[:, 0][y==1], X[:, 1][y==1], \"bs\", alpha=alpha)\n", - " plt.axis(axes)\n", - " plt.xlabel(r\"$x_1$\", fontsize=18)\n", - " plt.ylabel(r\"$x_2$\", fontsize=18, rotation=0)\n", - "plt.figure(figsize=(11,4))\n", - "plt.subplot(121)\n", - "plot_decision_boundary(tree_clf, X, y)\n", - "plt.title(\"Decision Tree\", fontsize=14)\n", - "plt.subplot(122)\n", - "plot_decision_boundary(bag_clf, X, y)\n", - "plt.title(\"Decision Trees with Bagging\", fontsize=14)\n", - "save_fig(\"baggingtree\")\n", - "plt.show()" + "**Bootstrap aggregation**, or just **bagging**, is a\n", + "general-purpose procedure for reducing the variance of a statistical\n", + "learning method." ] }, { "cell_type": "markdown", - "id": "50147ee0", + "id": "96ae19e9", + "metadata": { + "editable": true + }, + "source": [ + "## More bagging\n", + "\n", + "Bagging typically results in improved accuracy\n", + "over prediction using a single tree. Unfortunately, however, it can be\n", + "difficult to interpret the resulting model. Recall that one of the\n", + "advantages of decision trees is the attractive and easily interpreted\n", + "diagram that results.\n", + "\n", + "However, when we bag a large number of trees, it is no longer\n", + "possible to represent the resulting statistical learning procedure\n", + "using a single tree, and it is no longer clear which variables are\n", + "most important to the procedure. Thus, bagging improves prediction\n", + "accuracy at the expense of interpretability. Although the collection\n", + "of bagged trees is much more difficult to interpret than a single\n", + "tree, one can obtain an overall summary of the importance of each\n", + "predictor using the MSE (for bagging regression trees) or the Gini\n", + "index (for bagging classification trees). In the case of bagging\n", + "regression trees, we can record the total amount that the MSE is\n", + "decreased due to splits over a given predictor, averaged over all $B$ possible\n", + "trees. A large value indicates an important predictor. Similarly, in\n", + "the context of bagging classification trees, we can add up the total\n", + "amount that the Gini index is decreased by splits over a given\n", + "predictor, averaged over all $B$ trees." + ] + }, + { + "cell_type": "markdown", + "id": "0b821772", "metadata": { "editable": true }, @@ -2345,8 +2371,8 @@ }, { "cell_type": "code", - "execution_count": 26, - "id": "5c2c80a2", + "execution_count": 23, + "id": "c69ac3f2", "metadata": { "collapsed": false, "editable": true @@ -2415,328 +2441,7 @@ }, { "cell_type": "markdown", - "id": "1178fafb", - "metadata": { - "editable": true - }, - "source": [ - "## Why Voting?\n", - "\n", - "The idea behind boosting, and voting as well can be phrased as follows:\n", - "**Can a group of people somehow arrive at highly\n", - "reasoned decisions, despite the weak judgement of the individual\n", - "members?**\n", - "\n", - "The aim is to create a good classifier by combining several weak classifiers.\n", - "**A weak classifier is a classifier which is able to produce results that are only slightly better than guessing at random.**\n", - "\n", - "The basic approach is to apply repeatedly (in boosting this is done in an iterative way) a weak classifier to modifications of the data.\n", - "In voting we simply apply the law of large numbers while in boosting we give more weight to misclassified data in\n", - "each iteration. \n", - "\n", - "Decision trees play an important role as our weak classifier. They serve as the basic method." - ] - }, - { - "cell_type": "markdown", - "id": "a3a30aa4", - "metadata": { - "editable": true - }, - "source": [ - "## Tossing coins\n", - "\n", - "The simplest case is a so-called voting ensemble. To illustrate this,\n", - "think of yourself tossing coins with a biased outcome of 51 per cent\n", - "for heads and 49% for tails. With only few tosses,\n", - "you may not clearly see this distribution for heads and tails. However, after some\n", - "thousands of tosses, there will be a clear majority of heads. With 2000 tosses\n", - "you should see approximately 1020 heads and 980 tails.\n", - "\n", - "We can then state that the outcome is a clear majority of heads. If\n", - "you do this ten thousand times, it is easy to see that there is a 97%\n", - "likelihood of a majority of heads.\n", - "\n", - "Another example would be to collect all polls before an\n", - "election. Different polls may show different likelihoods for a\n", - "candidate winning with say a majority of the popular vote. The majority vote\n", - "would then consist in many polls indicating that this candidate will\n", - "actually win.\n", - "\n", - "The example here shows how we can implement the coin tossing case,\n", - "clealry demostrating that after some tosses we see the [law of large](https://en.wikipedia.org/wiki/Law_of_large_numbers)\n", - "numbers kicking in." - ] - }, - { - "cell_type": "markdown", - "id": "2fe724f5", - "metadata": { - "editable": true - }, - "source": [ - "## Standard imports first" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "id": "a5ee936a", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "# Common imports\n", - "from IPython.display import Image \n", - "from pydot import graph_from_dot_data\n", - "import pandas as pd\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "from sklearn.tree import DecisionTreeClassifier\n", - "from sklearn.model_selection import train_test_split\n", - "from sklearn.tree import export_graphviz\n", - "from sklearn.preprocessing import StandardScaler, OneHotEncoder\n", - "from sklearn.compose import ColumnTransformer\n", - "from IPython.display import Image \n", - "from pydot import graph_from_dot_data\n", - "import os\n", - "\n", - "# Where to save the figures and data files\n", - "PROJECT_ROOT_DIR = \"Results\"\n", - "FIGURE_ID = \"Results/FigureFiles\"\n", - "DATA_ID = \"DataFiles/\"\n", - "\n", - "if not os.path.exists(PROJECT_ROOT_DIR):\n", - " os.mkdir(PROJECT_ROOT_DIR)\n", - "\n", - "if not os.path.exists(FIGURE_ID):\n", - " os.makedirs(FIGURE_ID)\n", - "\n", - "if not os.path.exists(DATA_ID):\n", - " os.makedirs(DATA_ID)\n", - "\n", - "def image_path(fig_id):\n", - " return os.path.join(FIGURE_ID, fig_id)\n", - "\n", - "def data_path(dat_id):\n", - " return os.path.join(DATA_ID, dat_id)\n", - "\n", - "def save_fig(fig_id):\n", - " plt.savefig(image_path(fig_id) + \".png\", format='png')" - ] - }, - { - "cell_type": "markdown", - "id": "780b0b45", - "metadata": { - "editable": true - }, - "source": [ - "## Simple Voting Example, head or tail" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "id": "2aa03ca6", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "\n", - "# Common imports\n", - "import numpy as np\n", - "import matplotlib\n", - "import matplotlib.pyplot as plt\n", - "from matplotlib.colors import ListedColormap\n", - "plt.rcParams['axes.labelsize'] = 14\n", - "plt.rcParams['xtick.labelsize'] = 12\n", - "plt.rcParams['ytick.labelsize'] = 12\n", - "\n", - "heads_proba = 0.51\n", - "coin_tosses = (np.random.rand(10000, 10) < heads_proba).astype(np.int32)\n", - "cumulative_heads_ratio = np.cumsum(coin_tosses, axis=0) / np.arange(1, 10001).reshape(-1, 1)\n", - "plt.figure(figsize=(8,3.5))\n", - "plt.plot(cumulative_heads_ratio)\n", - "plt.plot([0, 10000], [0.51, 0.51], \"k--\", linewidth=2, label=\"51%\")\n", - "plt.plot([0, 10000], [0.5, 0.5], \"k-\", label=\"50%\")\n", - "plt.xlabel(\"Number of coin tosses\")\n", - "plt.ylabel(\"Heads ratio\")\n", - "plt.legend(loc=\"lower right\")\n", - "plt.axis([0, 10000, 0.42, 0.58])\n", - "save_fig(\"votingsimple\")\n", - "plt.show()" - ] - }, - { - "cell_type": "markdown", - "id": "edaded51", - "metadata": { - "editable": true - }, - "source": [ - "## Using the Voting Classifier\n", - "\n", - "We can use the voting classifier on other data sets, here the exciting binary case of two distinct objects using the make moons functionality of **Scikit-Learn**." - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "id": "ea39ac21", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "from sklearn.model_selection import train_test_split\n", - "from sklearn.datasets import make_moons\n", - "\n", - "X, y = make_moons(n_samples=500, noise=0.30, random_state=42)\n", - "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)\n", - "\n", - "from sklearn.ensemble import RandomForestClassifier\n", - "from sklearn.ensemble import VotingClassifier\n", - "from sklearn.linear_model import LogisticRegression\n", - "from sklearn.svm import SVC\n", - "\n", - "log_clf = LogisticRegression(solver=\"liblinear\", random_state=42)\n", - "rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)\n", - "svm_clf = SVC(gamma=\"auto\", random_state=42)\n", - "\n", - "voting_clf = VotingClassifier(\n", - " estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],\n", - " voting='hard')\n", - "\n", - "voting_clf.fit(X_train, y_train)\n", - "\n", - "from sklearn.metrics import accuracy_score\n", - "\n", - "for clf in (log_clf, rnd_clf, svm_clf, voting_clf):\n", - " clf.fit(X_train, y_train)\n", - " y_pred = clf.predict(X_test)\n", - " print(clf.__class__.__name__, accuracy_score(y_test, y_pred))\n", - "\n", - "log_clf = LogisticRegression(solver=\"liblinear\", random_state=42)\n", - "rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)\n", - "svm_clf = SVC(gamma=\"auto\", probability=True, random_state=42)\n", - "voting_clf = VotingClassifier(\n", - " estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],\n", - " voting='soft')\n", - "voting_clf.fit(X_train, y_train)\n", - "\n", - "from sklearn.metrics import accuracy_score\n", - "\n", - "for clf in (log_clf, rnd_clf, svm_clf, voting_clf):\n", - " clf.fit(X_train, y_train)\n", - " y_pred = clf.predict(X_test)\n", - " print(clf.__class__.__name__, accuracy_score(y_test, y_pred))" - ] - }, - { - "cell_type": "markdown", - "id": "2c612ac2", - "metadata": { - "editable": true - }, - "source": [ - "## Voting and Bagging" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "id": "d700c338", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "from sklearn.model_selection import train_test_split\n", - "from sklearn.datasets import make_moons\n", - "\n", - "X, y = make_moons(n_samples=500, noise=0.30, random_state=42)\n", - "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)\n", - "from sklearn.ensemble import RandomForestClassifier\n", - "from sklearn.ensemble import VotingClassifier\n", - "from sklearn.linear_model import LogisticRegression\n", - "from sklearn.svm import SVC\n", - "\n", - "log_clf = LogisticRegression(random_state=42)\n", - "rnd_clf = RandomForestClassifier(random_state=42)\n", - "svm_clf = SVC(random_state=42)\n", - "\n", - "voting_clf = VotingClassifier(\n", - " estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],\n", - " voting='hard')\n", - "voting_clf.fit(X_train, y_train)" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "id": "9a5ddf88", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "from sklearn.metrics import accuracy_score\n", - "\n", - "for clf in (log_clf, rnd_clf, svm_clf, voting_clf):\n", - " clf.fit(X_train, y_train)\n", - " y_pred = clf.predict(X_test)\n", - " print(clf.__class__.__name__, accuracy_score(y_test, y_pred))" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "id": "1760ed86", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "log_clf = LogisticRegression(random_state=42)\n", - "rnd_clf = RandomForestClassifier(random_state=42)\n", - "svm_clf = SVC(probability=True, random_state=42)\n", - "\n", - "voting_clf = VotingClassifier(\n", - " estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)],\n", - " voting='soft')\n", - "voting_clf.fit(X_train, y_train)" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "id": "4ab23f0f", - "metadata": { - "collapsed": false, - "editable": true - }, - "outputs": [], - "source": [ - "from sklearn.metrics import accuracy_score\n", - "\n", - "for clf in (log_clf, rnd_clf, svm_clf, voting_clf):\n", - " clf.fit(X_train, y_train)\n", - " y_pred = clf.predict(X_test)\n", - " print(clf.__class__.__name__, accuracy_score(y_test, y_pred))" - ] - }, - { - "cell_type": "markdown", - "id": "0355abcb", + "id": "9a85f577", "metadata": { "editable": true }, @@ -2759,7 +2464,7 @@ }, { "cell_type": "markdown", - "id": "e543eba5", + "id": "b020b475", "metadata": { "editable": true }, @@ -2771,7 +2476,7 @@ }, { "cell_type": "markdown", - "id": "d3f906c7", + "id": "5121590b", "metadata": { "editable": true }, @@ -2796,7 +2501,7 @@ }, { "cell_type": "markdown", - "id": "3582fecd", + "id": "ef8879c2", "metadata": { "editable": true }, @@ -2822,7 +2527,7 @@ }, { "cell_type": "markdown", - "id": "9dba7602", + "id": "f53f3987", "metadata": { "editable": true }, @@ -2832,8 +2537,8 @@ }, { "cell_type": "code", - "execution_count": 34, - "id": "b9bcda80", + "execution_count": 24, + "id": "caef766a", "metadata": { "collapsed": false, "editable": true @@ -2855,19 +2560,14 @@ "X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0)\n", "print(X_train.shape)\n", "print(X_test.shape)\n", + "#define methods\n", "# Logistic Regression\n", "logreg = LogisticRegression(solver='lbfgs')\n", - "logreg.fit(X_train, y_train)\n", - "print(\"Test set accuracy with Logistic Regression: {:.2f}\".format(logreg.score(X_test,y_test)))\n", "# Support vector machine\n", "svm = SVC(gamma='auto', C=100)\n", - "svm.fit(X_train, y_train)\n", - "print(\"Test set accuracy with SVM: {:.2f}\".format(svm.score(X_test,y_test)))\n", "# Decision Trees\n", "deep_tree_clf = DecisionTreeClassifier(max_depth=None)\n", - "deep_tree_clf.fit(X_train, y_train)\n", - "print(\"Test set accuracy with Decision Trees: {:.2f}\".format(deep_tree_clf.score(X_test,y_test)))\n", - "#now scale the data\n", + "#Scale the data\n", "from sklearn.preprocessing import StandardScaler\n", "scaler = StandardScaler()\n", "scaler.fit(X_train)\n", @@ -2910,7 +2610,7 @@ }, { "cell_type": "markdown", - "id": "699bd8fd", + "id": "51dc82ac", "metadata": { "editable": true }, @@ -2926,7 +2626,7 @@ }, { "cell_type": "markdown", - "id": "b66925ee", + "id": "19c89a3b", "metadata": { "editable": true }, @@ -2936,8 +2636,8 @@ }, { "cell_type": "code", - "execution_count": 35, - "id": "6deb494a", + "execution_count": 25, + "id": "61df8785", "metadata": { "collapsed": false, "editable": true @@ -2951,8 +2651,8 @@ }, { "cell_type": "code", - "execution_count": 36, - "id": "118dcd30", + "execution_count": 26, + "id": "4431c086", "metadata": { "collapsed": false, "editable": true diff --git a/doc/src/week44/week44.do.txt b/doc/src/week44/week44.do.txt index 7ec45cf41..b42ca4f2b 100644 --- a/doc/src/week44/week44.do.txt +++ b/doc/src/week44/week44.do.txt @@ -1062,7 +1062,7 @@ print('Split: [X%d < %.3f]' % ((split['index']+1), split['value'])) !split -===== Another example, the moons again ===== +===== Another example, the moons ===== !bc pycod from __future__ import division, print_function, unicode_literals @@ -1306,300 +1306,6 @@ We discuss these methods here. FIGURE: [DataFiles/ensembleoverview.png, width=600 frac=0.8] - - -!split -===== Bagging ===== - -The _plain_ decision trees suffer from high -variance. This means that if we split the training data into two parts -at random, and fit a decision tree to both halves, the results that we -get could be quite different. In contrast, a procedure with low -variance will yield similar results if applied repeatedly to distinct -data sets; linear regression tends to have low variance, if the ratio -of $n$ to $p$ is moderately large. - -_Bootstrap aggregation_, or just _bagging_, is a -general-purpose procedure for reducing the variance of a statistical -learning method. - - -!split -===== More bagging ===== - -Bagging typically results in improved accuracy -over prediction using a single tree. Unfortunately, however, it can be -difficult to interpret the resulting model. Recall that one of the -advantages of decision trees is the attractive and easily interpreted -diagram that results. - -However, when we bag a large number of trees, it is no longer -possible to represent the resulting statistical learning procedure -using a single tree, and it is no longer clear which variables are -most important to the procedure. Thus, bagging improves prediction -accuracy at the expense of interpretability. Although the collection -of bagged trees is much more difficult to interpret than a single -tree, one can obtain an overall summary of the importance of each -predictor using the MSE (for bagging regression trees) or the Gini -index (for bagging classification trees). In the case of bagging -regression trees, we can record the total amount that the MSE is -decreased due to splits over a given predictor, averaged over all $B$ possible -trees. A large value indicates an important predictor. Similarly, in -the context of bagging classification trees, we can add up the total -amount that the Gini index is decreased by splits over a given -predictor, averaged over all $B$ trees. - -!split -===== Simple Voting Example, head or tail ===== -!bc pycod -heads_proba = 0.51 -coin_tosses = (np.random.rand(10000, 10) < heads_proba).astype(np.int32) -cumulative_heads_ratio = np.cumsum(coin_tosses, axis=0) / np.arange(1, 10001).reshape(-1, 1) -plt.figure(figsize=(8,3.5)) -plt.plot(cumulative_heads_ratio) -plt.plot([0, 10000], [0.51, 0.51], "k--", linewidth=2, label="51%") -plt.plot([0, 10000], [0.5, 0.5], "k-", label="50%") -plt.xlabel("Number of coin tosses") -plt.ylabel("Heads ratio") -plt.legend(loc="lower right") -plt.axis([0, 10000, 0.42, 0.58]) -save_fig("votingsimple") -plt.show() - -!ec - -!split -===== Using the Voting Classifier ===== -!bc pycod -from sklearn.model_selection import train_test_split -from sklearn.datasets import make_moons - -X, y = make_moons(n_samples=500, noise=0.30, random_state=42) -X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42) - -from sklearn.ensemble import RandomForestClassifier -from sklearn.ensemble import VotingClassifier -from sklearn.linear_model import LogisticRegression -from sklearn.svm import SVC - -log_clf = LogisticRegression(solver="liblinear", random_state=42) -rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42) -svm_clf = SVC(gamma="auto", random_state=42) - -voting_clf = VotingClassifier( - estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)], - voting='hard') - -voting_clf.fit(X_train, y_train) - -from sklearn.metrics import accuracy_score - -for clf in (log_clf, rnd_clf, svm_clf, voting_clf): - clf.fit(X_train, y_train) - y_pred = clf.predict(X_test) - print(clf.__class__.__name__, accuracy_score(y_test, y_pred)) - -log_clf = LogisticRegression(solver="liblinear", random_state=42) -rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42) -svm_clf = SVC(gamma="auto", probability=True, random_state=42) - -voting_clf = VotingClassifier( - estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)], - voting='soft') -voting_clf.fit(X_train, y_train) - -from sklearn.metrics import accuracy_score - -for clf in (log_clf, rnd_clf, svm_clf, voting_clf): - clf.fit(X_train, y_train) - y_pred = clf.predict(X_test) - print(clf.__class__.__name__, accuracy_score(y_test, y_pred)) - -!ec - -!split -===== Please, not the moons again! Voting and Bagging ===== - -!bc pycod -from sklearn.model_selection import train_test_split -from sklearn.datasets import make_moons - -X, y = make_moons(n_samples=500, noise=0.30, random_state=42) -X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42) -from sklearn.ensemble import RandomForestClassifier -from sklearn.ensemble import VotingClassifier -from sklearn.linear_model import LogisticRegression -from sklearn.svm import SVC - -log_clf = LogisticRegression(random_state=42) -rnd_clf = RandomForestClassifier(random_state=42) -svm_clf = SVC(random_state=42) - -voting_clf = VotingClassifier( - estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)], - voting='hard') -voting_clf.fit(X_train, y_train) -!ec - -!bc pycod -from sklearn.metrics import accuracy_score - -for clf in (log_clf, rnd_clf, svm_clf, voting_clf): - clf.fit(X_train, y_train) - y_pred = clf.predict(X_test) - print(clf.__class__.__name__, accuracy_score(y_test, y_pred)) -!ec - -!bc pycod -log_clf = LogisticRegression(random_state=42) -rnd_clf = RandomForestClassifier(random_state=42) -svm_clf = SVC(probability=True, random_state=42) - -voting_clf = VotingClassifier( - estimators=[('lr', log_clf), ('rf', rnd_clf), ('svc', svm_clf)], - voting='soft') -voting_clf.fit(X_train, y_train) -!ec - -!bc pycod -from sklearn.metrics import accuracy_score - -for clf in (log_clf, rnd_clf, svm_clf, voting_clf): - clf.fit(X_train, y_train) - y_pred = clf.predict(X_test) - print(clf.__class__.__name__, accuracy_score(y_test, y_pred)) -!ec - -!split -===== Bagging Examples ===== - -!bc pycod -from sklearn.ensemble import BaggingClassifier -from sklearn.tree import DecisionTreeClassifier - -bag_clf = BaggingClassifier( - DecisionTreeClassifier(random_state=42), n_estimators=500, - max_samples=100, bootstrap=True, n_jobs=-1, random_state=42) -bag_clf.fit(X_train, y_train) -y_pred = bag_clf.predict(X_test) -!ec - - -!bc pycod -from sklearn.metrics import accuracy_score -print(accuracy_score(y_test, y_pred)) -!ec - -!bc pycod -tree_clf = DecisionTreeClassifier(random_state=42) -tree_clf.fit(X_train, y_train) -y_pred_tree = tree_clf.predict(X_test) -print(accuracy_score(y_test, y_pred_tree)) -!ec - -!bc pycod -from matplotlib.colors import ListedColormap - -def plot_decision_boundary(clf, X, y, axes=[-1.5, 2.5, -1, 1.5], alpha=0.5, contour=True): - x1s = np.linspace(axes[0], axes[1], 100) - x2s = np.linspace(axes[2], axes[3], 100) - x1, x2 = np.meshgrid(x1s, x2s) - X_new = np.c_[x1.ravel(), x2.ravel()] - y_pred = clf.predict(X_new).reshape(x1.shape) - custom_cmap = ListedColormap(['#fafab0','#9898ff','#a0faa0']) - plt.contourf(x1, x2, y_pred, alpha=0.3, cmap=custom_cmap) - if contour: - custom_cmap2 = ListedColormap(['#7d7d58','#4c4c7f','#507d50']) - plt.contour(x1, x2, y_pred, cmap=custom_cmap2, alpha=0.8) - plt.plot(X[:, 0][y==0], X[:, 1][y==0], "yo", alpha=alpha) - plt.plot(X[:, 0][y==1], X[:, 1][y==1], "bs", alpha=alpha) - plt.axis(axes) - plt.xlabel(r"$x_1$", fontsize=18) - plt.ylabel(r"$x_2$", fontsize=18, rotation=0) -plt.figure(figsize=(11,4)) -plt.subplot(121) -plot_decision_boundary(tree_clf, X, y) -plt.title("Decision Tree", fontsize=14) -plt.subplot(122) -plot_decision_boundary(bag_clf, X, y) -plt.title("Decision Trees with Bagging", fontsize=14) -save_fig("baggingtree") -plt.show() -!ec - - - -!split -===== Making your own Bootstrap: Changing the Level of the Decision Tree ===== - -Let us bring up our good old boostrap example from the linear regression lectures. We change the linerar regression algorithm with -a decision tree wth different depths and perform a bootstrap aggregate (in this case we perform as many bootstraps as data points $n$). -!bc pycod - -import matplotlib.pyplot as plt -import numpy as np -from sklearn.model_selection import train_test_split -from sklearn.pipeline import make_pipeline -from sklearn.utils import resample -from sklearn.tree import DecisionTreeRegressor - -n = 100 -n_boostraps = 100 -maxdepth = 8 - -# Make data set. -x = np.linspace(-3, 3, n).reshape(-1, 1) -y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape) -error = np.zeros(maxdepth) -bias = np.zeros(maxdepth) -variance = np.zeros(maxdepth) -polydegree = np.zeros(maxdepth) -X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2) - -from sklearn.preprocessing import StandardScaler -scaler = StandardScaler() -scaler.fit(X_train) -X_train_scaled = scaler.transform(X_train) -X_test_scaled = scaler.transform(X_test) - -# we produce a simple tree first as benchmark -simpletree = DecisionTreeRegressor(max_depth=3) -simpletree.fit(X_train_scaled, y_train) -simpleprediction = simpletree.predict(X_test_scaled) -for degree in range(1,maxdepth): - model = DecisionTreeRegressor(max_depth=degree) - y_pred = np.empty((y_test.shape[0], n_boostraps)) - for i in range(n_boostraps): - x_, y_ = resample(X_train_scaled, y_train) - model.fit(x_, y_) - y_pred[:, i] = model.predict(X_test_scaled)#.ravel() - - polydegree[degree] = degree - error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) ) - bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 ) - variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) ) - print('Polynomial degree:', degree) - print('Error:', error[degree]) - print('Bias^2:', bias[degree]) - print('Var:', variance[degree]) - print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree])) - -mse_simpletree= np.mean( np.mean((y_test - simpleprediction)**2) -print(mse_simpletree) -plt.xlim(1,maxdepth) -plt.plot(polydegree, error, label='MSE') -plt.plot(polydegree, bias, label='bias') -plt.plot(polydegree, variance, label='Variance') -plt.legend() -save_fig("baggingboot") -plt.show() - -!ec - - - - - !split ===== Why Voting? ===== @@ -1828,6 +1534,122 @@ for clf in (log_clf, rnd_clf, svm_clf, voting_clf): +!split +===== Bagging ===== + +The _plain_ decision trees suffer from high +variance. This means that if we split the training data into two parts +at random, and fit a decision tree to both halves, the results that we +get could be quite different. In contrast, a procedure with low +variance will yield similar results if applied repeatedly to distinct +data sets; linear regression tends to have low variance, if the ratio +of $n$ to $p$ is moderately large. + +_Bootstrap aggregation_, or just _bagging_, is a +general-purpose procedure for reducing the variance of a statistical +learning method. + + +!split +===== More bagging ===== + +Bagging typically results in improved accuracy +over prediction using a single tree. Unfortunately, however, it can be +difficult to interpret the resulting model. Recall that one of the +advantages of decision trees is the attractive and easily interpreted +diagram that results. + +However, when we bag a large number of trees, it is no longer +possible to represent the resulting statistical learning procedure +using a single tree, and it is no longer clear which variables are +most important to the procedure. Thus, bagging improves prediction +accuracy at the expense of interpretability. Although the collection +of bagged trees is much more difficult to interpret than a single +tree, one can obtain an overall summary of the importance of each +predictor using the MSE (for bagging regression trees) or the Gini +index (for bagging classification trees). In the case of bagging +regression trees, we can record the total amount that the MSE is +decreased due to splits over a given predictor, averaged over all $B$ possible +trees. A large value indicates an important predictor. Similarly, in +the context of bagging classification trees, we can add up the total +amount that the Gini index is decreased by splits over a given +predictor, averaged over all $B$ trees. + + + +!split +===== Making your own Bootstrap: Changing the Level of the Decision Tree ===== + +Let us bring up our good old boostrap example from the linear regression lectures. We change the linerar regression algorithm with +a decision tree wth different depths and perform a bootstrap aggregate (in this case we perform as many bootstraps as data points $n$). +!bc pycod + +import matplotlib.pyplot as plt +import numpy as np +from sklearn.model_selection import train_test_split +from sklearn.pipeline import make_pipeline +from sklearn.utils import resample +from sklearn.tree import DecisionTreeRegressor + +n = 100 +n_boostraps = 100 +maxdepth = 8 + +# Make data set. +x = np.linspace(-3, 3, n).reshape(-1, 1) +y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape) +error = np.zeros(maxdepth) +bias = np.zeros(maxdepth) +variance = np.zeros(maxdepth) +polydegree = np.zeros(maxdepth) +X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2) + +from sklearn.preprocessing import StandardScaler +scaler = StandardScaler() +scaler.fit(X_train) +X_train_scaled = scaler.transform(X_train) +X_test_scaled = scaler.transform(X_test) + +# we produce a simple tree first as benchmark +simpletree = DecisionTreeRegressor(max_depth=3) +simpletree.fit(X_train_scaled, y_train) +simpleprediction = simpletree.predict(X_test_scaled) +for degree in range(1,maxdepth): + model = DecisionTreeRegressor(max_depth=degree) + y_pred = np.empty((y_test.shape[0], n_boostraps)) + for i in range(n_boostraps): + x_, y_ = resample(X_train_scaled, y_train) + model.fit(x_, y_) + y_pred[:, i] = model.predict(X_test_scaled)#.ravel() + + polydegree[degree] = degree + error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) ) + bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 ) + variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) ) + print('Polynomial degree:', degree) + print('Error:', error[degree]) + print('Bias^2:', bias[degree]) + print('Var:', variance[degree]) + print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree])) + +mse_simpletree= np.mean( np.mean((y_test - simpleprediction)**2) +print(mse_simpletree) +plt.xlim(1,maxdepth) +plt.plot(polydegree, error, label='MSE') +plt.plot(polydegree, bias, label='bias') +plt.plot(polydegree, variance, label='Variance') +plt.legend() +save_fig("baggingboot") +plt.show() + +!ec + + + + + + + !split ===== Random forests ===== @@ -1902,19 +1724,14 @@ cancer = load_breast_cancer() X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0) print(X_train.shape) print(X_test.shape) +#define methods # Logistic Regression logreg = LogisticRegression(solver='lbfgs') -logreg.fit(X_train, y_train) -print("Test set accuracy with Logistic Regression: {:.2f}".format(logreg.score(X_test,y_test))) # Support vector machine svm = SVC(gamma='auto', C=100) -svm.fit(X_train, y_train) -print("Test set accuracy with SVM: {:.2f}".format(svm.score(X_test,y_test))) # Decision Trees deep_tree_clf = DecisionTreeClassifier(max_depth=None) -deep_tree_clf.fit(X_train, y_train) -print("Test set accuracy with Decision Trees: {:.2f}".format(deep_tree_clf.score(X_test,y_test))) -#now scale the data +#Scale the data from sklearn.preprocessing import StandardScaler scaler = StandardScaler() scaler.fit(X_train)