update on decision trees
This commit is contained in:
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -199,7 +208,7 @@ MathJax.Hub.Config({
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Oct 31, 2019</h4></center> <!-- date -->
|
||||
<center><h4>Nov 1, 2019</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
|
||||
@@ -223,7 +232,7 @@ MathJax.Hub.Config({
|
||||
<li><a href="._DecisionTrees-bs008.html">9</a></li>
|
||||
<li><a href="._DecisionTrees-bs009.html">10</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs001.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -228,7 +237,7 @@ given some assumptions, make predictions about the target feature value
|
||||
<li><a href="._DecisionTrees-bs009.html">10</a></li>
|
||||
<li><a href="._DecisionTrees-bs010.html">11</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs002.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -200,7 +209,7 @@ MathJax.Hub.Config({
|
||||
<li><a href="._DecisionTrees-bs010.html">11</a></li>
|
||||
<li><a href="._DecisionTrees-bs011.html">12</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs003.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -214,7 +223,7 @@ node.
|
||||
<li><a href="._DecisionTrees-bs011.html">12</a></li>
|
||||
<li><a href="._DecisionTrees-bs012.html">13</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs004.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -215,7 +224,7 @@ Then we are essentially done!
|
||||
<li><a href="._DecisionTrees-bs012.html">13</a></li>
|
||||
<li><a href="._DecisionTrees-bs013.html">14</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs005.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -294,7 +303,7 @@ plt<span style="color: #666666">.</span>show()
|
||||
<li><a href="._DecisionTrees-bs013.html">14</a></li>
|
||||
<li><a href="._DecisionTrees-bs014.html">15</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs006.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -227,7 +236,7 @@ within box \( j \).
|
||||
<li><a href="._DecisionTrees-bs014.html">15</a></li>
|
||||
<li><a href="._DecisionTrees-bs015.html">16</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs007.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -219,7 +228,7 @@ better tree in some future step.
|
||||
<li><a href="._DecisionTrees-bs015.html">16</a></li>
|
||||
<li><a href="._DecisionTrees-bs016.html">17</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs008.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -252,7 +261,7 @@ region contains more than five observations.
|
||||
<li><a href="._DecisionTrees-bs016.html">17</a></li>
|
||||
<li><a href="._DecisionTrees-bs017.html">18</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs009.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -221,7 +230,7 @@ parameter \( \alpha \).
|
||||
<li><a href="._DecisionTrees-bs017.html">18</a></li>
|
||||
<li><a href="._DecisionTrees-bs018.html">19</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs010.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -234,7 +243,7 @@ subtree corresponding to \( \alpha \).
|
||||
<li><a href="._DecisionTrees-bs018.html">19</a></li>
|
||||
<li><a href="._DecisionTrees-bs019.html">20</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs011.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -230,7 +239,7 @@ MathJax.Hub.Config({
|
||||
<li><a href="._DecisionTrees-bs019.html">20</a></li>
|
||||
<li><a href="._DecisionTrees-bs020.html">21</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs012.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -222,7 +231,7 @@ fall into that region.
|
||||
<li><a href="._DecisionTrees-bs020.html">21</a></li>
|
||||
<li><a href="._DecisionTrees-bs021.html">22</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs013.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -227,7 +236,7 @@ than is the classification error rate.
|
||||
<li><a href="._DecisionTrees-bs021.html">22</a></li>
|
||||
<li><a href="._DecisionTrees-bs022.html">23</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs014.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -253,7 +262,7 @@ $$
|
||||
<li><a href="._DecisionTrees-bs022.html">23</a></li>
|
||||
<li><a href="._DecisionTrees-bs023.html">24</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs015.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -244,7 +253,7 @@ os<span style="color: #666666">.</span>system(cmd)
|
||||
<li><a href="._DecisionTrees-bs023.html">24</a></li>
|
||||
<li><a href="._DecisionTrees-bs024.html">25</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs016.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -235,7 +244,7 @@ os<span style="color: #666666">.</span>system(cmd)
|
||||
<li><a href="._DecisionTrees-bs024.html">25</a></li>
|
||||
<li><a href="._DecisionTrees-bs025.html">26</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs017.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -248,7 +257,7 @@ The table here summarizes the various attributes and
|
||||
<li><a href="._DecisionTrees-bs025.html">26</a></li>
|
||||
<li><a href="._DecisionTrees-bs026.html">27</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs018.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -279,7 +288,7 @@ os<span style="color: #666666">.</span>system(cmd)
|
||||
<li><a href="._DecisionTrees-bs026.html">27</a></li>
|
||||
<li><a href="._DecisionTrees-bs027.html">28</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs019.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -281,7 +290,7 @@ split <span style="color: #666666">=</span> get_split(dataset)
|
||||
<li><a href="._DecisionTrees-bs027.html">28</a></li>
|
||||
<li><a href="._DecisionTrees-bs028.html">29</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs020.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -239,7 +248,7 @@ attributes at each step while growing the tree.
|
||||
<li><a href="._DecisionTrees-bs028.html">29</a></li>
|
||||
<li><a href="._DecisionTrees-bs029.html">30</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs021.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -399,7 +408,7 @@ MathJax.Hub.Config({
|
||||
<li><a href="._DecisionTrees-bs029.html">30</a></li>
|
||||
<li><a href="._DecisionTrees-bs030.html">31</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs022.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -252,7 +261,7 @@ deep_tree_clf<span style="color: #666666">.</span>fit(X_train_scaled, y_train)
|
||||
<li><a href="._DecisionTrees-bs030.html">31</a></li>
|
||||
<li><a href="._DecisionTrees-bs031.html">32</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs023.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -275,7 +284,7 @@ plt<span style="color: #666666">.</span>show()
|
||||
<li><a href="._DecisionTrees-bs031.html">32</a></li>
|
||||
<li><a href="._DecisionTrees-bs032.html">33</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs024.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -231,7 +240,7 @@ plt<span style="color: #666666">.</span>show()
|
||||
<li><a href="._DecisionTrees-bs032.html">33</a></li>
|
||||
<li><a href="._DecisionTrees-bs033.html">34</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs025.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -225,7 +234,7 @@ tree_reg<span style="color: #666666">.</span>fit(X, y)
|
||||
<li><a href="._DecisionTrees-bs033.html">34</a></li>
|
||||
<li><a href="._DecisionTrees-bs034.html">35</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs026.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -281,7 +290,7 @@ plt<span style="color: #666666">.</span>show()
|
||||
<li><a href="._DecisionTrees-bs034.html">35</a></li>
|
||||
<li><a href="._DecisionTrees-bs035.html">36</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs027.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -217,7 +226,7 @@ MathJax.Hub.Config({
|
||||
<li><a href="._DecisionTrees-bs035.html">36</a></li>
|
||||
<li><a href="._DecisionTrees-bs036.html">37</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs028.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -219,6 +228,8 @@ However, by aggregating many decision trees, using methods like bagging, random
|
||||
<li><a href="._DecisionTrees-bs035.html">36</a></li>
|
||||
<li><a href="._DecisionTrees-bs036.html">37</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs029.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -220,6 +229,9 @@ learning method.
|
||||
<li><a href="._DecisionTrees-bs035.html">36</a></li>
|
||||
<li><a href="._DecisionTrees-bs036.html">37</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs038.html">39</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs030.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -229,6 +238,10 @@ predictor, averaged over all \( B \) trees.
|
||||
<li><a href="._DecisionTrees-bs035.html">36</a></li>
|
||||
<li><a href="._DecisionTrees-bs036.html">37</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs038.html">39</a></li>
|
||||
<li><a href="._DecisionTrees-bs039.html">40</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs031.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -180,7 +189,7 @@ MathJax.Hub.Config({
|
||||
<a name="part0031"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="___sec30" class="anchor">Simple example, head or tail </h2>
|
||||
<h2 id="___sec30" class="anchor">Simple Voting Example, head or tail </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
@@ -219,6 +228,9 @@ plt<span style="color: #666666">.</span>show()
|
||||
<li><a href="._DecisionTrees-bs035.html">36</a></li>
|
||||
<li><a href="._DecisionTrees-bs036.html">37</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs038.html">39</a></li>
|
||||
<li><a href="._DecisionTrees-bs039.html">40</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs032.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -180,7 +189,7 @@ MathJax.Hub.Config({
|
||||
<a name="part0032"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="___sec31" class="anchor">Bagging Example </h2>
|
||||
<h2 id="___sec31" class="anchor">Using the Voting Classifier </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
@@ -249,6 +258,9 @@ voting_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
<li><a href="._DecisionTrees-bs035.html">36</a></li>
|
||||
<li><a href="._DecisionTrees-bs036.html">37</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs038.html">39</a></li>
|
||||
<li><a href="._DecisionTrees-bs039.html">40</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs033.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -180,47 +189,61 @@ MathJax.Hub.Config({
|
||||
<a name="part0033"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="___sec32" class="anchor">Random forests </h2>
|
||||
|
||||
<h2 id="___sec32" class="anchor">Please, not the moons again! Voting and Bagging </h2>
|
||||
<p>
|
||||
Random forests provide an improvement over bagged trees by way of a
|
||||
small tweak that decorrelates the trees.
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.model_selection</span> <span style="color: #008000; font-weight: bold">import</span> train_test_split
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.datasets</span> <span style="color: #008000; font-weight: bold">import</span> make_moons
|
||||
|
||||
X, y <span style="color: #666666">=</span> make_moons(n_samples<span style="color: #666666">=500</span>, noise<span style="color: #666666">=0.30</span>, random_state<span style="color: #666666">=42</span>)
|
||||
X_train, X_test, y_train, y_test <span style="color: #666666">=</span> train_test_split(X, y, random_state<span style="color: #666666">=42</span>)
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.ensemble</span> <span style="color: #008000; font-weight: bold">import</span> RandomForestClassifier
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.ensemble</span> <span style="color: #008000; font-weight: bold">import</span> VotingClassifier
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.linear_model</span> <span style="color: #008000; font-weight: bold">import</span> LogisticRegression
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.svm</span> <span style="color: #008000; font-weight: bold">import</span> SVC
|
||||
|
||||
log_clf <span style="color: #666666">=</span> LogisticRegression(random_state<span style="color: #666666">=42</span>)
|
||||
rnd_clf <span style="color: #666666">=</span> RandomForestClassifier(random_state<span style="color: #666666">=42</span>)
|
||||
svm_clf <span style="color: #666666">=</span> SVC(random_state<span style="color: #666666">=42</span>)
|
||||
|
||||
voting_clf <span style="color: #666666">=</span> VotingClassifier(
|
||||
estimators<span style="color: #666666">=</span>[(<span style="color: #BA2121">'lr'</span>, log_clf), (<span style="color: #BA2121">'rf'</span>, rnd_clf), (<span style="color: #BA2121">'svc'</span>, svm_clf)],
|
||||
voting<span style="color: #666666">=</span><span style="color: #BA2121">'hard'</span>)
|
||||
voting_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
</pre></div>
|
||||
<p>
|
||||
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.
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.metrics</span> <span style="color: #008000; font-weight: bold">import</span> accuracy_score
|
||||
|
||||
<span style="color: #008000; font-weight: bold">for</span> clf <span style="color: #AA22FF; font-weight: bold">in</span> (log_clf, rnd_clf, svm_clf, voting_clf):
|
||||
clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
y_pred <span style="color: #666666">=</span> clf<span style="color: #666666">.</span>predict(X_test)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(clf<span style="color: #666666">.</span><span style="color: #19177C">__class__</span><span style="color: #666666">.</span><span style="color: #19177C">__name__</span>, accuracy_score(y_test, y_pred))
|
||||
</pre></div>
|
||||
<p>
|
||||
A fresh sample of \( m \) predictors is
|
||||
taken at each split, and typically we choose
|
||||
|
||||
$$
|
||||
m\approx \sqrt{p}.
|
||||
$$
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>log_clf <span style="color: #666666">=</span> LogisticRegression(random_state<span style="color: #666666">=42</span>)
|
||||
rnd_clf <span style="color: #666666">=</span> RandomForestClassifier(random_state<span style="color: #666666">=42</span>)
|
||||
svm_clf <span style="color: #666666">=</span> SVC(probability<span style="color: #666666">=</span><span style="color: #008000">True</span>, random_state<span style="color: #666666">=42</span>)
|
||||
|
||||
voting_clf <span style="color: #666666">=</span> VotingClassifier(
|
||||
estimators<span style="color: #666666">=</span>[(<span style="color: #BA2121">'lr'</span>, log_clf), (<span style="color: #BA2121">'rf'</span>, rnd_clf), (<span style="color: #BA2121">'svc'</span>, svm_clf)],
|
||||
voting<span style="color: #666666">=</span><span style="color: #BA2121">'soft'</span>)
|
||||
voting_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
</pre></div>
|
||||
<p>
|
||||
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.
|
||||
|
||||
<p>
|
||||
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 quanti- ties. In particular, this means that bagging will
|
||||
not lead to a substantial reduction in variance over a single tree in
|
||||
this setting.
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.metrics</span> <span style="color: #008000; font-weight: bold">import</span> accuracy_score
|
||||
|
||||
<span style="color: #008000; font-weight: bold">for</span> clf <span style="color: #AA22FF; font-weight: bold">in</span> (log_clf, rnd_clf, svm_clf, voting_clf):
|
||||
clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
y_pred <span style="color: #666666">=</span> clf<span style="color: #666666">.</span>predict(X_test)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(clf<span style="color: #666666">.</span><span style="color: #19177C">__class__</span><span style="color: #666666">.</span><span style="color: #19177C">__name__</span>, accuracy_score(y_test, y_pred))
|
||||
</pre></div>
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
@@ -241,6 +264,9 @@ this setting.
|
||||
<li><a href="._DecisionTrees-bs035.html">36</a></li>
|
||||
<li><a href="._DecisionTrees-bs036.html">37</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs038.html">39</a></li>
|
||||
<li><a href="._DecisionTrees-bs039.html">40</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs034.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -180,20 +189,63 @@ MathJax.Hub.Config({
|
||||
<a name="part0034"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="___sec33" class="anchor">A simple scikit-learn example </h2>
|
||||
<h2 id="___sec33" class="anchor">Now Bagging </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.ensemble</span> <span style="color: #008000; font-weight: bold">import</span> RandomForestClassifier
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.preprocessing</span> <span style="color: #008000; font-weight: bold">import</span> LabelEncoder
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.model_selection</span> <span style="color: #008000; font-weight: bold">import</span> cross_validate
|
||||
<span style="color: #408080; font-style: italic"># Data set not specificied</span>
|
||||
X <span style="color: #666666">=</span> dataset<span style="color: #666666">.</span>XXX
|
||||
Y <span style="color: #666666">=</span> dataset<span style="color: #666666">.</span>YYY
|
||||
<span style="color: #408080; font-style: italic">#Instantiate the model with 100 trees and entropy as splitting criteria</span>
|
||||
Random_Forest_model <span style="color: #666666">=</span> RandomForestClassifier(n_estimators<span style="color: #666666">=100</span>,criterion<span style="color: #666666">=</span><span style="color: #BA2121">"entropy"</span>)
|
||||
<span style="color: #408080; font-style: italic">#Cross validation</span>
|
||||
accuracy <span style="color: #666666">=</span> cross_validate(Random_Forest_model,X,Y,cv<span style="color: #666666">=10</span>)[<span style="color: #BA2121">'test_score'</span>]
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.ensemble</span> <span style="color: #008000; font-weight: bold">import</span> BaggingClassifier
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.tree</span> <span style="color: #008000; font-weight: bold">import</span> DecisionTreeClassifier
|
||||
|
||||
bag_clf <span style="color: #666666">=</span> BaggingClassifier(
|
||||
DecisionTreeClassifier(random_state<span style="color: #666666">=42</span>), n_estimators<span style="color: #666666">=500</span>,
|
||||
max_samples<span style="color: #666666">=100</span>, bootstrap<span style="color: #666666">=</span><span style="color: #008000">True</span>, n_jobs<span style="color: #666666">=-1</span>, random_state<span style="color: #666666">=42</span>)
|
||||
bag_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
y_pred <span style="color: #666666">=</span> bag_clf<span style="color: #666666">.</span>predict(X_test)
|
||||
</pre></div>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.metrics</span> <span style="color: #008000; font-weight: bold">import</span> accuracy_score
|
||||
<span style="color: #008000; font-weight: bold">print</span>(accuracy_score(y_test, y_pred))
|
||||
</pre></div>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>tree_clf <span style="color: #666666">=</span> DecisionTreeClassifier(random_state<span style="color: #666666">=42</span>)
|
||||
tree_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
y_pred_tree <span style="color: #666666">=</span> tree_clf<span style="color: #666666">.</span>predict(X_test)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(accuracy_score(y_test, y_pred_tree))
|
||||
</pre></div>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">matplotlib.colors</span> <span style="color: #008000; font-weight: bold">import</span> ListedColormap
|
||||
|
||||
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">plot_decision_boundary</span>(clf, X, y, axes<span style="color: #666666">=</span>[<span style="color: #666666">-1.5</span>, <span style="color: #666666">2.5</span>, <span style="color: #666666">-1</span>, <span style="color: #666666">1.5</span>], alpha<span style="color: #666666">=0.5</span>, contour<span style="color: #666666">=</span><span style="color: #008000">True</span>):
|
||||
x1s <span style="color: #666666">=</span> np<span style="color: #666666">.</span>linspace(axes[<span style="color: #666666">0</span>], axes[<span style="color: #666666">1</span>], <span style="color: #666666">100</span>)
|
||||
x2s <span style="color: #666666">=</span> np<span style="color: #666666">.</span>linspace(axes[<span style="color: #666666">2</span>], axes[<span style="color: #666666">3</span>], <span style="color: #666666">100</span>)
|
||||
x1, x2 <span style="color: #666666">=</span> np<span style="color: #666666">.</span>meshgrid(x1s, x2s)
|
||||
X_new <span style="color: #666666">=</span> np<span style="color: #666666">.</span>c_[x1<span style="color: #666666">.</span>ravel(), x2<span style="color: #666666">.</span>ravel()]
|
||||
y_pred <span style="color: #666666">=</span> clf<span style="color: #666666">.</span>predict(X_new)<span style="color: #666666">.</span>reshape(x1<span style="color: #666666">.</span>shape)
|
||||
custom_cmap <span style="color: #666666">=</span> ListedColormap([<span style="color: #BA2121">'#fafab0'</span>,<span style="color: #BA2121">'#9898ff'</span>,<span style="color: #BA2121">'#a0faa0'</span>])
|
||||
plt<span style="color: #666666">.</span>contourf(x1, x2, y_pred, alpha<span style="color: #666666">=0.3</span>, cmap<span style="color: #666666">=</span>custom_cmap)
|
||||
<span style="color: #008000; font-weight: bold">if</span> contour:
|
||||
custom_cmap2 <span style="color: #666666">=</span> ListedColormap([<span style="color: #BA2121">'#7d7d58'</span>,<span style="color: #BA2121">'#4c4c7f'</span>,<span style="color: #BA2121">'#507d50'</span>])
|
||||
plt<span style="color: #666666">.</span>contour(x1, x2, y_pred, cmap<span style="color: #666666">=</span>custom_cmap2, alpha<span style="color: #666666">=0.8</span>)
|
||||
plt<span style="color: #666666">.</span>plot(X[:, <span style="color: #666666">0</span>][y<span style="color: #666666">==0</span>], X[:, <span style="color: #666666">1</span>][y<span style="color: #666666">==0</span>], <span style="color: #BA2121">"yo"</span>, alpha<span style="color: #666666">=</span>alpha)
|
||||
plt<span style="color: #666666">.</span>plot(X[:, <span style="color: #666666">0</span>][y<span style="color: #666666">==1</span>], X[:, <span style="color: #666666">1</span>][y<span style="color: #666666">==1</span>], <span style="color: #BA2121">"bs"</span>, alpha<span style="color: #666666">=</span>alpha)
|
||||
plt<span style="color: #666666">.</span>axis(axes)
|
||||
plt<span style="color: #666666">.</span>xlabel(<span style="color: #BA2121">r"$x_1$"</span>, fontsize<span style="color: #666666">=18</span>)
|
||||
plt<span style="color: #666666">.</span>ylabel(<span style="color: #BA2121">r"$x_2$"</span>, fontsize<span style="color: #666666">=18</span>, rotation<span style="color: #666666">=0</span>)
|
||||
plt<span style="color: #666666">.</span>figure(figsize<span style="color: #666666">=</span>(<span style="color: #666666">11</span>,<span style="color: #666666">4</span>))
|
||||
plt<span style="color: #666666">.</span>subplot(<span style="color: #666666">121</span>)
|
||||
plot_decision_boundary(tree_clf, X, y)
|
||||
plt<span style="color: #666666">.</span>title(<span style="color: #BA2121">"Decision Tree"</span>, fontsize<span style="color: #666666">=14</span>)
|
||||
plt<span style="color: #666666">.</span>subplot(<span style="color: #666666">122</span>)
|
||||
plot_decision_boundary(bag_clf, X, y)
|
||||
plt<span style="color: #666666">.</span>title(<span style="color: #BA2121">"Decision Trees with Bagging"</span>, fontsize<span style="color: #666666">=14</span>)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
<p>
|
||||
<p>
|
||||
@@ -214,6 +266,9 @@ accuracy <span style="color: #666666">=</span> cross_validate(Random_Forest_mode
|
||||
<li><a href="._DecisionTrees-bs035.html">36</a></li>
|
||||
<li><a href="._DecisionTrees-bs036.html">37</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs038.html">39</a></li>
|
||||
<li><a href="._DecisionTrees-bs039.html">40</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs035.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -180,61 +189,47 @@ MathJax.Hub.Config({
|
||||
<a name="part0035"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="___sec34" class="anchor">Please, not the moons again! </h2>
|
||||
<h2 id="___sec34" class="anchor">Random forests </h2>
|
||||
|
||||
<p>
|
||||
Random forests provide an improvement over bagged trees by way of a
|
||||
small tweak that decorrelates the trees.
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.model_selection</span> <span style="color: #008000; font-weight: bold">import</span> train_test_split
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.datasets</span> <span style="color: #008000; font-weight: bold">import</span> make_moons
|
||||
|
||||
X, y <span style="color: #666666">=</span> make_moons(n_samples<span style="color: #666666">=500</span>, noise<span style="color: #666666">=0.30</span>, random_state<span style="color: #666666">=42</span>)
|
||||
X_train, X_test, y_train, y_test <span style="color: #666666">=</span> train_test_split(X, y, random_state<span style="color: #666666">=42</span>)
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.ensemble</span> <span style="color: #008000; font-weight: bold">import</span> RandomForestClassifier
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.ensemble</span> <span style="color: #008000; font-weight: bold">import</span> VotingClassifier
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.linear_model</span> <span style="color: #008000; font-weight: bold">import</span> LogisticRegression
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.svm</span> <span style="color: #008000; font-weight: bold">import</span> SVC
|
||||
|
||||
log_clf <span style="color: #666666">=</span> LogisticRegression(random_state<span style="color: #666666">=42</span>)
|
||||
rnd_clf <span style="color: #666666">=</span> RandomForestClassifier(random_state<span style="color: #666666">=42</span>)
|
||||
svm_clf <span style="color: #666666">=</span> SVC(random_state<span style="color: #666666">=42</span>)
|
||||
|
||||
voting_clf <span style="color: #666666">=</span> VotingClassifier(
|
||||
estimators<span style="color: #666666">=</span>[(<span style="color: #BA2121">'lr'</span>, log_clf), (<span style="color: #BA2121">'rf'</span>, rnd_clf), (<span style="color: #BA2121">'svc'</span>, svm_clf)],
|
||||
voting<span style="color: #666666">=</span><span style="color: #BA2121">'hard'</span>)
|
||||
voting_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
</pre></div>
|
||||
<p>
|
||||
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.
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.metrics</span> <span style="color: #008000; font-weight: bold">import</span> accuracy_score
|
||||
|
||||
<span style="color: #008000; font-weight: bold">for</span> clf <span style="color: #AA22FF; font-weight: bold">in</span> (log_clf, rnd_clf, svm_clf, voting_clf):
|
||||
clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
y_pred <span style="color: #666666">=</span> clf<span style="color: #666666">.</span>predict(X_test)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(clf<span style="color: #666666">.</span><span style="color: #19177C">__class__</span><span style="color: #666666">.</span><span style="color: #19177C">__name__</span>, accuracy_score(y_test, y_pred))
|
||||
</pre></div>
|
||||
<p>
|
||||
A fresh sample of \( m \) predictors is
|
||||
taken at each split, and typically we choose
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>log_clf <span style="color: #666666">=</span> LogisticRegression(random_state<span style="color: #666666">=42</span>)
|
||||
rnd_clf <span style="color: #666666">=</span> RandomForestClassifier(random_state<span style="color: #666666">=42</span>)
|
||||
svm_clf <span style="color: #666666">=</span> SVC(probability<span style="color: #666666">=</span><span style="color: #008000">True</span>, random_state<span style="color: #666666">=42</span>)
|
||||
$$
|
||||
m\approx \sqrt{p}.
|
||||
$$
|
||||
|
||||
voting_clf <span style="color: #666666">=</span> VotingClassifier(
|
||||
estimators<span style="color: #666666">=</span>[(<span style="color: #BA2121">'lr'</span>, log_clf), (<span style="color: #BA2121">'rf'</span>, rnd_clf), (<span style="color: #BA2121">'svc'</span>, svm_clf)],
|
||||
voting<span style="color: #666666">=</span><span style="color: #BA2121">'soft'</span>)
|
||||
voting_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
</pre></div>
|
||||
<p>
|
||||
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.
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.metrics</span> <span style="color: #008000; font-weight: bold">import</span> accuracy_score
|
||||
<p>
|
||||
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 quanti- ties. In particular, this means that bagging will
|
||||
not lead to a substantial reduction in variance over a single tree in
|
||||
this setting.
|
||||
|
||||
<span style="color: #008000; font-weight: bold">for</span> clf <span style="color: #AA22FF; font-weight: bold">in</span> (log_clf, rnd_clf, svm_clf, voting_clf):
|
||||
clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
y_pred <span style="color: #666666">=</span> clf<span style="color: #666666">.</span>predict(X_test)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(clf<span style="color: #666666">.</span><span style="color: #19177C">__class__</span><span style="color: #666666">.</span><span style="color: #19177C">__name__</span>, accuracy_score(y_test, y_pred))
|
||||
</pre></div>
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
@@ -253,6 +248,9 @@ voting_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
<li class="active"><a href="._DecisionTrees-bs035.html">36</a></li>
|
||||
<li><a href="._DecisionTrees-bs036.html">37</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs038.html">39</a></li>
|
||||
<li><a href="._DecisionTrees-bs039.html">40</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs036.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -180,63 +189,20 @@ MathJax.Hub.Config({
|
||||
<a name="part0036"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="___sec35" class="anchor">Bagging examples </h2>
|
||||
|
||||
<h2 id="___sec35" class="anchor">A simple scikit-learn example </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.ensemble</span> <span style="color: #008000; font-weight: bold">import</span> BaggingClassifier
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.tree</span> <span style="color: #008000; font-weight: bold">import</span> DecisionTreeClassifier
|
||||
|
||||
bag_clf <span style="color: #666666">=</span> BaggingClassifier(
|
||||
DecisionTreeClassifier(random_state<span style="color: #666666">=42</span>), n_estimators<span style="color: #666666">=500</span>,
|
||||
max_samples<span style="color: #666666">=100</span>, bootstrap<span style="color: #666666">=</span><span style="color: #008000">True</span>, n_jobs<span style="color: #666666">=-1</span>, random_state<span style="color: #666666">=42</span>)
|
||||
bag_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
y_pred <span style="color: #666666">=</span> bag_clf<span style="color: #666666">.</span>predict(X_test)
|
||||
</pre></div>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.metrics</span> <span style="color: #008000; font-weight: bold">import</span> accuracy_score
|
||||
<span style="color: #008000; font-weight: bold">print</span>(accuracy_score(y_test, y_pred))
|
||||
</pre></div>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>tree_clf <span style="color: #666666">=</span> DecisionTreeClassifier(random_state<span style="color: #666666">=42</span>)
|
||||
tree_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
y_pred_tree <span style="color: #666666">=</span> tree_clf<span style="color: #666666">.</span>predict(X_test)
|
||||
<span style="color: #008000; font-weight: bold">print</span>(accuracy_score(y_test, y_pred_tree))
|
||||
</pre></div>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">matplotlib.colors</span> <span style="color: #008000; font-weight: bold">import</span> ListedColormap
|
||||
|
||||
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">plot_decision_boundary</span>(clf, X, y, axes<span style="color: #666666">=</span>[<span style="color: #666666">-1.5</span>, <span style="color: #666666">2.5</span>, <span style="color: #666666">-1</span>, <span style="color: #666666">1.5</span>], alpha<span style="color: #666666">=0.5</span>, contour<span style="color: #666666">=</span><span style="color: #008000">True</span>):
|
||||
x1s <span style="color: #666666">=</span> np<span style="color: #666666">.</span>linspace(axes[<span style="color: #666666">0</span>], axes[<span style="color: #666666">1</span>], <span style="color: #666666">100</span>)
|
||||
x2s <span style="color: #666666">=</span> np<span style="color: #666666">.</span>linspace(axes[<span style="color: #666666">2</span>], axes[<span style="color: #666666">3</span>], <span style="color: #666666">100</span>)
|
||||
x1, x2 <span style="color: #666666">=</span> np<span style="color: #666666">.</span>meshgrid(x1s, x2s)
|
||||
X_new <span style="color: #666666">=</span> np<span style="color: #666666">.</span>c_[x1<span style="color: #666666">.</span>ravel(), x2<span style="color: #666666">.</span>ravel()]
|
||||
y_pred <span style="color: #666666">=</span> clf<span style="color: #666666">.</span>predict(X_new)<span style="color: #666666">.</span>reshape(x1<span style="color: #666666">.</span>shape)
|
||||
custom_cmap <span style="color: #666666">=</span> ListedColormap([<span style="color: #BA2121">'#fafab0'</span>,<span style="color: #BA2121">'#9898ff'</span>,<span style="color: #BA2121">'#a0faa0'</span>])
|
||||
plt<span style="color: #666666">.</span>contourf(x1, x2, y_pred, alpha<span style="color: #666666">=0.3</span>, cmap<span style="color: #666666">=</span>custom_cmap)
|
||||
<span style="color: #008000; font-weight: bold">if</span> contour:
|
||||
custom_cmap2 <span style="color: #666666">=</span> ListedColormap([<span style="color: #BA2121">'#7d7d58'</span>,<span style="color: #BA2121">'#4c4c7f'</span>,<span style="color: #BA2121">'#507d50'</span>])
|
||||
plt<span style="color: #666666">.</span>contour(x1, x2, y_pred, cmap<span style="color: #666666">=</span>custom_cmap2, alpha<span style="color: #666666">=0.8</span>)
|
||||
plt<span style="color: #666666">.</span>plot(X[:, <span style="color: #666666">0</span>][y<span style="color: #666666">==0</span>], X[:, <span style="color: #666666">1</span>][y<span style="color: #666666">==0</span>], <span style="color: #BA2121">"yo"</span>, alpha<span style="color: #666666">=</span>alpha)
|
||||
plt<span style="color: #666666">.</span>plot(X[:, <span style="color: #666666">0</span>][y<span style="color: #666666">==1</span>], X[:, <span style="color: #666666">1</span>][y<span style="color: #666666">==1</span>], <span style="color: #BA2121">"bs"</span>, alpha<span style="color: #666666">=</span>alpha)
|
||||
plt<span style="color: #666666">.</span>axis(axes)
|
||||
plt<span style="color: #666666">.</span>xlabel(<span style="color: #BA2121">r"$x_1$"</span>, fontsize<span style="color: #666666">=18</span>)
|
||||
plt<span style="color: #666666">.</span>ylabel(<span style="color: #BA2121">r"$x_2$"</span>, fontsize<span style="color: #666666">=18</span>, rotation<span style="color: #666666">=0</span>)
|
||||
plt<span style="color: #666666">.</span>figure(figsize<span style="color: #666666">=</span>(<span style="color: #666666">11</span>,<span style="color: #666666">4</span>))
|
||||
plt<span style="color: #666666">.</span>subplot(<span style="color: #666666">121</span>)
|
||||
plot_decision_boundary(tree_clf, X, y)
|
||||
plt<span style="color: #666666">.</span>title(<span style="color: #BA2121">"Decision Tree"</span>, fontsize<span style="color: #666666">=14</span>)
|
||||
plt<span style="color: #666666">.</span>subplot(<span style="color: #666666">122</span>)
|
||||
plot_decision_boundary(bag_clf, X, y)
|
||||
plt<span style="color: #666666">.</span>title(<span style="color: #BA2121">"Decision Trees with Bagging"</span>, fontsize<span style="color: #666666">=14</span>)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.ensemble</span> <span style="color: #008000; font-weight: bold">import</span> RandomForestClassifier
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.preprocessing</span> <span style="color: #008000; font-weight: bold">import</span> LabelEncoder
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.model_selection</span> <span style="color: #008000; font-weight: bold">import</span> cross_validate
|
||||
<span style="color: #408080; font-style: italic"># Data set not specificied</span>
|
||||
X <span style="color: #666666">=</span> dataset<span style="color: #666666">.</span>XXX
|
||||
Y <span style="color: #666666">=</span> dataset<span style="color: #666666">.</span>YYY
|
||||
<span style="color: #408080; font-style: italic">#Instantiate the model with 100 trees and entropy as splitting criteria</span>
|
||||
Random_Forest_model <span style="color: #666666">=</span> RandomForestClassifier(n_estimators<span style="color: #666666">=100</span>,criterion<span style="color: #666666">=</span><span style="color: #BA2121">"entropy"</span>)
|
||||
<span style="color: #408080; font-style: italic">#Cross validation</span>
|
||||
accuracy <span style="color: #666666">=</span> cross_validate(Random_Forest_model,X,Y,cv<span style="color: #666666">=10</span>)[<span style="color: #BA2121">'test_score'</span>]
|
||||
</pre></div>
|
||||
<p>
|
||||
<p>
|
||||
@@ -255,6 +221,9 @@ plt<span style="color: #666666">.</span>show()
|
||||
<li><a href="._DecisionTrees-bs035.html">36</a></li>
|
||||
<li class="active"><a href="._DecisionTrees-bs036.html">37</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs038.html">39</a></li>
|
||||
<li><a href="._DecisionTrees-bs039.html">40</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -200,7 +209,6 @@ y_pred_rf <span style="color: #666666">=</span> rnd_clf<span style="color: #6666
|
||||
np<span style="color: #666666">.</span>sum(y_pred <span style="color: #666666">==</span> y_pred_rf) <span style="color: #666666">/</span> <span style="color: #008000">len</span>(y_pred)
|
||||
</pre></div>
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -216,6 +224,10 @@ np<span style="color: #666666">.</span>sum(y_pred <span style="color: #666666">=
|
||||
<li><a href="._DecisionTrees-bs035.html">36</a></li>
|
||||
<li><a href="._DecisionTrees-bs036.html">37</a></li>
|
||||
<li class="active"><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs038.html">39</a></li>
|
||||
<li><a href="._DecisionTrees-bs039.html">40</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs038.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
|
||||
@@ -47,52 +47,56 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'___sec1'),
|
||||
('A typical Decision Tree with its pertinent Jargon, Regeression '
|
||||
'Problem',
|
||||
2,
|
||||
None,
|
||||
'___sec2'),
|
||||
('General Features', 2, None, '___sec3'),
|
||||
('How do we set it up?', 2, None, '___sec4'),
|
||||
('Decision trees and Regression', 2, None, '___sec5'),
|
||||
('Building a tree, regression', 2, None, '___sec6'),
|
||||
('General Features', 2, None, '___sec2'),
|
||||
('How do we set it up?', 2, None, '___sec3'),
|
||||
('Decision trees and Regression', 2, None, '___sec4'),
|
||||
('Building a tree, regression', 2, None, '___sec5'),
|
||||
('A top-down approach, recursive binary splitting',
|
||||
2,
|
||||
None,
|
||||
'___sec7'),
|
||||
('Making a tree', 2, None, '___sec8'),
|
||||
('Pruning the tree', 2, None, '___sec9'),
|
||||
('Cost complexity pruning', 2, None, '___sec10'),
|
||||
('Schematic Regression Procedure', 2, None, '___sec11'),
|
||||
('A Classification Tree', 2, None, '___sec12'),
|
||||
('Growing a classification tree', 2, None, '___sec13'),
|
||||
('Classification tree, how to split nodes', 2, None, '___sec14'),
|
||||
('Visualizing the Tree, Classification', 2, None, '___sec15'),
|
||||
('Visualizing the Tree, The Moons', 2, None, '___sec16'),
|
||||
('Computing the Gini index', 2, None, '___sec17'),
|
||||
('Simple Python Code to read in Data', 2, None, '___sec18'),
|
||||
('Computing the Gini Factor', 2, None, '___sec19'),
|
||||
('Entropy and the ID3 algorithm', 2, None, '___sec20'),
|
||||
('Implementing the ID3 Algorithm', 2, None, '___sec21'),
|
||||
'___sec6'),
|
||||
('Making a tree', 2, None, '___sec7'),
|
||||
('Pruning the tree', 2, None, '___sec8'),
|
||||
('Cost complexity pruning', 2, None, '___sec9'),
|
||||
('Schematic Regression Procedure', 2, None, '___sec10'),
|
||||
('A Classification Tree', 2, None, '___sec11'),
|
||||
('Growing a classification tree', 2, None, '___sec12'),
|
||||
('Classification tree, how to split nodes', 2, None, '___sec13'),
|
||||
('Visualizing the Tree, Classification', 2, None, '___sec14'),
|
||||
('Visualizing the Tree, The Moons', 2, None, '___sec15'),
|
||||
('Computing the Gini index', 2, None, '___sec16'),
|
||||
('Simple Python Code to read in Data and perform Classification',
|
||||
2,
|
||||
None,
|
||||
'___sec17'),
|
||||
('Computing the Gini Factor', 2, None, '___sec18'),
|
||||
('Entropy and the ID3 algorithm', 2, None, '___sec19'),
|
||||
('Implementing the ID3 Algorithm', 2, None, '___sec20'),
|
||||
('Cancer Data again now with Decision Trees and other Methods',
|
||||
2,
|
||||
None,
|
||||
'___sec22'),
|
||||
('Another example, the moons again', 2, None, '___sec23'),
|
||||
('Playing around with regions', 2, None, '___sec24'),
|
||||
('Regression trees', 2, None, '___sec25'),
|
||||
('Final regressor code', 2, None, '___sec26'),
|
||||
('Pros and cons of trees, pros', 2, None, '___sec27'),
|
||||
('Disadvantages', 2, None, '___sec28'),
|
||||
('Bagging', 2, None, '___sec29'),
|
||||
('More bagging', 2, None, '___sec30'),
|
||||
('Simple example, head or tail', 2, None, '___sec31'),
|
||||
('Bagging Example', 2, None, '___sec32'),
|
||||
('Random forests', 2, None, '___sec33'),
|
||||
('A simple scikit-learn example', 2, None, '___sec34'),
|
||||
('Please, not the moons again!', 2, None, '___sec35'),
|
||||
('Bagging examples', 2, None, '___sec36'),
|
||||
('Then random forests', 2, None, '___sec37')]}
|
||||
'___sec21'),
|
||||
('Another example, the moons again', 2, None, '___sec22'),
|
||||
('Playing around with regions', 2, None, '___sec23'),
|
||||
('Regression trees', 2, None, '___sec24'),
|
||||
('Final regressor code', 2, None, '___sec25'),
|
||||
('Pros and cons of trees, pros', 2, None, '___sec26'),
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -132,42 +136,44 @@ MathJax.Hub.Config({
|
||||
<ul class="dropdown-menu">
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs001.html#___sec0" style="font-size: 80%;">Decision trees, overarching aims</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs002.html#___sec1" style="font-size: 80%;">A typical Decision Tree with its pertinent Jargon, Classification Problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs003.html#___sec2" style="font-size: 80%;">A typical Decision Tree with its pertinent Jargon, Regeression Problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs004.html#___sec3" style="font-size: 80%;">General Features</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs005.html#___sec4" style="font-size: 80%;">How do we set it up?</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs006.html#___sec5" style="font-size: 80%;">Decision trees and Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs007.html#___sec6" style="font-size: 80%;">Building a tree, regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs008.html#___sec7" style="font-size: 80%;">A top-down approach, recursive binary splitting</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs009.html#___sec8" style="font-size: 80%;">Making a tree</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs010.html#___sec9" style="font-size: 80%;">Pruning the tree</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs011.html#___sec10" style="font-size: 80%;">Cost complexity pruning</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs012.html#___sec11" style="font-size: 80%;">Schematic Regression Procedure</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs013.html#___sec12" style="font-size: 80%;">A Classification Tree</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs014.html#___sec13" style="font-size: 80%;">Growing a classification tree</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs015.html#___sec14" style="font-size: 80%;">Classification tree, how to split nodes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs016.html#___sec15" style="font-size: 80%;">Visualizing the Tree, Classification</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs017.html#___sec16" style="font-size: 80%;">Visualizing the Tree, The Moons</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs018.html#___sec17" style="font-size: 80%;">Computing the Gini index</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs019.html#___sec18" style="font-size: 80%;">Simple Python Code to read in Data</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs020.html#___sec19" style="font-size: 80%;">Computing the Gini Factor</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs021.html#___sec20" style="font-size: 80%;">Entropy and the ID3 algorithm</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs022.html#___sec21" style="font-size: 80%;">Implementing the ID3 Algorithm</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs023.html#___sec22" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs024.html#___sec23" style="font-size: 80%;">Another example, the moons again</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs025.html#___sec24" style="font-size: 80%;">Playing around with regions</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs026.html#___sec25" style="font-size: 80%;">Regression trees</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs027.html#___sec26" style="font-size: 80%;">Final regressor code</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Pros and cons of trees, pros</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec37" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs003.html#___sec2" style="font-size: 80%;">General Features</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs004.html#___sec3" style="font-size: 80%;">How do we set it up?</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs005.html#___sec4" style="font-size: 80%;">Decision trees and Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs006.html#___sec5" style="font-size: 80%;">Building a tree, regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs007.html#___sec6" style="font-size: 80%;">A top-down approach, recursive binary splitting</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs008.html#___sec7" style="font-size: 80%;">Making a tree</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs009.html#___sec8" style="font-size: 80%;">Pruning the tree</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs010.html#___sec9" style="font-size: 80%;">Cost complexity pruning</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs011.html#___sec10" style="font-size: 80%;">Schematic Regression Procedure</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs012.html#___sec11" style="font-size: 80%;">A Classification Tree</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs013.html#___sec12" style="font-size: 80%;">Growing a classification tree</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs014.html#___sec13" style="font-size: 80%;">Classification tree, how to split nodes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs015.html#___sec14" style="font-size: 80%;">Visualizing the Tree, Classification</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs016.html#___sec15" style="font-size: 80%;">Visualizing the Tree, The Moons</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs017.html#___sec16" style="font-size: 80%;">Computing the Gini index</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs018.html#___sec17" style="font-size: 80%;">Simple Python Code to read in Data and perform Classification</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs019.html#___sec18" style="font-size: 80%;">Computing the Gini Factor</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs020.html#___sec19" style="font-size: 80%;">Entropy and the ID3 algorithm</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs021.html#___sec20" style="font-size: 80%;">Implementing the ID3 Algorithm</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs022.html#___sec21" style="font-size: 80%;">Cancer Data again now with Decision Trees and other Methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs023.html#___sec22" style="font-size: 80%;">Another example, the moons again</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs024.html#___sec23" style="font-size: 80%;">Playing around with regions</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs025.html#___sec24" style="font-size: 80%;">Regression trees</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs026.html#___sec25" style="font-size: 80%;">Final regressor code</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs027.html#___sec26" style="font-size: 80%;">Pros and cons of trees, pros</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -183,27 +189,37 @@ MathJax.Hub.Config({
|
||||
<a name="part0038"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="___sec37" class="anchor">Then random forests </h2>
|
||||
<h2 id="___sec37" class="anchor">Feature Importance </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>bag_clf <span style="color: #666666">=</span> BaggingClassifier(
|
||||
DecisionTreeClassifier(splitter<span style="color: #666666">=</span><span style="color: #BA2121">"random"</span>, max_leaf_nodes<span style="color: #666666">=16</span>, random_state<span style="color: #666666">=42</span>),
|
||||
n_estimators<span style="color: #666666">=500</span>, max_samples<span style="color: #666666">=1.0</span>, bootstrap<span style="color: #666666">=</span><span style="color: #008000">True</span>, n_jobs<span style="color: #666666">=-1</span>, random_state<span style="color: #666666">=42</span>)
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">try</span>:
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.datasets</span> <span style="color: #008000; font-weight: bold">import</span> fetch_openml
|
||||
mnist <span style="color: #666666">=</span> fetch_openml(<span style="color: #BA2121">'mnist_784'</span>, version<span style="color: #666666">=1</span>)
|
||||
mnist<span style="color: #666666">.</span>target <span style="color: #666666">=</span> mnist<span style="color: #666666">.</span>target<span style="color: #666666">.</span>astype(np<span style="color: #666666">.</span>int64)
|
||||
<span style="color: #008000; font-weight: bold">except</span> <span style="color: #D2413A; font-weight: bold">ImportError</span>:
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.datasets</span> <span style="color: #008000; font-weight: bold">import</span> fetch_mldata
|
||||
mnist <span style="color: #666666">=</span> fetch_mldata(<span style="color: #BA2121">'MNIST original'</span>)
|
||||
|
||||
rnd_clf <span style="color: #666666">=</span> RandomForestClassifier(n_estimators<span style="color: #666666">=10</span>, random_state<span style="color: #666666">=42</span>)
|
||||
rnd_clf<span style="color: #666666">.</span>fit(mnist[<span style="color: #BA2121">"data"</span>], mnist[<span style="color: #BA2121">"target"</span>])
|
||||
|
||||
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">plot_digit</span>(data):
|
||||
image <span style="color: #666666">=</span> data<span style="color: #666666">.</span>reshape(<span style="color: #666666">28</span>, <span style="color: #666666">28</span>)
|
||||
plt<span style="color: #666666">.</span>imshow(image, cmap <span style="color: #666666">=</span> mpl<span style="color: #666666">.</span>cm<span style="color: #666666">.</span>hot,
|
||||
interpolation<span style="color: #666666">=</span><span style="color: #BA2121">"nearest"</span>)
|
||||
plt<span style="color: #666666">.</span>axis(<span style="color: #BA2121">"off"</span>)
|
||||
|
||||
plot_digit(rnd_clf<span style="color: #666666">.</span>feature_importances_)
|
||||
|
||||
cbar <span style="color: #666666">=</span> plt<span style="color: #666666">.</span>colorbar(ticks<span style="color: #666666">=</span>[rnd_clf<span style="color: #666666">.</span>feature_importances_<span style="color: #666666">.</span>min(), rnd_clf<span style="color: #666666">.</span>feature_importances_<span style="color: #666666">.</span>max()])
|
||||
cbar<span style="color: #666666">.</span>ax<span style="color: #666666">.</span>set_yticklabels([<span style="color: #BA2121">'Not important'</span>, <span style="color: #BA2121">'Very important'</span>])
|
||||
|
||||
<span style="color: #408080; font-style: italic">#save_fig("mnist_feature_importance_plot")</span>
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>bag_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
y_pred <span style="color: #666666">=</span> bag_clf<span style="color: #666666">.</span>predict(X_test)
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.ensemble</span> <span style="color: #008000; font-weight: bold">import</span> RandomForestClassifier
|
||||
rnd_clf <span style="color: #666666">=</span> RandomForestClassifier(n_estimators<span style="color: #666666">=500</span>, max_leaf_nodes<span style="color: #666666">=16</span>, n_jobs<span style="color: #666666">=-1</span>, random_state<span style="color: #666666">=42</span>)
|
||||
rnd_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
y_pred_rf <span style="color: #666666">=</span> rnd_clf<span style="color: #666666">.</span>predict(X_test)
|
||||
np<span style="color: #666666">.</span>sum(y_pred <span style="color: #666666">==</span> y_pred_rf) <span style="color: #666666">/</span> <span style="color: #008000">len</span>(y_pred)
|
||||
</pre></div>
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -219,6 +235,9 @@ np<span style="color: #666666">.</span>sum(y_pred <span style="color: #666666">=
|
||||
<li><a href="._DecisionTrees-bs036.html">37</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li class="active"><a href="._DecisionTrees-bs038.html">39</a></li>
|
||||
<li><a href="._DecisionTrees-bs039.html">40</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs039.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
|
||||
@@ -84,13 +84,19 @@ Automatically generated HTML file from DocOnce source
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -158,13 +164,16 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs028.html#___sec27" style="font-size: 80%;">Disadvantages</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs029.html#___sec28" style="font-size: 80%;">Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs030.html#___sec29" style="font-size: 80%;">More bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Bagging Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Please, not the moons again!</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">Bagging examples</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs031.html#___sec30" style="font-size: 80%;">Simple Voting Example, head or tail</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs032.html#___sec31" style="font-size: 80%;">Using the Voting Classifier</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs033.html#___sec32" style="font-size: 80%;">Please, not the moons again! Voting and Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs034.html#___sec33" style="font-size: 80%;">Now Bagging</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs035.html#___sec34" style="font-size: 80%;">Random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs036.html#___sec35" style="font-size: 80%;">A simple scikit-learn example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs037.html#___sec36" style="font-size: 80%;">Then random forests</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs038.html#___sec37" style="font-size: 80%;">Feature Importance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs039.html#___sec38" style="font-size: 80%;">Boosting: AdaBoost</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._DecisionTrees-bs040.html#___sec39" style="font-size: 80%;">Gradient Boosting</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -199,7 +208,7 @@ MathJax.Hub.Config({
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Oct 31, 2019</h4></center> <!-- date -->
|
||||
<center><h4>Nov 1, 2019</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
|
||||
@@ -223,7 +232,7 @@ MathJax.Hub.Config({
|
||||
<li><a href="._DecisionTrees-bs008.html">9</a></li>
|
||||
<li><a href="._DecisionTrees-bs009.html">10</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._DecisionTrees-bs037.html">38</a></li>
|
||||
<li><a href="._DecisionTrees-bs040.html">41</a></li>
|
||||
<li><a href="._DecisionTrees-bs001.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -148,7 +148,7 @@ MathJax.Hub.Config({
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p> <br>
|
||||
<center><h4>Oct 31, 2019</h4></center> <!-- date -->
|
||||
<center><h4>Nov 1, 2019</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
|
||||
@@ -1457,7 +1457,7 @@ predictor, averaged over all \( B \) trees.
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec30">Simple example, head or tail </h2>
|
||||
<h2 id="___sec30">Simple Voting Example, head or tail </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
@@ -1478,7 +1478,7 @@ plt.show()
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec31">Bagging Example </h2>
|
||||
<h2 id="___sec31">Using the Voting Classifier </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
@@ -1530,72 +1530,7 @@ voting_clf.fit(X_train, y_train)
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec32">Random forests </h2>
|
||||
|
||||
<p>
|
||||
Random forests provide an improvement over bagged trees by way of a
|
||||
small tweak that decorrelates the trees.
|
||||
|
||||
<p>
|
||||
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.
|
||||
|
||||
<p>
|
||||
A fresh sample of \( m \) predictors is
|
||||
taken at each split, and typically we choose
|
||||
|
||||
<p> <br>
|
||||
$$
|
||||
m\approx \sqrt{p}.
|
||||
$$
|
||||
<p> <br>
|
||||
|
||||
<p>
|
||||
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.
|
||||
|
||||
<p>
|
||||
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 quanti- ties. In particular, this means that bagging will
|
||||
not lead to a substantial reduction in variance over a single tree in
|
||||
this setting.
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec33">A simple scikit-learn example </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.ensemble</span> <span style="color: #8B008B; font-weight: bold">import</span> RandomForestClassifier
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.preprocessing</span> <span style="color: #8B008B; font-weight: bold">import</span> LabelEncoder
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.model_selection</span> <span style="color: #8B008B; font-weight: bold">import</span> cross_validate
|
||||
<span style="color: #228B22"># Data set not specificied</span>
|
||||
X = dataset.XXX
|
||||
Y = dataset.YYY
|
||||
<span style="color: #228B22">#Instantiate the model with 100 trees and entropy as splitting criteria</span>
|
||||
Random_Forest_model = RandomForestClassifier(n_estimators=<span style="color: #B452CD">100</span>,criterion=<span style="color: #CD5555">"entropy"</span>)
|
||||
<span style="color: #228B22">#Cross validation</span>
|
||||
accuracy = cross_validate(Random_Forest_model,X,Y,cv=<span style="color: #B452CD">10</span>)[<span style="color: #CD5555">'test_score'</span>]
|
||||
</pre></div>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec34">Please, not the moons again! </h2>
|
||||
<h2 id="___sec32">Please, not the moons again! Voting and Bagging </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
@@ -1654,7 +1589,7 @@ voting_clf.fit(X_train, y_train)
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec35">Bagging examples </h2>
|
||||
<h2 id="___sec33">Now Bagging </h2>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -1715,6 +1650,71 @@ plt.show()
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec34">Random forests </h2>
|
||||
|
||||
<p>
|
||||
Random forests provide an improvement over bagged trees by way of a
|
||||
small tweak that decorrelates the trees.
|
||||
|
||||
<p>
|
||||
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.
|
||||
|
||||
<p>
|
||||
A fresh sample of \( m \) predictors is
|
||||
taken at each split, and typically we choose
|
||||
|
||||
<p> <br>
|
||||
$$
|
||||
m\approx \sqrt{p}.
|
||||
$$
|
||||
<p> <br>
|
||||
|
||||
<p>
|
||||
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.
|
||||
|
||||
<p>
|
||||
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 quanti- ties. In particular, this means that bagging will
|
||||
not lead to a substantial reduction in variance over a single tree in
|
||||
this setting.
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec35">A simple scikit-learn example </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.ensemble</span> <span style="color: #8B008B; font-weight: bold">import</span> RandomForestClassifier
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.preprocessing</span> <span style="color: #8B008B; font-weight: bold">import</span> LabelEncoder
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.model_selection</span> <span style="color: #8B008B; font-weight: bold">import</span> cross_validate
|
||||
<span style="color: #228B22"># Data set not specificied</span>
|
||||
X = dataset.XXX
|
||||
Y = dataset.YYY
|
||||
<span style="color: #228B22">#Instantiate the model with 100 trees and entropy as splitting criteria</span>
|
||||
Random_Forest_model = RandomForestClassifier(n_estimators=<span style="color: #B452CD">100</span>,criterion=<span style="color: #CD5555">"entropy"</span>)
|
||||
<span style="color: #228B22">#Cross validation</span>
|
||||
accuracy = cross_validate(Random_Forest_model,X,Y,cv=<span style="color: #B452CD">10</span>)[<span style="color: #CD5555">'test_score'</span>]
|
||||
</pre></div>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec36">Then random forests </h2>
|
||||
<p>
|
||||
@@ -1738,6 +1738,172 @@ np.sum(y_pred == y_pred_rf) / <span style="color: #658b00">len</span>(y_pred)
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec37">Feature Importance </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">try</span>:
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.datasets</span> <span style="color: #8B008B; font-weight: bold">import</span> fetch_openml
|
||||
mnist = fetch_openml(<span style="color: #CD5555">'mnist_784'</span>, version=<span style="color: #B452CD">1</span>)
|
||||
mnist.target = mnist.target.astype(np.int64)
|
||||
<span style="color: #8B008B; font-weight: bold">except</span> <span style="color: #008b45; font-weight: bold">ImportError</span>:
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.datasets</span> <span style="color: #8B008B; font-weight: bold">import</span> fetch_mldata
|
||||
mnist = fetch_mldata(<span style="color: #CD5555">'MNIST original'</span>)
|
||||
|
||||
rnd_clf = RandomForestClassifier(n_estimators=<span style="color: #B452CD">10</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
rnd_clf.fit(mnist[<span style="color: #CD5555">"data"</span>], mnist[<span style="color: #CD5555">"target"</span>])
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">def</span> <span style="color: #008b45">plot_digit</span>(data):
|
||||
image = data.reshape(<span style="color: #B452CD">28</span>, <span style="color: #B452CD">28</span>)
|
||||
plt.imshow(image, cmap = mpl.cm.hot,
|
||||
interpolation=<span style="color: #CD5555">"nearest"</span>)
|
||||
plt.axis(<span style="color: #CD5555">"off"</span>)
|
||||
|
||||
plot_digit(rnd_clf.feature_importances_)
|
||||
|
||||
cbar = plt.colorbar(ticks=[rnd_clf.feature_importances_.min(), rnd_clf.feature_importances_.max()])
|
||||
cbar.ax.set_yticklabels([<span style="color: #CD5555">'Not important'</span>, <span style="color: #CD5555">'Very important'</span>])
|
||||
|
||||
<span style="color: #228B22">#save_fig("mnist_feature_importance_plot")</span>
|
||||
plt.show()
|
||||
</pre></div>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec38">Boosting: AdaBoost </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.ensemble</span> <span style="color: #8B008B; font-weight: bold">import</span> AdaBoostClassifier
|
||||
|
||||
ada_clf = AdaBoostClassifier(
|
||||
DecisionTreeClassifier(max_depth=<span style="color: #B452CD">1</span>), n_estimators=<span style="color: #B452CD">200</span>,
|
||||
algorithm=<span style="color: #CD5555">"SAMME.R"</span>, learning_rate=<span style="color: #B452CD">0.5</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
ada_clf.fit(X_train, y_train)
|
||||
|
||||
plot_decision_boundary(ada_clf, X, y)
|
||||
|
||||
m = <span style="color: #658b00">len</span>(X_train)
|
||||
|
||||
plt.figure(figsize=(<span style="color: #B452CD">11</span>, <span style="color: #B452CD">4</span>))
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> subplot, learning_rate <span style="color: #8B008B">in</span> ((<span style="color: #B452CD">121</span>, <span style="color: #B452CD">1</span>), (<span style="color: #B452CD">122</span>, <span style="color: #B452CD">0.5</span>)):
|
||||
sample_weights = np.ones(m)
|
||||
plt.subplot(subplot)
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> i <span style="color: #8B008B">in</span> <span style="color: #658b00">range</span>(<span style="color: #B452CD">5</span>):
|
||||
svm_clf = SVC(kernel=<span style="color: #CD5555">"rbf"</span>, C=<span style="color: #B452CD">0.05</span>, gamma=<span style="color: #CD5555">"auto"</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
svm_clf.fit(X_train, y_train, sample_weight=sample_weights)
|
||||
y_pred = svm_clf.predict(X_train)
|
||||
sample_weights[y_pred != y_train] *= (<span style="color: #B452CD">1</span> + learning_rate)
|
||||
plot_decision_boundary(svm_clf, X, y, alpha=<span style="color: #B452CD">0.2</span>)
|
||||
plt.title(<span style="color: #CD5555">"learning_rate = {}"</span>.format(learning_rate), fontsize=<span style="color: #B452CD">16</span>)
|
||||
<span style="color: #8B008B; font-weight: bold">if</span> subplot == <span style="color: #B452CD">121</span>:
|
||||
plt.text(-<span style="color: #B452CD">0.7</span>, -<span style="color: #B452CD">0.65</span>, <span style="color: #CD5555">"1"</span>, fontsize=<span style="color: #B452CD">14</span>)
|
||||
plt.text(-<span style="color: #B452CD">0.6</span>, -<span style="color: #B452CD">0.10</span>, <span style="color: #CD5555">"2"</span>, fontsize=<span style="color: #B452CD">14</span>)
|
||||
plt.text(-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.10</span>, <span style="color: #CD5555">"3"</span>, fontsize=<span style="color: #B452CD">14</span>)
|
||||
plt.text(-<span style="color: #B452CD">0.4</span>, <span style="color: #B452CD">0.55</span>, <span style="color: #CD5555">"4"</span>, fontsize=<span style="color: #B452CD">14</span>)
|
||||
plt.text(-<span style="color: #B452CD">0.3</span>, <span style="color: #B452CD">0.90</span>, <span style="color: #CD5555">"5"</span>, fontsize=<span style="color: #B452CD">14</span>)
|
||||
|
||||
save_fig(<span style="color: #CD5555">"boosting_plot"</span>)
|
||||
plt.show()
|
||||
</pre></div>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="___sec39">Gradient Boosting </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="font-size: 80%; line-height: 125%"><span></span>np.random.seed(<span style="color: #B452CD">42</span>)
|
||||
X = np.random.rand(<span style="color: #B452CD">100</span>, <span style="color: #B452CD">1</span>) - <span style="color: #B452CD">0.5</span>
|
||||
y = <span style="color: #B452CD">3</span>*X[:, <span style="color: #B452CD">0</span>]**<span style="color: #B452CD">2</span> + <span style="color: #B452CD">0.05</span> * np.random.randn(<span style="color: #B452CD">100</span>)
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.tree</span> <span style="color: #8B008B; font-weight: bold">import</span> DecisionTreeRegressor
|
||||
|
||||
tree_reg1 = DecisionTreeRegressor(max_depth=<span style="color: #B452CD">2</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
tree_reg1.fit(X, y)
|
||||
|
||||
y2 = y - tree_reg1.predict(X)
|
||||
tree_reg2 = DecisionTreeRegressor(max_depth=<span style="color: #B452CD">2</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
tree_reg2.fit(X, y2)
|
||||
|
||||
y3 = y2 - tree_reg2.predict(X)
|
||||
tree_reg3 = DecisionTreeRegressor(max_depth=<span style="color: #B452CD">2</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
tree_reg3.fit(X, y3)
|
||||
|
||||
X_new = np.array([[<span style="color: #B452CD">0.8</span>]])
|
||||
y_pred = <span style="color: #658b00">sum</span>(tree.predict(X_new) <span style="color: #8B008B; font-weight: bold">for</span> tree <span style="color: #8B008B">in</span> (tree_reg1, tree_reg2, tree_reg3))
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">def</span> <span style="color: #008b45">plot_predictions</span>(regressors, X, y, axes, label=<span style="color: #658b00">None</span>, style=<span style="color: #CD5555">"r-"</span>, data_style=<span style="color: #CD5555">"b."</span>, data_label=<span style="color: #658b00">None</span>):
|
||||
x1 = np.linspace(axes[<span style="color: #B452CD">0</span>], axes[<span style="color: #B452CD">1</span>], <span style="color: #B452CD">500</span>)
|
||||
y_pred = <span style="color: #658b00">sum</span>(regressor.predict(x1.reshape(-<span style="color: #B452CD">1</span>, <span style="color: #B452CD">1</span>)) <span style="color: #8B008B; font-weight: bold">for</span> regressor <span style="color: #8B008B">in</span> regressors)
|
||||
plt.plot(X[:, <span style="color: #B452CD">0</span>], y, data_style, label=data_label)
|
||||
plt.plot(x1, y_pred, style, linewidth=<span style="color: #B452CD">2</span>, label=label)
|
||||
<span style="color: #8B008B; font-weight: bold">if</span> label <span style="color: #8B008B">or</span> data_label:
|
||||
plt.legend(loc=<span style="color: #CD5555">"upper center"</span>, fontsize=<span style="color: #B452CD">16</span>)
|
||||
plt.axis(axes)
|
||||
|
||||
plt.figure(figsize=(<span style="color: #B452CD">11</span>,<span style="color: #B452CD">11</span>))
|
||||
|
||||
plt.subplot(<span style="color: #B452CD">321</span>)
|
||||
plot_predictions([tree_reg1], X, y, axes=[-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>, -<span style="color: #B452CD">0.1</span>, <span style="color: #B452CD">0.8</span>], label=<span style="color: #CD5555">"$h_1(x_1)$"</span>, style=<span style="color: #CD5555">"g-"</span>, data_label=<span style="color: #CD5555">"Training set"</span>)
|
||||
plt.ylabel(<span style="color: #CD5555">"$y$"</span>, fontsize=<span style="color: #B452CD">16</span>, rotation=<span style="color: #B452CD">0</span>)
|
||||
plt.title(<span style="color: #CD5555">"Residuals and tree predictions"</span>, fontsize=<span style="color: #B452CD">16</span>)
|
||||
|
||||
plt.subplot(<span style="color: #B452CD">322</span>)
|
||||
plot_predictions([tree_reg1], X, y, axes=[-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>, -<span style="color: #B452CD">0.1</span>, <span style="color: #B452CD">0.8</span>], label=<span style="color: #CD5555">"$h(x_1) = h_1(x_1)$"</span>, data_label=<span style="color: #CD5555">"Training set"</span>)
|
||||
plt.ylabel(<span style="color: #CD5555">"$y$"</span>, fontsize=<span style="color: #B452CD">16</span>, rotation=<span style="color: #B452CD">0</span>)
|
||||
plt.title(<span style="color: #CD5555">"Ensemble predictions"</span>, fontsize=<span style="color: #B452CD">16</span>)
|
||||
|
||||
plt.subplot(<span style="color: #B452CD">323</span>)
|
||||
plot_predictions([tree_reg2], X, y2, axes=[-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>, -<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>], label=<span style="color: #CD5555">"$h_2(x_1)$"</span>, style=<span style="color: #CD5555">"g-"</span>, data_style=<span style="color: #CD5555">"k+"</span>, data_label=<span style="color: #CD5555">"Residuals"</span>)
|
||||
plt.ylabel(<span style="color: #CD5555">"$y - h_1(x_1)$"</span>, fontsize=<span style="color: #B452CD">16</span>)
|
||||
|
||||
plt.subplot(<span style="color: #B452CD">324</span>)
|
||||
plot_predictions([tree_reg1, tree_reg2], X, y, axes=[-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>, -<span style="color: #B452CD">0.1</span>, <span style="color: #B452CD">0.8</span>], label=<span style="color: #CD5555">"$h(x_1) = h_1(x_1) + h_2(x_1)$"</span>)
|
||||
plt.ylabel(<span style="color: #CD5555">"$y$"</span>, fontsize=<span style="color: #B452CD">16</span>, rotation=<span style="color: #B452CD">0</span>)
|
||||
|
||||
plt.subplot(<span style="color: #B452CD">325</span>)
|
||||
plot_predictions([tree_reg3], X, y3, axes=[-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>, -<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>], label=<span style="color: #CD5555">"$h_3(x_1)$"</span>, style=<span style="color: #CD5555">"g-"</span>, data_style=<span style="color: #CD5555">"k+"</span>)
|
||||
plt.ylabel(<span style="color: #CD5555">"$y - h_1(x_1) - h_2(x_1)$"</span>, fontsize=<span style="color: #B452CD">16</span>)
|
||||
plt.xlabel(<span style="color: #CD5555">"$x_1$"</span>, fontsize=<span style="color: #B452CD">16</span>)
|
||||
|
||||
plt.subplot(<span style="color: #B452CD">326</span>)
|
||||
plot_predictions([tree_reg1, tree_reg2, tree_reg3], X, y, axes=[-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>, -<span style="color: #B452CD">0.1</span>, <span style="color: #B452CD">0.8</span>], label=<span style="color: #CD5555">"$h(x_1) = h_1(x_1) + h_2(x_1) + h_3(x_1)$"</span>)
|
||||
plt.xlabel(<span style="color: #CD5555">"$x_1$"</span>, fontsize=<span style="color: #B452CD">16</span>)
|
||||
plt.ylabel(<span style="color: #CD5555">"$y$"</span>, fontsize=<span style="color: #B452CD">16</span>, rotation=<span style="color: #B452CD">0</span>)
|
||||
|
||||
save_fig(<span style="color: #CD5555">"gradient_boosting_plot"</span>)
|
||||
plt.show()
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.ensemble</span> <span style="color: #8B008B; font-weight: bold">import</span> GradientBoostingRegressor
|
||||
|
||||
gbrt = GradientBoostingRegressor(max_depth=<span style="color: #B452CD">2</span>, n_estimators=<span style="color: #B452CD">3</span>, learning_rate=<span style="color: #B452CD">1.0</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
gbrt.fit(X, y)
|
||||
|
||||
gbrt_slow = GradientBoostingRegressor(max_depth=<span style="color: #B452CD">2</span>, n_estimators=<span style="color: #B452CD">200</span>, learning_rate=<span style="color: #B452CD">0.1</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
gbrt_slow.fit(X, y)
|
||||
|
||||
plt.figure(figsize=(<span style="color: #B452CD">11</span>,<span style="color: #B452CD">4</span>))
|
||||
|
||||
plt.subplot(<span style="color: #B452CD">121</span>)
|
||||
plot_predictions([gbrt], X, y, axes=[-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>, -<span style="color: #B452CD">0.1</span>, <span style="color: #B452CD">0.8</span>], label=<span style="color: #CD5555">"Ensemble predictions"</span>)
|
||||
plt.title(<span style="color: #CD5555">"learning_rate={}, n_estimators={}"</span>.format(gbrt.learning_rate, gbrt.n_estimators), fontsize=<span style="color: #B452CD">14</span>)
|
||||
|
||||
plt.subplot(<span style="color: #B452CD">122</span>)
|
||||
plot_predictions([gbrt_slow], X, y, axes=[-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>, -<span style="color: #B452CD">0.1</span>, <span style="color: #B452CD">0.8</span>])
|
||||
plt.title(<span style="color: #CD5555">"learning_rate={}, n_estimators={}"</span>.format(gbrt_slow.learning_rate, gbrt_slow.n_estimators), fontsize=<span style="color: #B452CD">14</span>)
|
||||
|
||||
save_fig(<span style="color: #CD5555">"gbrt_learning_rate_plot"</span>)
|
||||
plt.show()
|
||||
</pre></div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
</div> <!-- class="slides" -->
|
||||
</div> <!-- class="reveal" -->
|
||||
|
||||
@@ -104,13 +104,19 @@ div { text-align: justify; text-justify: inter-word; }
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -152,7 +158,7 @@ MathJax.Hub.Config({
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Oct 31, 2019</h4></center> <!-- date -->
|
||||
<center><h4>Nov 1, 2019</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
@@ -1422,7 +1428,7 @@ predictor, averaged over all \( B \) trees.
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec30">Simple example, head or tail </h2>
|
||||
<h2 id="___sec30">Simple Voting Example, head or tail </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
@@ -1442,7 +1448,7 @@ plt.show()
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec31">Bagging Example </h2>
|
||||
<h2 id="___sec31">Using the Voting Classifier </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
@@ -1493,69 +1499,7 @@ voting_clf.fit(X_train, y_train)
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec32">Random forests </h2>
|
||||
|
||||
<p>
|
||||
Random forests provide an improvement over bagged trees by way of a
|
||||
small tweak that decorrelates the trees.
|
||||
|
||||
<p>
|
||||
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.
|
||||
|
||||
<p>
|
||||
A fresh sample of \( m \) predictors is
|
||||
taken at each split, and typically we choose
|
||||
|
||||
$$
|
||||
m\approx \sqrt{p}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
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.
|
||||
|
||||
<p>
|
||||
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 quanti- ties. In particular, this means that bagging will
|
||||
not lead to a substantial reduction in variance over a single tree in
|
||||
this setting.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec33">A simple scikit-learn example </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.ensemble</span> <span style="color: #8B008B; font-weight: bold">import</span> RandomForestClassifier
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.preprocessing</span> <span style="color: #8B008B; font-weight: bold">import</span> LabelEncoder
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.model_selection</span> <span style="color: #8B008B; font-weight: bold">import</span> cross_validate
|
||||
<span style="color: #228B22"># Data set not specificied</span>
|
||||
X = dataset.XXX
|
||||
Y = dataset.YYY
|
||||
<span style="color: #228B22">#Instantiate the model with 100 trees and entropy as splitting criteria</span>
|
||||
Random_Forest_model = RandomForestClassifier(n_estimators=<span style="color: #B452CD">100</span>,criterion=<span style="color: #CD5555">"entropy"</span>)
|
||||
<span style="color: #228B22">#Cross validation</span>
|
||||
accuracy = cross_validate(Random_Forest_model,X,Y,cv=<span style="color: #B452CD">10</span>)[<span style="color: #CD5555">'test_score'</span>]
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec34">Please, not the moons again! </h2>
|
||||
<h2 id="___sec32">Please, not the moons again! Voting and Bagging </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
@@ -1613,7 +1557,7 @@ voting_clf.fit(X_train, y_train)
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec35">Bagging examples </h2>
|
||||
<h2 id="___sec33">Now Bagging </h2>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -1674,6 +1618,68 @@ plt.show()
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec34">Random forests </h2>
|
||||
|
||||
<p>
|
||||
Random forests provide an improvement over bagged trees by way of a
|
||||
small tweak that decorrelates the trees.
|
||||
|
||||
<p>
|
||||
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.
|
||||
|
||||
<p>
|
||||
A fresh sample of \( m \) predictors is
|
||||
taken at each split, and typically we choose
|
||||
|
||||
$$
|
||||
m\approx \sqrt{p}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
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.
|
||||
|
||||
<p>
|
||||
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 quanti- ties. In particular, this means that bagging will
|
||||
not lead to a substantial reduction in variance over a single tree in
|
||||
this setting.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec35">A simple scikit-learn example </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.ensemble</span> <span style="color: #8B008B; font-weight: bold">import</span> RandomForestClassifier
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.preprocessing</span> <span style="color: #8B008B; font-weight: bold">import</span> LabelEncoder
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.model_selection</span> <span style="color: #8B008B; font-weight: bold">import</span> cross_validate
|
||||
<span style="color: #228B22"># Data set not specificied</span>
|
||||
X = dataset.XXX
|
||||
Y = dataset.YYY
|
||||
<span style="color: #228B22">#Instantiate the model with 100 trees and entropy as splitting criteria</span>
|
||||
Random_Forest_model = RandomForestClassifier(n_estimators=<span style="color: #B452CD">100</span>,criterion=<span style="color: #CD5555">"entropy"</span>)
|
||||
<span style="color: #228B22">#Cross validation</span>
|
||||
accuracy = cross_validate(Random_Forest_model,X,Y,cv=<span style="color: #B452CD">10</span>)[<span style="color: #CD5555">'test_score'</span>]
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec36">Then random forests </h2>
|
||||
<p>
|
||||
|
||||
@@ -1694,6 +1700,169 @@ y_pred_rf = rnd_clf.predict(X_test)
|
||||
np.sum(y_pred == y_pred_rf) / <span style="color: #658b00">len</span>(y_pred)
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec37">Feature Importance </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">try</span>:
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.datasets</span> <span style="color: #8B008B; font-weight: bold">import</span> fetch_openml
|
||||
mnist = fetch_openml(<span style="color: #CD5555">'mnist_784'</span>, version=<span style="color: #B452CD">1</span>)
|
||||
mnist.target = mnist.target.astype(np.int64)
|
||||
<span style="color: #8B008B; font-weight: bold">except</span> <span style="color: #008b45; font-weight: bold">ImportError</span>:
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.datasets</span> <span style="color: #8B008B; font-weight: bold">import</span> fetch_mldata
|
||||
mnist = fetch_mldata(<span style="color: #CD5555">'MNIST original'</span>)
|
||||
|
||||
rnd_clf = RandomForestClassifier(n_estimators=<span style="color: #B452CD">10</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
rnd_clf.fit(mnist[<span style="color: #CD5555">"data"</span>], mnist[<span style="color: #CD5555">"target"</span>])
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">def</span> <span style="color: #008b45">plot_digit</span>(data):
|
||||
image = data.reshape(<span style="color: #B452CD">28</span>, <span style="color: #B452CD">28</span>)
|
||||
plt.imshow(image, cmap = mpl.cm.hot,
|
||||
interpolation=<span style="color: #CD5555">"nearest"</span>)
|
||||
plt.axis(<span style="color: #CD5555">"off"</span>)
|
||||
|
||||
plot_digit(rnd_clf.feature_importances_)
|
||||
|
||||
cbar = plt.colorbar(ticks=[rnd_clf.feature_importances_.min(), rnd_clf.feature_importances_.max()])
|
||||
cbar.ax.set_yticklabels([<span style="color: #CD5555">'Not important'</span>, <span style="color: #CD5555">'Very important'</span>])
|
||||
|
||||
<span style="color: #228B22">#save_fig("mnist_feature_importance_plot")</span>
|
||||
plt.show()
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec38">Boosting: AdaBoost </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span><span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.ensemble</span> <span style="color: #8B008B; font-weight: bold">import</span> AdaBoostClassifier
|
||||
|
||||
ada_clf = AdaBoostClassifier(
|
||||
DecisionTreeClassifier(max_depth=<span style="color: #B452CD">1</span>), n_estimators=<span style="color: #B452CD">200</span>,
|
||||
algorithm=<span style="color: #CD5555">"SAMME.R"</span>, learning_rate=<span style="color: #B452CD">0.5</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
ada_clf.fit(X_train, y_train)
|
||||
|
||||
plot_decision_boundary(ada_clf, X, y)
|
||||
|
||||
m = <span style="color: #658b00">len</span>(X_train)
|
||||
|
||||
plt.figure(figsize=(<span style="color: #B452CD">11</span>, <span style="color: #B452CD">4</span>))
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> subplot, learning_rate <span style="color: #8B008B">in</span> ((<span style="color: #B452CD">121</span>, <span style="color: #B452CD">1</span>), (<span style="color: #B452CD">122</span>, <span style="color: #B452CD">0.5</span>)):
|
||||
sample_weights = np.ones(m)
|
||||
plt.subplot(subplot)
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> i <span style="color: #8B008B">in</span> <span style="color: #658b00">range</span>(<span style="color: #B452CD">5</span>):
|
||||
svm_clf = SVC(kernel=<span style="color: #CD5555">"rbf"</span>, C=<span style="color: #B452CD">0.05</span>, gamma=<span style="color: #CD5555">"auto"</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
svm_clf.fit(X_train, y_train, sample_weight=sample_weights)
|
||||
y_pred = svm_clf.predict(X_train)
|
||||
sample_weights[y_pred != y_train] *= (<span style="color: #B452CD">1</span> + learning_rate)
|
||||
plot_decision_boundary(svm_clf, X, y, alpha=<span style="color: #B452CD">0.2</span>)
|
||||
plt.title(<span style="color: #CD5555">"learning_rate = {}"</span>.format(learning_rate), fontsize=<span style="color: #B452CD">16</span>)
|
||||
<span style="color: #8B008B; font-weight: bold">if</span> subplot == <span style="color: #B452CD">121</span>:
|
||||
plt.text(-<span style="color: #B452CD">0.7</span>, -<span style="color: #B452CD">0.65</span>, <span style="color: #CD5555">"1"</span>, fontsize=<span style="color: #B452CD">14</span>)
|
||||
plt.text(-<span style="color: #B452CD">0.6</span>, -<span style="color: #B452CD">0.10</span>, <span style="color: #CD5555">"2"</span>, fontsize=<span style="color: #B452CD">14</span>)
|
||||
plt.text(-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.10</span>, <span style="color: #CD5555">"3"</span>, fontsize=<span style="color: #B452CD">14</span>)
|
||||
plt.text(-<span style="color: #B452CD">0.4</span>, <span style="color: #B452CD">0.55</span>, <span style="color: #CD5555">"4"</span>, fontsize=<span style="color: #B452CD">14</span>)
|
||||
plt.text(-<span style="color: #B452CD">0.3</span>, <span style="color: #B452CD">0.90</span>, <span style="color: #CD5555">"5"</span>, fontsize=<span style="color: #B452CD">14</span>)
|
||||
|
||||
save_fig(<span style="color: #CD5555">"boosting_plot"</span>)
|
||||
plt.show()
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec39">Gradient Boosting </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span>np.random.seed(<span style="color: #B452CD">42</span>)
|
||||
X = np.random.rand(<span style="color: #B452CD">100</span>, <span style="color: #B452CD">1</span>) - <span style="color: #B452CD">0.5</span>
|
||||
y = <span style="color: #B452CD">3</span>*X[:, <span style="color: #B452CD">0</span>]**<span style="color: #B452CD">2</span> + <span style="color: #B452CD">0.05</span> * np.random.randn(<span style="color: #B452CD">100</span>)
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.tree</span> <span style="color: #8B008B; font-weight: bold">import</span> DecisionTreeRegressor
|
||||
|
||||
tree_reg1 = DecisionTreeRegressor(max_depth=<span style="color: #B452CD">2</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
tree_reg1.fit(X, y)
|
||||
|
||||
y2 = y - tree_reg1.predict(X)
|
||||
tree_reg2 = DecisionTreeRegressor(max_depth=<span style="color: #B452CD">2</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
tree_reg2.fit(X, y2)
|
||||
|
||||
y3 = y2 - tree_reg2.predict(X)
|
||||
tree_reg3 = DecisionTreeRegressor(max_depth=<span style="color: #B452CD">2</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
tree_reg3.fit(X, y3)
|
||||
|
||||
X_new = np.array([[<span style="color: #B452CD">0.8</span>]])
|
||||
y_pred = <span style="color: #658b00">sum</span>(tree.predict(X_new) <span style="color: #8B008B; font-weight: bold">for</span> tree <span style="color: #8B008B">in</span> (tree_reg1, tree_reg2, tree_reg3))
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">def</span> <span style="color: #008b45">plot_predictions</span>(regressors, X, y, axes, label=<span style="color: #658b00">None</span>, style=<span style="color: #CD5555">"r-"</span>, data_style=<span style="color: #CD5555">"b."</span>, data_label=<span style="color: #658b00">None</span>):
|
||||
x1 = np.linspace(axes[<span style="color: #B452CD">0</span>], axes[<span style="color: #B452CD">1</span>], <span style="color: #B452CD">500</span>)
|
||||
y_pred = <span style="color: #658b00">sum</span>(regressor.predict(x1.reshape(-<span style="color: #B452CD">1</span>, <span style="color: #B452CD">1</span>)) <span style="color: #8B008B; font-weight: bold">for</span> regressor <span style="color: #8B008B">in</span> regressors)
|
||||
plt.plot(X[:, <span style="color: #B452CD">0</span>], y, data_style, label=data_label)
|
||||
plt.plot(x1, y_pred, style, linewidth=<span style="color: #B452CD">2</span>, label=label)
|
||||
<span style="color: #8B008B; font-weight: bold">if</span> label <span style="color: #8B008B">or</span> data_label:
|
||||
plt.legend(loc=<span style="color: #CD5555">"upper center"</span>, fontsize=<span style="color: #B452CD">16</span>)
|
||||
plt.axis(axes)
|
||||
|
||||
plt.figure(figsize=(<span style="color: #B452CD">11</span>,<span style="color: #B452CD">11</span>))
|
||||
|
||||
plt.subplot(<span style="color: #B452CD">321</span>)
|
||||
plot_predictions([tree_reg1], X, y, axes=[-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>, -<span style="color: #B452CD">0.1</span>, <span style="color: #B452CD">0.8</span>], label=<span style="color: #CD5555">"$h_1(x_1)$"</span>, style=<span style="color: #CD5555">"g-"</span>, data_label=<span style="color: #CD5555">"Training set"</span>)
|
||||
plt.ylabel(<span style="color: #CD5555">"$y$"</span>, fontsize=<span style="color: #B452CD">16</span>, rotation=<span style="color: #B452CD">0</span>)
|
||||
plt.title(<span style="color: #CD5555">"Residuals and tree predictions"</span>, fontsize=<span style="color: #B452CD">16</span>)
|
||||
|
||||
plt.subplot(<span style="color: #B452CD">322</span>)
|
||||
plot_predictions([tree_reg1], X, y, axes=[-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>, -<span style="color: #B452CD">0.1</span>, <span style="color: #B452CD">0.8</span>], label=<span style="color: #CD5555">"$h(x_1) = h_1(x_1)$"</span>, data_label=<span style="color: #CD5555">"Training set"</span>)
|
||||
plt.ylabel(<span style="color: #CD5555">"$y$"</span>, fontsize=<span style="color: #B452CD">16</span>, rotation=<span style="color: #B452CD">0</span>)
|
||||
plt.title(<span style="color: #CD5555">"Ensemble predictions"</span>, fontsize=<span style="color: #B452CD">16</span>)
|
||||
|
||||
plt.subplot(<span style="color: #B452CD">323</span>)
|
||||
plot_predictions([tree_reg2], X, y2, axes=[-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>, -<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>], label=<span style="color: #CD5555">"$h_2(x_1)$"</span>, style=<span style="color: #CD5555">"g-"</span>, data_style=<span style="color: #CD5555">"k+"</span>, data_label=<span style="color: #CD5555">"Residuals"</span>)
|
||||
plt.ylabel(<span style="color: #CD5555">"$y - h_1(x_1)$"</span>, fontsize=<span style="color: #B452CD">16</span>)
|
||||
|
||||
plt.subplot(<span style="color: #B452CD">324</span>)
|
||||
plot_predictions([tree_reg1, tree_reg2], X, y, axes=[-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>, -<span style="color: #B452CD">0.1</span>, <span style="color: #B452CD">0.8</span>], label=<span style="color: #CD5555">"$h(x_1) = h_1(x_1) + h_2(x_1)$"</span>)
|
||||
plt.ylabel(<span style="color: #CD5555">"$y$"</span>, fontsize=<span style="color: #B452CD">16</span>, rotation=<span style="color: #B452CD">0</span>)
|
||||
|
||||
plt.subplot(<span style="color: #B452CD">325</span>)
|
||||
plot_predictions([tree_reg3], X, y3, axes=[-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>, -<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>], label=<span style="color: #CD5555">"$h_3(x_1)$"</span>, style=<span style="color: #CD5555">"g-"</span>, data_style=<span style="color: #CD5555">"k+"</span>)
|
||||
plt.ylabel(<span style="color: #CD5555">"$y - h_1(x_1) - h_2(x_1)$"</span>, fontsize=<span style="color: #B452CD">16</span>)
|
||||
plt.xlabel(<span style="color: #CD5555">"$x_1$"</span>, fontsize=<span style="color: #B452CD">16</span>)
|
||||
|
||||
plt.subplot(<span style="color: #B452CD">326</span>)
|
||||
plot_predictions([tree_reg1, tree_reg2, tree_reg3], X, y, axes=[-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>, -<span style="color: #B452CD">0.1</span>, <span style="color: #B452CD">0.8</span>], label=<span style="color: #CD5555">"$h(x_1) = h_1(x_1) + h_2(x_1) + h_3(x_1)$"</span>)
|
||||
plt.xlabel(<span style="color: #CD5555">"$x_1$"</span>, fontsize=<span style="color: #B452CD">16</span>)
|
||||
plt.ylabel(<span style="color: #CD5555">"$y$"</span>, fontsize=<span style="color: #B452CD">16</span>, rotation=<span style="color: #B452CD">0</span>)
|
||||
|
||||
save_fig(<span style="color: #CD5555">"gradient_boosting_plot"</span>)
|
||||
plt.show()
|
||||
|
||||
<span style="color: #8B008B; font-weight: bold">from</span> <span style="color: #008b45; text-decoration: underline">sklearn.ensemble</span> <span style="color: #8B008B; font-weight: bold">import</span> GradientBoostingRegressor
|
||||
|
||||
gbrt = GradientBoostingRegressor(max_depth=<span style="color: #B452CD">2</span>, n_estimators=<span style="color: #B452CD">3</span>, learning_rate=<span style="color: #B452CD">1.0</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
gbrt.fit(X, y)
|
||||
|
||||
gbrt_slow = GradientBoostingRegressor(max_depth=<span style="color: #B452CD">2</span>, n_estimators=<span style="color: #B452CD">200</span>, learning_rate=<span style="color: #B452CD">0.1</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
gbrt_slow.fit(X, y)
|
||||
|
||||
plt.figure(figsize=(<span style="color: #B452CD">11</span>,<span style="color: #B452CD">4</span>))
|
||||
|
||||
plt.subplot(<span style="color: #B452CD">121</span>)
|
||||
plot_predictions([gbrt], X, y, axes=[-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>, -<span style="color: #B452CD">0.1</span>, <span style="color: #B452CD">0.8</span>], label=<span style="color: #CD5555">"Ensemble predictions"</span>)
|
||||
plt.title(<span style="color: #CD5555">"learning_rate={}, n_estimators={}"</span>.format(gbrt.learning_rate, gbrt.n_estimators), fontsize=<span style="color: #B452CD">14</span>)
|
||||
|
||||
plt.subplot(<span style="color: #B452CD">122</span>)
|
||||
plot_predictions([gbrt_slow], X, y, axes=[-<span style="color: #B452CD">0.5</span>, <span style="color: #B452CD">0.5</span>, -<span style="color: #B452CD">0.1</span>, <span style="color: #B452CD">0.8</span>])
|
||||
plt.title(<span style="color: #CD5555">"learning_rate={}, n_estimators={}"</span>.format(gbrt_slow.learning_rate, gbrt_slow.n_estimators), fontsize=<span style="color: #B452CD">14</span>)
|
||||
|
||||
save_fig(<span style="color: #CD5555">"gbrt_learning_rate_plot"</span>)
|
||||
plt.show()
|
||||
</pre></div>
|
||||
<p>
|
||||
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
|
||||
@@ -109,13 +109,19 @@ div { text-align: justify; text-justify: inter-word; }
|
||||
('Disadvantages', 2, None, '___sec27'),
|
||||
('Bagging', 2, None, '___sec28'),
|
||||
('More bagging', 2, None, '___sec29'),
|
||||
('Simple example, head or tail', 2, None, '___sec30'),
|
||||
('Bagging Example', 2, None, '___sec31'),
|
||||
('Random forests', 2, None, '___sec32'),
|
||||
('A simple scikit-learn example', 2, None, '___sec33'),
|
||||
('Please, not the moons again!', 2, None, '___sec34'),
|
||||
('Bagging examples', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36')]}
|
||||
('Simple Voting Example, head or tail', 2, None, '___sec30'),
|
||||
('Using the Voting Classifier', 2, None, '___sec31'),
|
||||
('Please, not the moons again! Voting and Bagging',
|
||||
2,
|
||||
None,
|
||||
'___sec32'),
|
||||
('Now Bagging', 2, None, '___sec33'),
|
||||
('Random forests', 2, None, '___sec34'),
|
||||
('A simple scikit-learn example', 2, None, '___sec35'),
|
||||
('Then random forests', 2, None, '___sec36'),
|
||||
('Feature Importance', 2, None, '___sec37'),
|
||||
('Boosting: AdaBoost', 2, None, '___sec38'),
|
||||
('Gradient Boosting', 2, None, '___sec39')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -157,7 +163,7 @@ MathJax.Hub.Config({
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Oct 31, 2019</h4></center> <!-- date -->
|
||||
<center><h4>Nov 1, 2019</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
@@ -1427,7 +1433,7 @@ predictor, averaged over all \( B \) trees.
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec30">Simple example, head or tail </h2>
|
||||
<h2 id="___sec30">Simple Voting Example, head or tail </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
@@ -1447,7 +1453,7 @@ plt<span style="color: #666666">.</span>show()
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec31">Bagging Example </h2>
|
||||
<h2 id="___sec31">Using the Voting Classifier </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
@@ -1498,69 +1504,7 @@ voting_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec32">Random forests </h2>
|
||||
|
||||
<p>
|
||||
Random forests provide an improvement over bagged trees by way of a
|
||||
small tweak that decorrelates the trees.
|
||||
|
||||
<p>
|
||||
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.
|
||||
|
||||
<p>
|
||||
A fresh sample of \( m \) predictors is
|
||||
taken at each split, and typically we choose
|
||||
|
||||
$$
|
||||
m\approx \sqrt{p}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
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.
|
||||
|
||||
<p>
|
||||
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 quanti- ties. In particular, this means that bagging will
|
||||
not lead to a substantial reduction in variance over a single tree in
|
||||
this setting.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec33">A simple scikit-learn example </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.ensemble</span> <span style="color: #008000; font-weight: bold">import</span> RandomForestClassifier
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.preprocessing</span> <span style="color: #008000; font-weight: bold">import</span> LabelEncoder
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.model_selection</span> <span style="color: #008000; font-weight: bold">import</span> cross_validate
|
||||
<span style="color: #408080; font-style: italic"># Data set not specificied</span>
|
||||
X <span style="color: #666666">=</span> dataset<span style="color: #666666">.</span>XXX
|
||||
Y <span style="color: #666666">=</span> dataset<span style="color: #666666">.</span>YYY
|
||||
<span style="color: #408080; font-style: italic">#Instantiate the model with 100 trees and entropy as splitting criteria</span>
|
||||
Random_Forest_model <span style="color: #666666">=</span> RandomForestClassifier(n_estimators<span style="color: #666666">=100</span>,criterion<span style="color: #666666">=</span><span style="color: #BA2121">"entropy"</span>)
|
||||
<span style="color: #408080; font-style: italic">#Cross validation</span>
|
||||
accuracy <span style="color: #666666">=</span> cross_validate(Random_Forest_model,X,Y,cv<span style="color: #666666">=10</span>)[<span style="color: #BA2121">'test_score'</span>]
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec34">Please, not the moons again! </h2>
|
||||
<h2 id="___sec32">Please, not the moons again! Voting and Bagging </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
@@ -1618,7 +1562,7 @@ voting_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec35">Bagging examples </h2>
|
||||
<h2 id="___sec33">Now Bagging </h2>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -1679,6 +1623,68 @@ plt<span style="color: #666666">.</span>show()
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec34">Random forests </h2>
|
||||
|
||||
<p>
|
||||
Random forests provide an improvement over bagged trees by way of a
|
||||
small tweak that decorrelates the trees.
|
||||
|
||||
<p>
|
||||
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.
|
||||
|
||||
<p>
|
||||
A fresh sample of \( m \) predictors is
|
||||
taken at each split, and typically we choose
|
||||
|
||||
$$
|
||||
m\approx \sqrt{p}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
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.
|
||||
|
||||
<p>
|
||||
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 quanti- ties. In particular, this means that bagging will
|
||||
not lead to a substantial reduction in variance over a single tree in
|
||||
this setting.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec35">A simple scikit-learn example </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.ensemble</span> <span style="color: #008000; font-weight: bold">import</span> RandomForestClassifier
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.preprocessing</span> <span style="color: #008000; font-weight: bold">import</span> LabelEncoder
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.model_selection</span> <span style="color: #008000; font-weight: bold">import</span> cross_validate
|
||||
<span style="color: #408080; font-style: italic"># Data set not specificied</span>
|
||||
X <span style="color: #666666">=</span> dataset<span style="color: #666666">.</span>XXX
|
||||
Y <span style="color: #666666">=</span> dataset<span style="color: #666666">.</span>YYY
|
||||
<span style="color: #408080; font-style: italic">#Instantiate the model with 100 trees and entropy as splitting criteria</span>
|
||||
Random_Forest_model <span style="color: #666666">=</span> RandomForestClassifier(n_estimators<span style="color: #666666">=100</span>,criterion<span style="color: #666666">=</span><span style="color: #BA2121">"entropy"</span>)
|
||||
<span style="color: #408080; font-style: italic">#Cross validation</span>
|
||||
accuracy <span style="color: #666666">=</span> cross_validate(Random_Forest_model,X,Y,cv<span style="color: #666666">=10</span>)[<span style="color: #BA2121">'test_score'</span>]
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec36">Then random forests </h2>
|
||||
<p>
|
||||
|
||||
@@ -1699,6 +1705,169 @@ y_pred_rf <span style="color: #666666">=</span> rnd_clf<span style="color: #6666
|
||||
np<span style="color: #666666">.</span>sum(y_pred <span style="color: #666666">==</span> y_pred_rf) <span style="color: #666666">/</span> <span style="color: #008000">len</span>(y_pred)
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec37">Feature Importance </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">try</span>:
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.datasets</span> <span style="color: #008000; font-weight: bold">import</span> fetch_openml
|
||||
mnist <span style="color: #666666">=</span> fetch_openml(<span style="color: #BA2121">'mnist_784'</span>, version<span style="color: #666666">=1</span>)
|
||||
mnist<span style="color: #666666">.</span>target <span style="color: #666666">=</span> mnist<span style="color: #666666">.</span>target<span style="color: #666666">.</span>astype(np<span style="color: #666666">.</span>int64)
|
||||
<span style="color: #008000; font-weight: bold">except</span> <span style="color: #D2413A; font-weight: bold">ImportError</span>:
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.datasets</span> <span style="color: #008000; font-weight: bold">import</span> fetch_mldata
|
||||
mnist <span style="color: #666666">=</span> fetch_mldata(<span style="color: #BA2121">'MNIST original'</span>)
|
||||
|
||||
rnd_clf <span style="color: #666666">=</span> RandomForestClassifier(n_estimators<span style="color: #666666">=10</span>, random_state<span style="color: #666666">=42</span>)
|
||||
rnd_clf<span style="color: #666666">.</span>fit(mnist[<span style="color: #BA2121">"data"</span>], mnist[<span style="color: #BA2121">"target"</span>])
|
||||
|
||||
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">plot_digit</span>(data):
|
||||
image <span style="color: #666666">=</span> data<span style="color: #666666">.</span>reshape(<span style="color: #666666">28</span>, <span style="color: #666666">28</span>)
|
||||
plt<span style="color: #666666">.</span>imshow(image, cmap <span style="color: #666666">=</span> mpl<span style="color: #666666">.</span>cm<span style="color: #666666">.</span>hot,
|
||||
interpolation<span style="color: #666666">=</span><span style="color: #BA2121">"nearest"</span>)
|
||||
plt<span style="color: #666666">.</span>axis(<span style="color: #BA2121">"off"</span>)
|
||||
|
||||
plot_digit(rnd_clf<span style="color: #666666">.</span>feature_importances_)
|
||||
|
||||
cbar <span style="color: #666666">=</span> plt<span style="color: #666666">.</span>colorbar(ticks<span style="color: #666666">=</span>[rnd_clf<span style="color: #666666">.</span>feature_importances_<span style="color: #666666">.</span>min(), rnd_clf<span style="color: #666666">.</span>feature_importances_<span style="color: #666666">.</span>max()])
|
||||
cbar<span style="color: #666666">.</span>ax<span style="color: #666666">.</span>set_yticklabels([<span style="color: #BA2121">'Not important'</span>, <span style="color: #BA2121">'Very important'</span>])
|
||||
|
||||
<span style="color: #408080; font-style: italic">#save_fig("mnist_feature_importance_plot")</span>
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec38">Boosting: AdaBoost </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.ensemble</span> <span style="color: #008000; font-weight: bold">import</span> AdaBoostClassifier
|
||||
|
||||
ada_clf <span style="color: #666666">=</span> AdaBoostClassifier(
|
||||
DecisionTreeClassifier(max_depth<span style="color: #666666">=1</span>), n_estimators<span style="color: #666666">=200</span>,
|
||||
algorithm<span style="color: #666666">=</span><span style="color: #BA2121">"SAMME.R"</span>, learning_rate<span style="color: #666666">=0.5</span>, random_state<span style="color: #666666">=42</span>)
|
||||
ada_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
|
||||
plot_decision_boundary(ada_clf, X, y)
|
||||
|
||||
m <span style="color: #666666">=</span> <span style="color: #008000">len</span>(X_train)
|
||||
|
||||
plt<span style="color: #666666">.</span>figure(figsize<span style="color: #666666">=</span>(<span style="color: #666666">11</span>, <span style="color: #666666">4</span>))
|
||||
<span style="color: #008000; font-weight: bold">for</span> subplot, learning_rate <span style="color: #AA22FF; font-weight: bold">in</span> ((<span style="color: #666666">121</span>, <span style="color: #666666">1</span>), (<span style="color: #666666">122</span>, <span style="color: #666666">0.5</span>)):
|
||||
sample_weights <span style="color: #666666">=</span> np<span style="color: #666666">.</span>ones(m)
|
||||
plt<span style="color: #666666">.</span>subplot(subplot)
|
||||
<span style="color: #008000; font-weight: bold">for</span> i <span style="color: #AA22FF; font-weight: bold">in</span> <span style="color: #008000">range</span>(<span style="color: #666666">5</span>):
|
||||
svm_clf <span style="color: #666666">=</span> SVC(kernel<span style="color: #666666">=</span><span style="color: #BA2121">"rbf"</span>, C<span style="color: #666666">=0.05</span>, gamma<span style="color: #666666">=</span><span style="color: #BA2121">"auto"</span>, random_state<span style="color: #666666">=42</span>)
|
||||
svm_clf<span style="color: #666666">.</span>fit(X_train, y_train, sample_weight<span style="color: #666666">=</span>sample_weights)
|
||||
y_pred <span style="color: #666666">=</span> svm_clf<span style="color: #666666">.</span>predict(X_train)
|
||||
sample_weights[y_pred <span style="color: #666666">!=</span> y_train] <span style="color: #666666">*=</span> (<span style="color: #666666">1</span> <span style="color: #666666">+</span> learning_rate)
|
||||
plot_decision_boundary(svm_clf, X, y, alpha<span style="color: #666666">=0.2</span>)
|
||||
plt<span style="color: #666666">.</span>title(<span style="color: #BA2121">"learning_rate = {}"</span><span style="color: #666666">.</span>format(learning_rate), fontsize<span style="color: #666666">=16</span>)
|
||||
<span style="color: #008000; font-weight: bold">if</span> subplot <span style="color: #666666">==</span> <span style="color: #666666">121</span>:
|
||||
plt<span style="color: #666666">.</span>text(<span style="color: #666666">-0.7</span>, <span style="color: #666666">-0.65</span>, <span style="color: #BA2121">"1"</span>, fontsize<span style="color: #666666">=14</span>)
|
||||
plt<span style="color: #666666">.</span>text(<span style="color: #666666">-0.6</span>, <span style="color: #666666">-0.10</span>, <span style="color: #BA2121">"2"</span>, fontsize<span style="color: #666666">=14</span>)
|
||||
plt<span style="color: #666666">.</span>text(<span style="color: #666666">-0.5</span>, <span style="color: #666666">0.10</span>, <span style="color: #BA2121">"3"</span>, fontsize<span style="color: #666666">=14</span>)
|
||||
plt<span style="color: #666666">.</span>text(<span style="color: #666666">-0.4</span>, <span style="color: #666666">0.55</span>, <span style="color: #BA2121">"4"</span>, fontsize<span style="color: #666666">=14</span>)
|
||||
plt<span style="color: #666666">.</span>text(<span style="color: #666666">-0.3</span>, <span style="color: #666666">0.90</span>, <span style="color: #BA2121">"5"</span>, fontsize<span style="color: #666666">=14</span>)
|
||||
|
||||
save_fig(<span style="color: #BA2121">"boosting_plot"</span>)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="___sec39">Gradient Boosting </h2>
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>seed(<span style="color: #666666">42</span>)
|
||||
X <span style="color: #666666">=</span> np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>rand(<span style="color: #666666">100</span>, <span style="color: #666666">1</span>) <span style="color: #666666">-</span> <span style="color: #666666">0.5</span>
|
||||
y <span style="color: #666666">=</span> <span style="color: #666666">3*</span>X[:, <span style="color: #666666">0</span>]<span style="color: #666666">**2</span> <span style="color: #666666">+</span> <span style="color: #666666">0.05</span> <span style="color: #666666">*</span> np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>randn(<span style="color: #666666">100</span>)
|
||||
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.tree</span> <span style="color: #008000; font-weight: bold">import</span> DecisionTreeRegressor
|
||||
|
||||
tree_reg1 <span style="color: #666666">=</span> DecisionTreeRegressor(max_depth<span style="color: #666666">=2</span>, random_state<span style="color: #666666">=42</span>)
|
||||
tree_reg1<span style="color: #666666">.</span>fit(X, y)
|
||||
|
||||
y2 <span style="color: #666666">=</span> y <span style="color: #666666">-</span> tree_reg1<span style="color: #666666">.</span>predict(X)
|
||||
tree_reg2 <span style="color: #666666">=</span> DecisionTreeRegressor(max_depth<span style="color: #666666">=2</span>, random_state<span style="color: #666666">=42</span>)
|
||||
tree_reg2<span style="color: #666666">.</span>fit(X, y2)
|
||||
|
||||
y3 <span style="color: #666666">=</span> y2 <span style="color: #666666">-</span> tree_reg2<span style="color: #666666">.</span>predict(X)
|
||||
tree_reg3 <span style="color: #666666">=</span> DecisionTreeRegressor(max_depth<span style="color: #666666">=2</span>, random_state<span style="color: #666666">=42</span>)
|
||||
tree_reg3<span style="color: #666666">.</span>fit(X, y3)
|
||||
|
||||
X_new <span style="color: #666666">=</span> np<span style="color: #666666">.</span>array([[<span style="color: #666666">0.8</span>]])
|
||||
y_pred <span style="color: #666666">=</span> <span style="color: #008000">sum</span>(tree<span style="color: #666666">.</span>predict(X_new) <span style="color: #008000; font-weight: bold">for</span> tree <span style="color: #AA22FF; font-weight: bold">in</span> (tree_reg1, tree_reg2, tree_reg3))
|
||||
|
||||
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">plot_predictions</span>(regressors, X, y, axes, label<span style="color: #666666">=</span><span style="color: #008000">None</span>, style<span style="color: #666666">=</span><span style="color: #BA2121">"r-"</span>, data_style<span style="color: #666666">=</span><span style="color: #BA2121">"b."</span>, data_label<span style="color: #666666">=</span><span style="color: #008000">None</span>):
|
||||
x1 <span style="color: #666666">=</span> np<span style="color: #666666">.</span>linspace(axes[<span style="color: #666666">0</span>], axes[<span style="color: #666666">1</span>], <span style="color: #666666">500</span>)
|
||||
y_pred <span style="color: #666666">=</span> <span style="color: #008000">sum</span>(regressor<span style="color: #666666">.</span>predict(x1<span style="color: #666666">.</span>reshape(<span style="color: #666666">-1</span>, <span style="color: #666666">1</span>)) <span style="color: #008000; font-weight: bold">for</span> regressor <span style="color: #AA22FF; font-weight: bold">in</span> regressors)
|
||||
plt<span style="color: #666666">.</span>plot(X[:, <span style="color: #666666">0</span>], y, data_style, label<span style="color: #666666">=</span>data_label)
|
||||
plt<span style="color: #666666">.</span>plot(x1, y_pred, style, linewidth<span style="color: #666666">=2</span>, label<span style="color: #666666">=</span>label)
|
||||
<span style="color: #008000; font-weight: bold">if</span> label <span style="color: #AA22FF; font-weight: bold">or</span> data_label:
|
||||
plt<span style="color: #666666">.</span>legend(loc<span style="color: #666666">=</span><span style="color: #BA2121">"upper center"</span>, fontsize<span style="color: #666666">=16</span>)
|
||||
plt<span style="color: #666666">.</span>axis(axes)
|
||||
|
||||
plt<span style="color: #666666">.</span>figure(figsize<span style="color: #666666">=</span>(<span style="color: #666666">11</span>,<span style="color: #666666">11</span>))
|
||||
|
||||
plt<span style="color: #666666">.</span>subplot(<span style="color: #666666">321</span>)
|
||||
plot_predictions([tree_reg1], X, y, axes<span style="color: #666666">=</span>[<span style="color: #666666">-0.5</span>, <span style="color: #666666">0.5</span>, <span style="color: #666666">-0.1</span>, <span style="color: #666666">0.8</span>], label<span style="color: #666666">=</span><span style="color: #BA2121">"$h_1(x_1)$"</span>, style<span style="color: #666666">=</span><span style="color: #BA2121">"g-"</span>, data_label<span style="color: #666666">=</span><span style="color: #BA2121">"Training set"</span>)
|
||||
plt<span style="color: #666666">.</span>ylabel(<span style="color: #BA2121">"$y$"</span>, fontsize<span style="color: #666666">=16</span>, rotation<span style="color: #666666">=0</span>)
|
||||
plt<span style="color: #666666">.</span>title(<span style="color: #BA2121">"Residuals and tree predictions"</span>, fontsize<span style="color: #666666">=16</span>)
|
||||
|
||||
plt<span style="color: #666666">.</span>subplot(<span style="color: #666666">322</span>)
|
||||
plot_predictions([tree_reg1], X, y, axes<span style="color: #666666">=</span>[<span style="color: #666666">-0.5</span>, <span style="color: #666666">0.5</span>, <span style="color: #666666">-0.1</span>, <span style="color: #666666">0.8</span>], label<span style="color: #666666">=</span><span style="color: #BA2121">"$h(x_1) = h_1(x_1)$"</span>, data_label<span style="color: #666666">=</span><span style="color: #BA2121">"Training set"</span>)
|
||||
plt<span style="color: #666666">.</span>ylabel(<span style="color: #BA2121">"$y$"</span>, fontsize<span style="color: #666666">=16</span>, rotation<span style="color: #666666">=0</span>)
|
||||
plt<span style="color: #666666">.</span>title(<span style="color: #BA2121">"Ensemble predictions"</span>, fontsize<span style="color: #666666">=16</span>)
|
||||
|
||||
plt<span style="color: #666666">.</span>subplot(<span style="color: #666666">323</span>)
|
||||
plot_predictions([tree_reg2], X, y2, axes<span style="color: #666666">=</span>[<span style="color: #666666">-0.5</span>, <span style="color: #666666">0.5</span>, <span style="color: #666666">-0.5</span>, <span style="color: #666666">0.5</span>], label<span style="color: #666666">=</span><span style="color: #BA2121">"$h_2(x_1)$"</span>, style<span style="color: #666666">=</span><span style="color: #BA2121">"g-"</span>, data_style<span style="color: #666666">=</span><span style="color: #BA2121">"k+"</span>, data_label<span style="color: #666666">=</span><span style="color: #BA2121">"Residuals"</span>)
|
||||
plt<span style="color: #666666">.</span>ylabel(<span style="color: #BA2121">"$y - h_1(x_1)$"</span>, fontsize<span style="color: #666666">=16</span>)
|
||||
|
||||
plt<span style="color: #666666">.</span>subplot(<span style="color: #666666">324</span>)
|
||||
plot_predictions([tree_reg1, tree_reg2], X, y, axes<span style="color: #666666">=</span>[<span style="color: #666666">-0.5</span>, <span style="color: #666666">0.5</span>, <span style="color: #666666">-0.1</span>, <span style="color: #666666">0.8</span>], label<span style="color: #666666">=</span><span style="color: #BA2121">"$h(x_1) = h_1(x_1) + h_2(x_1)$"</span>)
|
||||
plt<span style="color: #666666">.</span>ylabel(<span style="color: #BA2121">"$y$"</span>, fontsize<span style="color: #666666">=16</span>, rotation<span style="color: #666666">=0</span>)
|
||||
|
||||
plt<span style="color: #666666">.</span>subplot(<span style="color: #666666">325</span>)
|
||||
plot_predictions([tree_reg3], X, y3, axes<span style="color: #666666">=</span>[<span style="color: #666666">-0.5</span>, <span style="color: #666666">0.5</span>, <span style="color: #666666">-0.5</span>, <span style="color: #666666">0.5</span>], label<span style="color: #666666">=</span><span style="color: #BA2121">"$h_3(x_1)$"</span>, style<span style="color: #666666">=</span><span style="color: #BA2121">"g-"</span>, data_style<span style="color: #666666">=</span><span style="color: #BA2121">"k+"</span>)
|
||||
plt<span style="color: #666666">.</span>ylabel(<span style="color: #BA2121">"$y - h_1(x_1) - h_2(x_1)$"</span>, fontsize<span style="color: #666666">=16</span>)
|
||||
plt<span style="color: #666666">.</span>xlabel(<span style="color: #BA2121">"$x_1$"</span>, fontsize<span style="color: #666666">=16</span>)
|
||||
|
||||
plt<span style="color: #666666">.</span>subplot(<span style="color: #666666">326</span>)
|
||||
plot_predictions([tree_reg1, tree_reg2, tree_reg3], X, y, axes<span style="color: #666666">=</span>[<span style="color: #666666">-0.5</span>, <span style="color: #666666">0.5</span>, <span style="color: #666666">-0.1</span>, <span style="color: #666666">0.8</span>], label<span style="color: #666666">=</span><span style="color: #BA2121">"$h(x_1) = h_1(x_1) + h_2(x_1) + h_3(x_1)$"</span>)
|
||||
plt<span style="color: #666666">.</span>xlabel(<span style="color: #BA2121">"$x_1$"</span>, fontsize<span style="color: #666666">=16</span>)
|
||||
plt<span style="color: #666666">.</span>ylabel(<span style="color: #BA2121">"$y$"</span>, fontsize<span style="color: #666666">=16</span>, rotation<span style="color: #666666">=0</span>)
|
||||
|
||||
save_fig(<span style="color: #BA2121">"gradient_boosting_plot"</span>)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.ensemble</span> <span style="color: #008000; font-weight: bold">import</span> GradientBoostingRegressor
|
||||
|
||||
gbrt <span style="color: #666666">=</span> GradientBoostingRegressor(max_depth<span style="color: #666666">=2</span>, n_estimators<span style="color: #666666">=3</span>, learning_rate<span style="color: #666666">=1.0</span>, random_state<span style="color: #666666">=42</span>)
|
||||
gbrt<span style="color: #666666">.</span>fit(X, y)
|
||||
|
||||
gbrt_slow <span style="color: #666666">=</span> GradientBoostingRegressor(max_depth<span style="color: #666666">=2</span>, n_estimators<span style="color: #666666">=200</span>, learning_rate<span style="color: #666666">=0.1</span>, random_state<span style="color: #666666">=42</span>)
|
||||
gbrt_slow<span style="color: #666666">.</span>fit(X, y)
|
||||
|
||||
plt<span style="color: #666666">.</span>figure(figsize<span style="color: #666666">=</span>(<span style="color: #666666">11</span>,<span style="color: #666666">4</span>))
|
||||
|
||||
plt<span style="color: #666666">.</span>subplot(<span style="color: #666666">121</span>)
|
||||
plot_predictions([gbrt], X, y, axes<span style="color: #666666">=</span>[<span style="color: #666666">-0.5</span>, <span style="color: #666666">0.5</span>, <span style="color: #666666">-0.1</span>, <span style="color: #666666">0.8</span>], label<span style="color: #666666">=</span><span style="color: #BA2121">"Ensemble predictions"</span>)
|
||||
plt<span style="color: #666666">.</span>title(<span style="color: #BA2121">"learning_rate={}, n_estimators={}"</span><span style="color: #666666">.</span>format(gbrt<span style="color: #666666">.</span>learning_rate, gbrt<span style="color: #666666">.</span>n_estimators), fontsize<span style="color: #666666">=14</span>)
|
||||
|
||||
plt<span style="color: #666666">.</span>subplot(<span style="color: #666666">122</span>)
|
||||
plot_predictions([gbrt_slow], X, y, axes<span style="color: #666666">=</span>[<span style="color: #666666">-0.5</span>, <span style="color: #666666">0.5</span>, <span style="color: #666666">-0.1</span>, <span style="color: #666666">0.8</span>])
|
||||
plt<span style="color: #666666">.</span>title(<span style="color: #BA2121">"learning_rate={}, n_estimators={}"</span><span style="color: #666666">.</span>format(gbrt_slow<span style="color: #666666">.</span>learning_rate, gbrt_slow<span style="color: #666666">.</span>n_estimators), fontsize<span style="color: #666666">=14</span>)
|
||||
|
||||
save_fig(<span style="color: #BA2121">"gbrt_learning_rate_plot"</span>)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
<p>
|
||||
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ edge [fontname=helvetica] ;
|
||||
2 -> 3 ;
|
||||
4 [label="gini = 0.0\nsamples = 239\nvalue = [[239, 0]\n[0, 239]]", fillcolor="#e58139ff"] ;
|
||||
3 -> 4 ;
|
||||
5 [label="mean area <= 469.25\ngini = 0.444\nsamples = 3\nvalue = [[2, 1]\n[1, 2]]", fillcolor="#e5813913"] ;
|
||||
5 [label="worst area <= 566.55\ngini = 0.444\nsamples = 3\nvalue = [[2, 1]\n[1, 2]]", fillcolor="#e5813913"] ;
|
||||
3 -> 5 ;
|
||||
6 [label="gini = 0.0\nsamples = 1\nvalue = [[0, 1]\n[1, 0]]", fillcolor="#e58139ff"] ;
|
||||
5 -> 6 ;
|
||||
@@ -30,7 +30,7 @@ edge [fontname=helvetica] ;
|
||||
11 -> 13 ;
|
||||
14 [label="worst texture <= 20.645\ngini = 0.202\nsamples = 167\nvalue = [[19, 148]\n[148, 19]]", fillcolor="#e5813994"] ;
|
||||
0 -> 14 [labeldistance=2.5, labelangle=-45, headlabel="False"] ;
|
||||
15 [label="worst perimeter <= 116.8\ngini = 0.375\nsamples = 16\nvalue = [[12, 4]\n[4, 12]]", fillcolor="#e5813938"] ;
|
||||
15 [label="worst radius <= 17.74\ngini = 0.375\nsamples = 16\nvalue = [[12, 4]\n[4, 12]]", fillcolor="#e5813938"] ;
|
||||
14 -> 15 ;
|
||||
16 [label="gini = 0.0\nsamples = 11\nvalue = [[11, 0]\n[0, 11]]", fillcolor="#e58139ff"] ;
|
||||
15 -> 16 ;
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 217 KiB After Width: | Height: | Size: 217 KiB |
@@ -10,7 +10,7 @@
|
||||
"<!-- Author: --> \n",
|
||||
"**Morten Hjorth-Jensen**, Department of Physics, University of Oslo and Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University\n",
|
||||
"\n",
|
||||
"Date: **Oct 31, 2019**\n",
|
||||
"Date: **Nov 1, 2019**\n",
|
||||
"\n",
|
||||
"Copyright 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license\n",
|
||||
"\n",
|
||||
@@ -1411,7 +1411,7 @@
|
||||
"amount that the Gini index is decreased by splits over a given\n",
|
||||
"predictor, averaged over all $B$ trees.\n",
|
||||
"\n",
|
||||
"## Simple example, head or tail"
|
||||
"## Simple Voting Example, head or tail"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1440,7 +1440,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Bagging Example"
|
||||
"## Using the Voting Classifier"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1496,6 +1496,178 @@
|
||||
" print(clf.__class__.__name__, accuracy_score(y_test, y_pred))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Please, not the moons again! Voting and Bagging"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"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": 17,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"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": 18,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"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": 19,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"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",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Now Bagging"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from sklearn.ensemble import BaggingClassifier\n",
|
||||
"from sklearn.tree import DecisionTreeClassifier\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": 21,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from sklearn.metrics import accuracy_score\n",
|
||||
"print(accuracy_score(y_test, y_pred))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"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": 23,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from matplotlib.colors import ListedColormap\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",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -1551,7 +1723,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"execution_count": 24,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@@ -1569,178 +1741,6 @@
|
||||
"accuracy = cross_validate(Random_Forest_model,X,Y,cv=10)['test_score']"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Please, not the moons again!"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"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": 18,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"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": 19,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"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": 20,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"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",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Bagging examples"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from sklearn.ensemble import BaggingClassifier\n",
|
||||
"from sklearn.tree import DecisionTreeClassifier\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": 22,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from sklearn.metrics import accuracy_score\n",
|
||||
"print(accuracy_score(y_test, y_pred))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"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": 24,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from matplotlib.colors import ListedColormap\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",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -1777,6 +1777,194 @@
|
||||
"y_pred_rf = rnd_clf.predict(X_test)\n",
|
||||
"np.sum(y_pred == y_pred_rf) / len(y_pred)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Feature Importance"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"try:\n",
|
||||
" from sklearn.datasets import fetch_openml\n",
|
||||
" mnist = fetch_openml('mnist_784', version=1)\n",
|
||||
" mnist.target = mnist.target.astype(np.int64)\n",
|
||||
"except ImportError:\n",
|
||||
" from sklearn.datasets import fetch_mldata\n",
|
||||
" mnist = fetch_mldata('MNIST original')\n",
|
||||
"\n",
|
||||
"rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)\n",
|
||||
"rnd_clf.fit(mnist[\"data\"], mnist[\"target\"])\n",
|
||||
"\n",
|
||||
"def plot_digit(data):\n",
|
||||
" image = data.reshape(28, 28)\n",
|
||||
" plt.imshow(image, cmap = mpl.cm.hot,\n",
|
||||
" interpolation=\"nearest\")\n",
|
||||
" plt.axis(\"off\")\n",
|
||||
"\n",
|
||||
"plot_digit(rnd_clf.feature_importances_)\n",
|
||||
"\n",
|
||||
"cbar = plt.colorbar(ticks=[rnd_clf.feature_importances_.min(), rnd_clf.feature_importances_.max()])\n",
|
||||
"cbar.ax.set_yticklabels(['Not important', 'Very important'])\n",
|
||||
"\n",
|
||||
"#save_fig(\"mnist_feature_importance_plot\")\n",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Boosting: AdaBoost"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from sklearn.ensemble import AdaBoostClassifier\n",
|
||||
"\n",
|
||||
"ada_clf = AdaBoostClassifier(\n",
|
||||
" DecisionTreeClassifier(max_depth=1), n_estimators=200,\n",
|
||||
" algorithm=\"SAMME.R\", learning_rate=0.5, random_state=42)\n",
|
||||
"ada_clf.fit(X_train, y_train)\n",
|
||||
"\n",
|
||||
"plot_decision_boundary(ada_clf, X, y)\n",
|
||||
"\n",
|
||||
"m = len(X_train)\n",
|
||||
"\n",
|
||||
"plt.figure(figsize=(11, 4))\n",
|
||||
"for subplot, learning_rate in ((121, 1), (122, 0.5)):\n",
|
||||
" sample_weights = np.ones(m)\n",
|
||||
" plt.subplot(subplot)\n",
|
||||
" for i in range(5):\n",
|
||||
" svm_clf = SVC(kernel=\"rbf\", C=0.05, gamma=\"auto\", random_state=42)\n",
|
||||
" svm_clf.fit(X_train, y_train, sample_weight=sample_weights)\n",
|
||||
" y_pred = svm_clf.predict(X_train)\n",
|
||||
" sample_weights[y_pred != y_train] *= (1 + learning_rate)\n",
|
||||
" plot_decision_boundary(svm_clf, X, y, alpha=0.2)\n",
|
||||
" plt.title(\"learning_rate = {}\".format(learning_rate), fontsize=16)\n",
|
||||
" if subplot == 121:\n",
|
||||
" plt.text(-0.7, -0.65, \"1\", fontsize=14)\n",
|
||||
" plt.text(-0.6, -0.10, \"2\", fontsize=14)\n",
|
||||
" plt.text(-0.5, 0.10, \"3\", fontsize=14)\n",
|
||||
" plt.text(-0.4, 0.55, \"4\", fontsize=14)\n",
|
||||
" plt.text(-0.3, 0.90, \"5\", fontsize=14)\n",
|
||||
"\n",
|
||||
"save_fig(\"boosting_plot\")\n",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Gradient Boosting"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"np.random.seed(42)\n",
|
||||
"X = np.random.rand(100, 1) - 0.5\n",
|
||||
"y = 3*X[:, 0]**2 + 0.05 * np.random.randn(100)\n",
|
||||
"\n",
|
||||
"from sklearn.tree import DecisionTreeRegressor\n",
|
||||
"\n",
|
||||
"tree_reg1 = DecisionTreeRegressor(max_depth=2, random_state=42)\n",
|
||||
"tree_reg1.fit(X, y)\n",
|
||||
"\n",
|
||||
"y2 = y - tree_reg1.predict(X)\n",
|
||||
"tree_reg2 = DecisionTreeRegressor(max_depth=2, random_state=42)\n",
|
||||
"tree_reg2.fit(X, y2)\n",
|
||||
"\n",
|
||||
"y3 = y2 - tree_reg2.predict(X)\n",
|
||||
"tree_reg3 = DecisionTreeRegressor(max_depth=2, random_state=42)\n",
|
||||
"tree_reg3.fit(X, y3)\n",
|
||||
"\n",
|
||||
"X_new = np.array([[0.8]])\n",
|
||||
"y_pred = sum(tree.predict(X_new) for tree in (tree_reg1, tree_reg2, tree_reg3))\n",
|
||||
"\n",
|
||||
"def plot_predictions(regressors, X, y, axes, label=None, style=\"r-\", data_style=\"b.\", data_label=None):\n",
|
||||
" x1 = np.linspace(axes[0], axes[1], 500)\n",
|
||||
" y_pred = sum(regressor.predict(x1.reshape(-1, 1)) for regressor in regressors)\n",
|
||||
" plt.plot(X[:, 0], y, data_style, label=data_label)\n",
|
||||
" plt.plot(x1, y_pred, style, linewidth=2, label=label)\n",
|
||||
" if label or data_label:\n",
|
||||
" plt.legend(loc=\"upper center\", fontsize=16)\n",
|
||||
" plt.axis(axes)\n",
|
||||
"\n",
|
||||
"plt.figure(figsize=(11,11))\n",
|
||||
"\n",
|
||||
"plt.subplot(321)\n",
|
||||
"plot_predictions([tree_reg1], X, y, axes=[-0.5, 0.5, -0.1, 0.8], label=\"$h_1(x_1)$\", style=\"g-\", data_label=\"Training set\")\n",
|
||||
"plt.ylabel(\"$y$\", fontsize=16, rotation=0)\n",
|
||||
"plt.title(\"Residuals and tree predictions\", fontsize=16)\n",
|
||||
"\n",
|
||||
"plt.subplot(322)\n",
|
||||
"plot_predictions([tree_reg1], X, y, axes=[-0.5, 0.5, -0.1, 0.8], label=\"$h(x_1) = h_1(x_1)$\", data_label=\"Training set\")\n",
|
||||
"plt.ylabel(\"$y$\", fontsize=16, rotation=0)\n",
|
||||
"plt.title(\"Ensemble predictions\", fontsize=16)\n",
|
||||
"\n",
|
||||
"plt.subplot(323)\n",
|
||||
"plot_predictions([tree_reg2], X, y2, axes=[-0.5, 0.5, -0.5, 0.5], label=\"$h_2(x_1)$\", style=\"g-\", data_style=\"k+\", data_label=\"Residuals\")\n",
|
||||
"plt.ylabel(\"$y - h_1(x_1)$\", fontsize=16)\n",
|
||||
"\n",
|
||||
"plt.subplot(324)\n",
|
||||
"plot_predictions([tree_reg1, tree_reg2], X, y, axes=[-0.5, 0.5, -0.1, 0.8], label=\"$h(x_1) = h_1(x_1) + h_2(x_1)$\")\n",
|
||||
"plt.ylabel(\"$y$\", fontsize=16, rotation=0)\n",
|
||||
"\n",
|
||||
"plt.subplot(325)\n",
|
||||
"plot_predictions([tree_reg3], X, y3, axes=[-0.5, 0.5, -0.5, 0.5], label=\"$h_3(x_1)$\", style=\"g-\", data_style=\"k+\")\n",
|
||||
"plt.ylabel(\"$y - h_1(x_1) - h_2(x_1)$\", fontsize=16)\n",
|
||||
"plt.xlabel(\"$x_1$\", fontsize=16)\n",
|
||||
"\n",
|
||||
"plt.subplot(326)\n",
|
||||
"plot_predictions([tree_reg1, tree_reg2, tree_reg3], X, y, axes=[-0.5, 0.5, -0.1, 0.8], label=\"$h(x_1) = h_1(x_1) + h_2(x_1) + h_3(x_1)$\")\n",
|
||||
"plt.xlabel(\"$x_1$\", fontsize=16)\n",
|
||||
"plt.ylabel(\"$y$\", fontsize=16, rotation=0)\n",
|
||||
"\n",
|
||||
"save_fig(\"gradient_boosting_plot\")\n",
|
||||
"plt.show()\n",
|
||||
"\n",
|
||||
"from sklearn.ensemble import GradientBoostingRegressor\n",
|
||||
"\n",
|
||||
"gbrt = GradientBoostingRegressor(max_depth=2, n_estimators=3, learning_rate=1.0, random_state=42)\n",
|
||||
"gbrt.fit(X, y)\n",
|
||||
"\n",
|
||||
"gbrt_slow = GradientBoostingRegressor(max_depth=2, n_estimators=200, learning_rate=0.1, random_state=42)\n",
|
||||
"gbrt_slow.fit(X, y)\n",
|
||||
"\n",
|
||||
"plt.figure(figsize=(11,4))\n",
|
||||
"\n",
|
||||
"plt.subplot(121)\n",
|
||||
"plot_predictions([gbrt], X, y, axes=[-0.5, 0.5, -0.1, 0.8], label=\"Ensemble predictions\")\n",
|
||||
"plt.title(\"learning_rate={}, n_estimators={}\".format(gbrt.learning_rate, gbrt.n_estimators), fontsize=14)\n",
|
||||
"\n",
|
||||
"plt.subplot(122)\n",
|
||||
"plot_predictions([gbrt_slow], X, y, axes=[-0.5, 0.5, -0.1, 0.8])\n",
|
||||
"plt.title(\"learning_rate={}, n_estimators={}\".format(gbrt_slow.learning_rate, gbrt_slow.n_estimators), fontsize=14)\n",
|
||||
"\n",
|
||||
"save_fig(\"gbrt_learning_rate_plot\")\n",
|
||||
"plt.show()"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {},
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1169,7 +1169,7 @@ amount that the Gini index is decreased by splits over a given
|
||||
predictor, averaged over all $B$ trees.
|
||||
|
||||
!split
|
||||
===== Simple example, head or tail =====
|
||||
===== Simple Voting Example, head or tail =====
|
||||
!bc pycod
|
||||
heads_proba = 0.51
|
||||
coin_tosses = (np.random.rand(10000, 10) < heads_proba).astype(np.int32)
|
||||
@@ -1187,7 +1187,7 @@ plt.show()
|
||||
!ec
|
||||
|
||||
!split
|
||||
===== Bagging Example =====
|
||||
===== Using the Voting Classifier =====
|
||||
!bc pycod
|
||||
from sklearn.model_selection import train_test_split
|
||||
from sklearn.datasets import make_moons
|
||||
@@ -1235,6 +1235,113 @@ for clf in (log_clf, rnd_clf, svm_clf, voting_clf):
|
||||
|
||||
!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
|
||||
===== Now Bagging =====
|
||||
|
||||
!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)
|
||||
plt.show()
|
||||
!ec
|
||||
|
||||
|
||||
!split
|
||||
@@ -1291,113 +1398,6 @@ Random_Forest_model = RandomForestClassifier(n_estimators=100,criterion="entropy
|
||||
accuracy = cross_validate(Random_Forest_model,X,Y,cv=10)['test_score']
|
||||
!ec
|
||||
|
||||
!split
|
||||
===== Please, not the moons again! =====
|
||||
!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)
|
||||
plt.show()
|
||||
!ec
|
||||
|
||||
!split
|
||||
===== Then random forests =====
|
||||
@@ -1421,3 +1421,161 @@ np.sum(y_pred == y_pred_rf) / len(y_pred)
|
||||
|
||||
|
||||
|
||||
!split
|
||||
===== Feature Importance =====
|
||||
|
||||
!bc pycod
|
||||
try:
|
||||
from sklearn.datasets import fetch_openml
|
||||
mnist = fetch_openml('mnist_784', version=1)
|
||||
mnist.target = mnist.target.astype(np.int64)
|
||||
except ImportError:
|
||||
from sklearn.datasets import fetch_mldata
|
||||
mnist = fetch_mldata('MNIST original')
|
||||
|
||||
rnd_clf = RandomForestClassifier(n_estimators=10, random_state=42)
|
||||
rnd_clf.fit(mnist["data"], mnist["target"])
|
||||
|
||||
def plot_digit(data):
|
||||
image = data.reshape(28, 28)
|
||||
plt.imshow(image, cmap = mpl.cm.hot,
|
||||
interpolation="nearest")
|
||||
plt.axis("off")
|
||||
|
||||
plot_digit(rnd_clf.feature_importances_)
|
||||
|
||||
cbar = plt.colorbar(ticks=[rnd_clf.feature_importances_.min(), rnd_clf.feature_importances_.max()])
|
||||
cbar.ax.set_yticklabels(['Not important', 'Very important'])
|
||||
|
||||
#save_fig("mnist_feature_importance_plot")
|
||||
plt.show()
|
||||
!ec
|
||||
|
||||
!split
|
||||
===== Boosting: AdaBoost =====
|
||||
|
||||
!bc pycod
|
||||
from sklearn.ensemble import AdaBoostClassifier
|
||||
|
||||
ada_clf = AdaBoostClassifier(
|
||||
DecisionTreeClassifier(max_depth=1), n_estimators=200,
|
||||
algorithm="SAMME.R", learning_rate=0.5, random_state=42)
|
||||
ada_clf.fit(X_train, y_train)
|
||||
|
||||
plot_decision_boundary(ada_clf, X, y)
|
||||
|
||||
m = len(X_train)
|
||||
|
||||
plt.figure(figsize=(11, 4))
|
||||
for subplot, learning_rate in ((121, 1), (122, 0.5)):
|
||||
sample_weights = np.ones(m)
|
||||
plt.subplot(subplot)
|
||||
for i in range(5):
|
||||
svm_clf = SVC(kernel="rbf", C=0.05, gamma="auto", random_state=42)
|
||||
svm_clf.fit(X_train, y_train, sample_weight=sample_weights)
|
||||
y_pred = svm_clf.predict(X_train)
|
||||
sample_weights[y_pred != y_train] *= (1 + learning_rate)
|
||||
plot_decision_boundary(svm_clf, X, y, alpha=0.2)
|
||||
plt.title("learning_rate = {}".format(learning_rate), fontsize=16)
|
||||
if subplot == 121:
|
||||
plt.text(-0.7, -0.65, "1", fontsize=14)
|
||||
plt.text(-0.6, -0.10, "2", fontsize=14)
|
||||
plt.text(-0.5, 0.10, "3", fontsize=14)
|
||||
plt.text(-0.4, 0.55, "4", fontsize=14)
|
||||
plt.text(-0.3, 0.90, "5", fontsize=14)
|
||||
|
||||
save_fig("boosting_plot")
|
||||
plt.show()
|
||||
|
||||
|
||||
|
||||
!ec
|
||||
|
||||
|
||||
!split
|
||||
===== Gradient Boosting =====
|
||||
!bc pycod
|
||||
np.random.seed(42)
|
||||
X = np.random.rand(100, 1) - 0.5
|
||||
y = 3*X[:, 0]**2 + 0.05 * np.random.randn(100)
|
||||
|
||||
from sklearn.tree import DecisionTreeRegressor
|
||||
|
||||
tree_reg1 = DecisionTreeRegressor(max_depth=2, random_state=42)
|
||||
tree_reg1.fit(X, y)
|
||||
|
||||
y2 = y - tree_reg1.predict(X)
|
||||
tree_reg2 = DecisionTreeRegressor(max_depth=2, random_state=42)
|
||||
tree_reg2.fit(X, y2)
|
||||
|
||||
y3 = y2 - tree_reg2.predict(X)
|
||||
tree_reg3 = DecisionTreeRegressor(max_depth=2, random_state=42)
|
||||
tree_reg3.fit(X, y3)
|
||||
|
||||
X_new = np.array([[0.8]])
|
||||
y_pred = sum(tree.predict(X_new) for tree in (tree_reg1, tree_reg2, tree_reg3))
|
||||
|
||||
def plot_predictions(regressors, X, y, axes, label=None, style="r-", data_style="b.", data_label=None):
|
||||
x1 = np.linspace(axes[0], axes[1], 500)
|
||||
y_pred = sum(regressor.predict(x1.reshape(-1, 1)) for regressor in regressors)
|
||||
plt.plot(X[:, 0], y, data_style, label=data_label)
|
||||
plt.plot(x1, y_pred, style, linewidth=2, label=label)
|
||||
if label or data_label:
|
||||
plt.legend(loc="upper center", fontsize=16)
|
||||
plt.axis(axes)
|
||||
|
||||
plt.figure(figsize=(11,11))
|
||||
|
||||
plt.subplot(321)
|
||||
plot_predictions([tree_reg1], X, y, axes=[-0.5, 0.5, -0.1, 0.8], label="$h_1(x_1)$", style="g-", data_label="Training set")
|
||||
plt.ylabel("$y$", fontsize=16, rotation=0)
|
||||
plt.title("Residuals and tree predictions", fontsize=16)
|
||||
|
||||
plt.subplot(322)
|
||||
plot_predictions([tree_reg1], X, y, axes=[-0.5, 0.5, -0.1, 0.8], label="$h(x_1) = h_1(x_1)$", data_label="Training set")
|
||||
plt.ylabel("$y$", fontsize=16, rotation=0)
|
||||
plt.title("Ensemble predictions", fontsize=16)
|
||||
|
||||
plt.subplot(323)
|
||||
plot_predictions([tree_reg2], X, y2, axes=[-0.5, 0.5, -0.5, 0.5], label="$h_2(x_1)$", style="g-", data_style="k+", data_label="Residuals")
|
||||
plt.ylabel("$y - h_1(x_1)$", fontsize=16)
|
||||
|
||||
plt.subplot(324)
|
||||
plot_predictions([tree_reg1, tree_reg2], X, y, axes=[-0.5, 0.5, -0.1, 0.8], label="$h(x_1) = h_1(x_1) + h_2(x_1)$")
|
||||
plt.ylabel("$y$", fontsize=16, rotation=0)
|
||||
|
||||
plt.subplot(325)
|
||||
plot_predictions([tree_reg3], X, y3, axes=[-0.5, 0.5, -0.5, 0.5], label="$h_3(x_1)$", style="g-", data_style="k+")
|
||||
plt.ylabel("$y - h_1(x_1) - h_2(x_1)$", fontsize=16)
|
||||
plt.xlabel("$x_1$", fontsize=16)
|
||||
|
||||
plt.subplot(326)
|
||||
plot_predictions([tree_reg1, tree_reg2, tree_reg3], X, y, axes=[-0.5, 0.5, -0.1, 0.8], label="$h(x_1) = h_1(x_1) + h_2(x_1) + h_3(x_1)$")
|
||||
plt.xlabel("$x_1$", fontsize=16)
|
||||
plt.ylabel("$y$", fontsize=16, rotation=0)
|
||||
|
||||
save_fig("gradient_boosting_plot")
|
||||
plt.show()
|
||||
|
||||
from sklearn.ensemble import GradientBoostingRegressor
|
||||
|
||||
gbrt = GradientBoostingRegressor(max_depth=2, n_estimators=3, learning_rate=1.0, random_state=42)
|
||||
gbrt.fit(X, y)
|
||||
|
||||
gbrt_slow = GradientBoostingRegressor(max_depth=2, n_estimators=200, learning_rate=0.1, random_state=42)
|
||||
gbrt_slow.fit(X, y)
|
||||
|
||||
plt.figure(figsize=(11,4))
|
||||
|
||||
plt.subplot(121)
|
||||
plot_predictions([gbrt], X, y, axes=[-0.5, 0.5, -0.1, 0.8], label="Ensemble predictions")
|
||||
plt.title("learning_rate={}, n_estimators={}".format(gbrt.learning_rate, gbrt.n_estimators), fontsize=14)
|
||||
|
||||
plt.subplot(122)
|
||||
plot_predictions([gbrt_slow], X, y, axes=[-0.5, 0.5, -0.1, 0.8])
|
||||
plt.title("learning_rate={}, n_estimators={}".format(gbrt_slow.learning_rate, gbrt_slow.n_estimators), fontsize=14)
|
||||
|
||||
save_fig("gbrt_learning_rate_plot")
|
||||
plt.show()
|
||||
|
||||
!ec
|
||||
|
||||
Reference in New Issue
Block a user