updating decision tree

This commit is contained in:
mhjensen
2019-11-08 10:53:26 +01:00
parent b87fd2d131
commit 7354ba60ec
15 changed files with 79 additions and 7 deletions
@@ -276,6 +276,7 @@ plt<span style="color: #666666">.</span>xlabel(<span style="color: #BA2121">&quo
plt<span style="color: #666666">.</span>ylabel(<span style="color: #BA2121">&quot;Heads ratio&quot;</span>)
plt<span style="color: #666666">.</span>legend(loc<span style="color: #666666">=</span><span style="color: #BA2121">&quot;lower right&quot;</span>)
plt<span style="color: #666666">.</span>axis([<span style="color: #666666">0</span>, <span style="color: #666666">10000</span>, <span style="color: #666666">0.42</span>, <span style="color: #666666">0.58</span>])
save_fig(<span style="color: #BA2121">&quot;votingsimple&quot;</span>)
plt<span style="color: #666666">.</span>show()
</pre></div>
<p>
@@ -317,6 +317,7 @@ plt<span style="color: #666666">.</span>title(<span style="color: #BA2121">&quot
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">&quot;Decision Trees with Bagging&quot;</span>, fontsize<span style="color: #666666">=14</span>)
save_fig(<span style="color: #BA2121">&quot;baggingtree&quot;</span>)
plt<span style="color: #666666">.</span>show()
</pre></div>
<p>
@@ -315,6 +315,7 @@ plt<span style="color: #666666">.</span>plot(polydegree, error, label<span style
plt<span style="color: #666666">.</span>plot(polydegree, bias, label<span style="color: #666666">=</span><span style="color: #BA2121">&#39;bias&#39;</span>)
plt<span style="color: #666666">.</span>plot(polydegree, variance, label<span style="color: #666666">=</span><span style="color: #BA2121">&#39;Variance&#39;</span>)
plt<span style="color: #666666">.</span>legend()
save_fig(<span style="color: #BA2121">&quot;baggingboot&quot;</span>)
plt<span style="color: #666666">.</span>show()
</pre></div>
<p>
@@ -309,6 +309,7 @@ plt<span style="color: #666666">.</span>plot(polydegree, error, label<span style
plt<span style="color: #666666">.</span>plot(polydegree, bias, label<span style="color: #666666">=</span><span style="color: #BA2121">&#39;bias&#39;</span>)
plt<span style="color: #666666">.</span>plot(polydegree, variance, label<span style="color: #666666">=</span><span style="color: #BA2121">&#39;Variance&#39;</span>)
plt<span style="color: #666666">.</span>legend()
save_fig(<span style="color: #BA2121">&quot;gdregression&quot;</span>)
plt<span style="color: #666666">.</span>show()
</pre></div>
<p>
@@ -296,11 +296,14 @@ accuracy <span style="color: #666666">=</span> cross_validate(gd_clf,X_test_scal
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">scikitplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">skplt</span>
y_pred <span style="color: #666666">=</span> gd_clf<span style="color: #666666">.</span>predict(X_test_scaled)
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_confusion_matrix(y_test, y_pred, normalize<span style="color: #666666">=</span><span style="color: #008000">True</span>)
save_fig(<span style="color: #BA2121">&quot;gdclassiffierconfusion&quot;</span>)
plt<span style="color: #666666">.</span>show()
y_probas <span style="color: #666666">=</span> gd_clf<span style="color: #666666">.</span>predict_proba(X_test_scaled)
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_roc(y_test, y_probas)
save_fig(<span style="color: #BA2121">&quot;gdclassiffierroc&quot;</span>)
plt<span style="color: #666666">.</span>show()
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_cumulative_gain(y_test, y_probas)
save_fig(<span style="color: #BA2121">&quot;gdclassiffiercgain&quot;</span>)
plt<span style="color: #666666">.</span>show()
</pre></div>
<p>
@@ -296,20 +296,25 @@ y_test <span style="color: #666666">=</span> xg_clf<span style="color: #666666">
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">scikitplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">skplt</span>
y_pred <span style="color: #666666">=</span> xg_clf<span style="color: #666666">.</span>predict(X_test_scaled)
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_confusion_matrix(y_test, y_pred, normalize<span style="color: #666666">=</span><span style="color: #008000">True</span>)
save_fig(<span style="color: #BA2121">&quot;xdclassiffierconfusion&quot;</span>)
plt<span style="color: #666666">.</span>show()
y_probas <span style="color: #666666">=</span> xg_clf<span style="color: #666666">.</span>predict_proba(X_test_scaled)
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_roc(y_test, y_probas)
save_fig(<span style="color: #BA2121">&quot;xdclassiffierroc&quot;</span>)
plt<span style="color: #666666">.</span>show()
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_cumulative_gain(y_test, y_probas)
save_fig(<span style="color: #BA2121">&quot;gdclassiffiercgain&quot;</span>)
plt<span style="color: #666666">.</span>show()
xgb<span style="color: #666666">.</span>plot_tree(xg_clf,num_trees<span style="color: #666666">=0</span>)
plt<span style="color: #666666">.</span>rcParams[<span style="color: #BA2121">&#39;figure.figsize&#39;</span>] <span style="color: #666666">=</span> [<span style="color: #666666">50</span>, <span style="color: #666666">10</span>]
save_fig(<span style="color: #BA2121">&quot;xgtree&quot;</span>)
plt<span style="color: #666666">.</span>show()
xgb<span style="color: #666666">.</span>plot_importance(xg_clf)
plt<span style="color: #666666">.</span>rcParams[<span style="color: #BA2121">&#39;figure.figsize&#39;</span>] <span style="color: #666666">=</span> [<span style="color: #666666">5</span>, <span style="color: #666666">5</span>]
save_fig(<span style="color: #BA2121">&quot;xgparams&quot;</span>)
plt<span style="color: #666666">.</span>show()
</pre></div>
<p>
@@ -1537,6 +1537,7 @@ plt.xlabel(<span style="color: #CD5555">&quot;Number of coin tosses&quot;</span>
plt.ylabel(<span style="color: #CD5555">&quot;Heads ratio&quot;</span>)
plt.legend(loc=<span style="color: #CD5555">&quot;lower right&quot;</span>)
plt.axis([<span style="color: #B452CD">0</span>, <span style="color: #B452CD">10000</span>, <span style="color: #B452CD">0.42</span>, <span style="color: #B452CD">0.58</span>])
save_fig(<span style="color: #CD5555">&quot;votingsimple&quot;</span>)
plt.show()
</pre></div>
</section>
@@ -1710,6 +1711,7 @@ plt.title(<span style="color: #CD5555">&quot;Decision Tree&quot;</span>, fontsiz
plt.subplot(<span style="color: #B452CD">122</span>)
plot_decision_boundary(bag_clf, X, y)
plt.title(<span style="color: #CD5555">&quot;Decision Trees with Bagging&quot;</span>, fontsize=<span style="color: #B452CD">14</span>)
save_fig(<span style="color: #CD5555">&quot;baggingtree&quot;</span>)
plt.show()
</pre></div>
</section>
@@ -1770,6 +1772,7 @@ plt.plot(polydegree, error, label=<span style="color: #CD5555">&#39;Error&#39;</
plt.plot(polydegree, bias, label=<span style="color: #CD5555">&#39;bias&#39;</span>)
plt.plot(polydegree, variance, label=<span style="color: #CD5555">&#39;Variance&#39;</span>)
plt.legend()
save_fig(<span style="color: #CD5555">&quot;baggingboot&quot;</span>)
plt.show()
</pre></div>
</section>
@@ -2364,6 +2367,7 @@ plt.plot(polydegree, error, label=<span style="color: #CD5555">&#39;Error&#39;</
plt.plot(polydegree, bias, label=<span style="color: #CD5555">&#39;bias&#39;</span>)
plt.plot(polydegree, variance, label=<span style="color: #CD5555">&#39;Variance&#39;</span>)
plt.legend()
save_fig(<span style="color: #CD5555">&quot;gdregression&quot;</span>)
plt.show()
</pre></div>
</section>
@@ -2405,11 +2409,14 @@ accuracy = cross_validate(gd_clf,X_test_scaled,y_test,cv=<span style="color: #B4
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">scikitplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">skplt</span>
y_pred = gd_clf.predict(X_test_scaled)
skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=<span style="color: #658b00">True</span>)
save_fig(<span style="color: #CD5555">&quot;gdclassiffierconfusion&quot;</span>)
plt.show()
y_probas = gd_clf.predict_proba(X_test_scaled)
skplt.metrics.plot_roc(y_test, y_probas)
save_fig(<span style="color: #CD5555">&quot;gdclassiffierroc&quot;</span>)
plt.show()
skplt.metrics.plot_cumulative_gain(y_test, y_probas)
save_fig(<span style="color: #CD5555">&quot;gdclassiffiercgain&quot;</span>)
plt.show()
</pre></div>
</section>
@@ -2528,20 +2535,25 @@ y_test = xg_clf.predict(X_test_scaled)
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">scikitplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">skplt</span>
y_pred = xg_clf.predict(X_test_scaled)
skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=<span style="color: #658b00">True</span>)
save_fig(<span style="color: #CD5555">&quot;xdclassiffierconfusion&quot;</span>)
plt.show()
y_probas = xg_clf.predict_proba(X_test_scaled)
skplt.metrics.plot_roc(y_test, y_probas)
save_fig(<span style="color: #CD5555">&quot;xdclassiffierroc&quot;</span>)
plt.show()
skplt.metrics.plot_cumulative_gain(y_test, y_probas)
save_fig(<span style="color: #CD5555">&quot;gdclassiffiercgain&quot;</span>)
plt.show()
xgb.plot_tree(xg_clf,num_trees=<span style="color: #B452CD">0</span>)
plt.rcParams[<span style="color: #CD5555">&#39;figure.figsize&#39;</span>] = [<span style="color: #B452CD">50</span>, <span style="color: #B452CD">10</span>]
save_fig(<span style="color: #CD5555">&quot;xgtree&quot;</span>)
plt.show()
xgb.plot_importance(xg_clf)
plt.rcParams[<span style="color: #CD5555">&#39;figure.figsize&#39;</span>] = [<span style="color: #B452CD">5</span>, <span style="color: #B452CD">5</span>]
save_fig(<span style="color: #CD5555">&quot;xgparams&quot;</span>)
plt.show()
</pre></div>
</section>
@@ -1558,6 +1558,7 @@ plt.xlabel(<span style="color: #CD5555">&quot;Number of coin tosses&quot;</span>
plt.ylabel(<span style="color: #CD5555">&quot;Heads ratio&quot;</span>)
plt.legend(loc=<span style="color: #CD5555">&quot;lower right&quot;</span>)
plt.axis([<span style="color: #B452CD">0</span>, <span style="color: #B452CD">10000</span>, <span style="color: #B452CD">0.42</span>, <span style="color: #B452CD">0.58</span>])
save_fig(<span style="color: #CD5555">&quot;votingsimple&quot;</span>)
plt.show()
</pre></div>
<p>
@@ -1728,6 +1729,7 @@ plt.title(<span style="color: #CD5555">&quot;Decision Tree&quot;</span>, fontsiz
plt.subplot(<span style="color: #B452CD">122</span>)
plot_decision_boundary(bag_clf, X, y)
plt.title(<span style="color: #CD5555">&quot;Decision Trees with Bagging&quot;</span>, fontsize=<span style="color: #B452CD">14</span>)
save_fig(<span style="color: #CD5555">&quot;baggingtree&quot;</span>)
plt.show()
</pre></div>
<p>
@@ -1787,6 +1789,7 @@ plt.plot(polydegree, error, label=<span style="color: #CD5555">&#39;Error&#39;</
plt.plot(polydegree, bias, label=<span style="color: #CD5555">&#39;bias&#39;</span>)
plt.plot(polydegree, variance, label=<span style="color: #CD5555">&#39;Variance&#39;</span>)
plt.legend()
save_fig(<span style="color: #CD5555">&quot;baggingboot&quot;</span>)
plt.show()
</pre></div>
<p>
@@ -2329,6 +2332,7 @@ plt.plot(polydegree, error, label=<span style="color: #CD5555">&#39;Error&#39;</
plt.plot(polydegree, bias, label=<span style="color: #CD5555">&#39;bias&#39;</span>)
plt.plot(polydegree, variance, label=<span style="color: #CD5555">&#39;Variance&#39;</span>)
plt.legend()
save_fig(<span style="color: #CD5555">&quot;gdregression&quot;</span>)
plt.show()
</pre></div>
<p>
@@ -2369,11 +2373,14 @@ accuracy = cross_validate(gd_clf,X_test_scaled,y_test,cv=<span style="color: #B4
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">scikitplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">skplt</span>
y_pred = gd_clf.predict(X_test_scaled)
skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=<span style="color: #658b00">True</span>)
save_fig(<span style="color: #CD5555">&quot;gdclassiffierconfusion&quot;</span>)
plt.show()
y_probas = gd_clf.predict_proba(X_test_scaled)
skplt.metrics.plot_roc(y_test, y_probas)
save_fig(<span style="color: #CD5555">&quot;gdclassiffierroc&quot;</span>)
plt.show()
skplt.metrics.plot_cumulative_gain(y_test, y_probas)
save_fig(<span style="color: #CD5555">&quot;gdclassiffiercgain&quot;</span>)
plt.show()
</pre></div>
<p>
@@ -2490,20 +2497,25 @@ y_test = xg_clf.predict(X_test_scaled)
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">scikitplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">skplt</span>
y_pred = xg_clf.predict(X_test_scaled)
skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=<span style="color: #658b00">True</span>)
save_fig(<span style="color: #CD5555">&quot;xdclassiffierconfusion&quot;</span>)
plt.show()
y_probas = xg_clf.predict_proba(X_test_scaled)
skplt.metrics.plot_roc(y_test, y_probas)
save_fig(<span style="color: #CD5555">&quot;xdclassiffierroc&quot;</span>)
plt.show()
skplt.metrics.plot_cumulative_gain(y_test, y_probas)
save_fig(<span style="color: #CD5555">&quot;gdclassiffiercgain&quot;</span>)
plt.show()
xgb.plot_tree(xg_clf,num_trees=<span style="color: #B452CD">0</span>)
plt.rcParams[<span style="color: #CD5555">&#39;figure.figsize&#39;</span>] = [<span style="color: #B452CD">50</span>, <span style="color: #B452CD">10</span>]
save_fig(<span style="color: #CD5555">&quot;xgtree&quot;</span>)
plt.show()
xgb.plot_importance(xg_clf)
plt.rcParams[<span style="color: #CD5555">&#39;figure.figsize&#39;</span>] = [<span style="color: #B452CD">5</span>, <span style="color: #B452CD">5</span>]
save_fig(<span style="color: #CD5555">&quot;xgparams&quot;</span>)
plt.show()
</pre></div>
<p>
@@ -1563,6 +1563,7 @@ plt<span style="color: #666666">.</span>xlabel(<span style="color: #BA2121">&quo
plt<span style="color: #666666">.</span>ylabel(<span style="color: #BA2121">&quot;Heads ratio&quot;</span>)
plt<span style="color: #666666">.</span>legend(loc<span style="color: #666666">=</span><span style="color: #BA2121">&quot;lower right&quot;</span>)
plt<span style="color: #666666">.</span>axis([<span style="color: #666666">0</span>, <span style="color: #666666">10000</span>, <span style="color: #666666">0.42</span>, <span style="color: #666666">0.58</span>])
save_fig(<span style="color: #BA2121">&quot;votingsimple&quot;</span>)
plt<span style="color: #666666">.</span>show()
</pre></div>
<p>
@@ -1733,6 +1734,7 @@ plt<span style="color: #666666">.</span>title(<span style="color: #BA2121">&quot
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">&quot;Decision Trees with Bagging&quot;</span>, fontsize<span style="color: #666666">=14</span>)
save_fig(<span style="color: #BA2121">&quot;baggingtree&quot;</span>)
plt<span style="color: #666666">.</span>show()
</pre></div>
<p>
@@ -1792,6 +1794,7 @@ plt<span style="color: #666666">.</span>plot(polydegree, error, label<span style
plt<span style="color: #666666">.</span>plot(polydegree, bias, label<span style="color: #666666">=</span><span style="color: #BA2121">&#39;bias&#39;</span>)
plt<span style="color: #666666">.</span>plot(polydegree, variance, label<span style="color: #666666">=</span><span style="color: #BA2121">&#39;Variance&#39;</span>)
plt<span style="color: #666666">.</span>legend()
save_fig(<span style="color: #BA2121">&quot;baggingboot&quot;</span>)
plt<span style="color: #666666">.</span>show()
</pre></div>
<p>
@@ -2334,6 +2337,7 @@ plt<span style="color: #666666">.</span>plot(polydegree, error, label<span style
plt<span style="color: #666666">.</span>plot(polydegree, bias, label<span style="color: #666666">=</span><span style="color: #BA2121">&#39;bias&#39;</span>)
plt<span style="color: #666666">.</span>plot(polydegree, variance, label<span style="color: #666666">=</span><span style="color: #BA2121">&#39;Variance&#39;</span>)
plt<span style="color: #666666">.</span>legend()
save_fig(<span style="color: #BA2121">&quot;gdregression&quot;</span>)
plt<span style="color: #666666">.</span>show()
</pre></div>
<p>
@@ -2374,11 +2378,14 @@ accuracy <span style="color: #666666">=</span> cross_validate(gd_clf,X_test_scal
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">scikitplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">skplt</span>
y_pred <span style="color: #666666">=</span> gd_clf<span style="color: #666666">.</span>predict(X_test_scaled)
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_confusion_matrix(y_test, y_pred, normalize<span style="color: #666666">=</span><span style="color: #008000">True</span>)
save_fig(<span style="color: #BA2121">&quot;gdclassiffierconfusion&quot;</span>)
plt<span style="color: #666666">.</span>show()
y_probas <span style="color: #666666">=</span> gd_clf<span style="color: #666666">.</span>predict_proba(X_test_scaled)
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_roc(y_test, y_probas)
save_fig(<span style="color: #BA2121">&quot;gdclassiffierroc&quot;</span>)
plt<span style="color: #666666">.</span>show()
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_cumulative_gain(y_test, y_probas)
save_fig(<span style="color: #BA2121">&quot;gdclassiffiercgain&quot;</span>)
plt<span style="color: #666666">.</span>show()
</pre></div>
<p>
@@ -2495,20 +2502,25 @@ y_test <span style="color: #666666">=</span> xg_clf<span style="color: #666666">
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">scikitplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">skplt</span>
y_pred <span style="color: #666666">=</span> xg_clf<span style="color: #666666">.</span>predict(X_test_scaled)
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_confusion_matrix(y_test, y_pred, normalize<span style="color: #666666">=</span><span style="color: #008000">True</span>)
save_fig(<span style="color: #BA2121">&quot;xdclassiffierconfusion&quot;</span>)
plt<span style="color: #666666">.</span>show()
y_probas <span style="color: #666666">=</span> xg_clf<span style="color: #666666">.</span>predict_proba(X_test_scaled)
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_roc(y_test, y_probas)
save_fig(<span style="color: #BA2121">&quot;xdclassiffierroc&quot;</span>)
plt<span style="color: #666666">.</span>show()
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_cumulative_gain(y_test, y_probas)
save_fig(<span style="color: #BA2121">&quot;gdclassiffiercgain&quot;</span>)
plt<span style="color: #666666">.</span>show()
xgb<span style="color: #666666">.</span>plot_tree(xg_clf,num_trees<span style="color: #666666">=0</span>)
plt<span style="color: #666666">.</span>rcParams[<span style="color: #BA2121">&#39;figure.figsize&#39;</span>] <span style="color: #666666">=</span> [<span style="color: #666666">50</span>, <span style="color: #666666">10</span>]
save_fig(<span style="color: #BA2121">&quot;xgtree&quot;</span>)
plt<span style="color: #666666">.</span>show()
xgb<span style="color: #666666">.</span>plot_importance(xg_clf)
plt<span style="color: #666666">.</span>rcParams[<span style="color: #BA2121">&#39;figure.figsize&#39;</span>] <span style="color: #666666">=</span> [<span style="color: #666666">5</span>, <span style="color: #666666">5</span>]
save_fig(<span style="color: #BA2121">&quot;xgparams&quot;</span>)
plt<span style="color: #666666">.</span>show()
</pre></div>
<p>
@@ -6,11 +6,11 @@ edge [fontname=helvetica] ;
0 -> 1 [labeldistance=2.5, labelangle=45, headlabel="True"] ;
2 [label="worst concave points <= 0.135\ngini = 0.031\nsamples = 253\nvalue = [[249, 4]\n[4, 249]]", fillcolor="#e58139ee"] ;
1 -> 2 ;
3 [label="radius error <= 0.643\ngini = 0.008\nsamples = 242\nvalue = [[241, 1]\n[1, 241]]", fillcolor="#e58139fb"] ;
3 [label="area error <= 48.975\ngini = 0.008\nsamples = 242\nvalue = [[241, 1]\n[1, 241]]", fillcolor="#e58139fb"] ;
2 -> 3 ;
4 [label="gini = 0.0\nsamples = 239\nvalue = [[239, 0]\n[0, 239]]", fillcolor="#e58139ff"] ;
3 -> 4 ;
5 [label="mean symmetry <= 0.166\ngini = 0.444\nsamples = 3\nvalue = [[2, 1]\n[1, 2]]", fillcolor="#e5813913"] ;
5 [label="area error <= 51.38\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 ;
@@ -22,7 +22,7 @@ edge [fontname=helvetica] ;
8 -> 9 ;
10 [label="gini = 0.0\nsamples = 3\nvalue = [[0, 3]\n[3, 0]]", fillcolor="#e58139ff"] ;
8 -> 10 ;
11 [label="mean texture <= 16.22\ngini = 0.278\nsamples = 6\nvalue = [[1, 5]\n[5, 1]]", fillcolor="#e581396b"] ;
11 [label="area error <= 13.475\ngini = 0.278\nsamples = 6\nvalue = [[1, 5]\n[5, 1]]", fillcolor="#e581396b"] ;
1 -> 11 ;
12 [label="gini = 0.0\nsamples = 1\nvalue = [[1, 0]\n[0, 1]]", fillcolor="#e58139ff"] ;
11 -> 12 ;
@@ -30,11 +30,11 @@ 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 area <= 964.4\ngini = 0.375\nsamples = 16\nvalue = [[12, 4]\n[4, 12]]", fillcolor="#e5813938"] ;
15 [label="worst concavity <= 0.318\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 ;
17 [label="mean symmetry <= 0.141\ngini = 0.32\nsamples = 5\nvalue = [[1, 4]\n[4, 1]]", fillcolor="#e5813955"] ;
17 [label="radius error <= 0.251\ngini = 0.32\nsamples = 5\nvalue = [[1, 4]\n[4, 1]]", fillcolor="#e5813955"] ;
15 -> 17 ;
18 [label="gini = 0.0\nsamples = 1\nvalue = [[1, 0]\n[0, 1]]", fillcolor="#e58139ff"] ;
17 -> 18 ;
@@ -42,13 +42,13 @@ edge [fontname=helvetica] ;
17 -> 19 ;
20 [label="mean concave points <= 0.049\ngini = 0.088\nsamples = 151\nvalue = [[7, 144]\n[144, 7]]", fillcolor="#e58139d0"] ;
14 -> 20 ;
21 [label="compactness error <= 0.016\ngini = 0.48\nsamples = 15\nvalue = [[6, 9]\n[9, 6]]", fillcolor="#e5813900"] ;
21 [label="concave points error <= 0.01\ngini = 0.48\nsamples = 15\nvalue = [[6, 9]\n[9, 6]]", fillcolor="#e5813900"] ;
20 -> 21 ;
22 [label="gini = 0.0\nsamples = 9\nvalue = [[0, 9]\n[9, 0]]", fillcolor="#e58139ff"] ;
21 -> 22 ;
23 [label="gini = 0.0\nsamples = 6\nvalue = [[6, 0]\n[0, 6]]", fillcolor="#e58139ff"] ;
21 -> 23 ;
24 [label="mean smoothness <= 0.079\ngini = 0.015\nsamples = 136\nvalue = [[1, 135]\n[135, 1]]", fillcolor="#e58139f7"] ;
24 [label="worst smoothness <= 0.096\ngini = 0.015\nsamples = 136\nvalue = [[1, 135]\n[135, 1]]", fillcolor="#e58139f7"] ;
20 -> 24 ;
25 [label="gini = 0.0\nsamples = 1\nvalue = [[1, 0]\n[0, 1]]", fillcolor="#e58139ff"] ;
24 -> 25 ;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 KiB

After

Width:  |  Height:  |  Size: 214 KiB

@@ -1492,6 +1492,7 @@
"plt.ylabel(\"Heads ratio\")\n",
"plt.legend(loc=\"lower right\")\n",
"plt.axis([0, 10000, 0.42, 0.58])\n",
"save_fig(\"votingsimple\")\n",
"plt.show()"
]
},
@@ -1724,6 +1725,7 @@
"plt.subplot(122)\n",
"plot_decision_boundary(bag_clf, X, y)\n",
"plt.title(\"Decision Trees with Bagging\", fontsize=14)\n",
"save_fig(\"baggingtree\")\n",
"plt.show()"
]
},
@@ -1792,6 +1794,7 @@
"plt.plot(polydegree, bias, label='bias')\n",
"plt.plot(polydegree, variance, label='Variance')\n",
"plt.legend()\n",
"save_fig(\"baggingboot\")\n",
"plt.show()"
]
},
@@ -2535,6 +2538,7 @@
"plt.plot(polydegree, bias, label='bias')\n",
"plt.plot(polydegree, variance, label='Variance')\n",
"plt.legend()\n",
"save_fig(\"gdregression\")\n",
"plt.show()"
]
},
@@ -2584,11 +2588,14 @@
"import scikitplot as skplt\n",
"y_pred = gd_clf.predict(X_test_scaled)\n",
"skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)\n",
"save_fig(\"gdclassiffierconfusion\")\n",
"plt.show()\n",
"y_probas = gd_clf.predict_proba(X_test_scaled)\n",
"skplt.metrics.plot_roc(y_test, y_probas)\n",
"save_fig(\"gdclassiffierroc\")\n",
"plt.show()\n",
"skplt.metrics.plot_cumulative_gain(y_test, y_probas)\n",
"save_fig(\"gdclassiffiercgain\")\n",
"plt.show()"
]
},
@@ -2718,20 +2725,25 @@
"import scikitplot as skplt\n",
"y_pred = xg_clf.predict(X_test_scaled)\n",
"skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)\n",
"save_fig(\"xdclassiffierconfusion\")\n",
"plt.show()\n",
"y_probas = xg_clf.predict_proba(X_test_scaled)\n",
"skplt.metrics.plot_roc(y_test, y_probas)\n",
"save_fig(\"xdclassiffierroc\")\n",
"plt.show()\n",
"skplt.metrics.plot_cumulative_gain(y_test, y_probas)\n",
"save_fig(\"gdclassiffiercgain\")\n",
"plt.show()\n",
"\n",
"\n",
"xgb.plot_tree(xg_clf,num_trees=0)\n",
"plt.rcParams['figure.figsize'] = [50, 10]\n",
"save_fig(\"xgtree\")\n",
"plt.show()\n",
"\n",
"xgb.plot_importance(xg_clf)\n",
"plt.rcParams['figure.figsize'] = [5, 5]\n",
"save_fig(\"xgparams\")\n",
"plt.show()"
]
}
Binary file not shown.
@@ -1228,6 +1228,7 @@ plt.xlabel("Number of coin tosses")
plt.ylabel("Heads ratio")
plt.legend(loc="lower right")
plt.axis([0, 10000, 0.42, 0.58])
save_fig("votingsimple")
plt.show()
!ec
@@ -1386,6 +1387,7 @@ plt.title("Decision Tree", fontsize=14)
plt.subplot(122)
plot_decision_boundary(bag_clf, X, y)
plt.title("Decision Trees with Bagging", fontsize=14)
save_fig("baggingtree")
plt.show()
!ec
@@ -1445,6 +1447,7 @@ plt.plot(polydegree, error, label='Error')
plt.plot(polydegree, bias, label='bias')
plt.plot(polydegree, variance, label='Variance')
plt.legend()
save_fig("baggingboot")
plt.show()
!ec
@@ -1940,6 +1943,7 @@ plt.plot(polydegree, error, label='Error')
plt.plot(polydegree, bias, label='bias')
plt.plot(polydegree, variance, label='Variance')
plt.legend()
save_fig("gdregression")
plt.show()
!ec
@@ -1978,11 +1982,14 @@ print("Test set accuracy with Random Forests and scaled data: {:.2f}".format(gd_
import scikitplot as skplt
y_pred = gd_clf.predict(X_test_scaled)
skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)
save_fig("gdclassiffierconfusion")
plt.show()
y_probas = gd_clf.predict_proba(X_test_scaled)
skplt.metrics.plot_roc(y_test, y_probas)
save_fig("gdclassiffierroc")
plt.show()
skplt.metrics.plot_cumulative_gain(y_test, y_probas)
save_fig("gdclassiffiercgain")
plt.show()
!ec
@@ -2092,20 +2099,25 @@ print("Test set accuracy with Random Forests and scaled data: {:.2f}".format(xg_
import scikitplot as skplt
y_pred = xg_clf.predict(X_test_scaled)
skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)
save_fig("xdclassiffierconfusion")
plt.show()
y_probas = xg_clf.predict_proba(X_test_scaled)
skplt.metrics.plot_roc(y_test, y_probas)
save_fig("xdclassiffierroc")
plt.show()
skplt.metrics.plot_cumulative_gain(y_test, y_probas)
save_fig("gdclassiffiercgain")
plt.show()
xgb.plot_tree(xg_clf,num_trees=0)
plt.rcParams['figure.figsize'] = [50, 10]
save_fig("xgtree")
plt.show()
xgb.plot_importance(xg_clf)
plt.rcParams['figure.figsize'] = [5, 5]
save_fig("xgparams")
plt.show()
!ec