update
@@ -183,20 +183,13 @@ MathJax.Hub.Config({
|
||||
<pre style="line-height: 125%;"><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>)
|
||||
DecisionTreeClassifier(max_depth<span style="color: #666666">=2</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.01</span>, random_state<span style="color: #666666">=42</span>)
|
||||
ada_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
|
||||
<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_scaled, y_train)
|
||||
y_pred <span style="color: #666666">=</span> ada_clf<span style="color: #666666">.</span>predict(X_test_scaled)
|
||||
y_pred <span style="color: #666666">=</span> ada_clf<span style="color: #666666">.</span>predict(X_test)
|
||||
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; font-weight: bold">True</span>)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
y_probas <span style="color: #666666">=</span> ada_clf<span style="color: #666666">.</span>predict_proba(X_test_scaled)
|
||||
y_probas <span style="color: #666666">=</span> ada_clf<span style="color: #666666">.</span>predict_proba(X_test)
|
||||
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_roc(y_test, y_probas)
|
||||
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)
|
||||
|
||||
@@ -203,7 +203,7 @@ gd_clf<span style="color: #666666">.</span>fit(X_train_scaled, y_train)
|
||||
<span style="color: #408080; font-style: italic">#Cross validation</span>
|
||||
accuracy <span style="color: #666666">=</span> cross_validate(gd_clf,X_test_scaled,y_test,cv<span style="color: #666666">=10</span>)[<span style="color: #BA2121">'test_score'</span>]
|
||||
<span style="color: #008000">print</span>(accuracy)
|
||||
<span style="color: #008000">print</span>(<span style="color: #BA2121">"Test set accuracy with Random Forests and scaled data: </span><span style="color: #BB6688; font-weight: bold">{:.2f}</span><span style="color: #BA2121">"</span><span style="color: #666666">.</span>format(gd_clf<span style="color: #666666">.</span>score(X_test_scaled,y_test)))
|
||||
<span style="color: #008000">print</span>(<span style="color: #BA2121">"Test set accuracy with Gradient boosting and scaled data: </span><span style="color: #BB6688; font-weight: bold">{:.2f}</span><span style="color: #BA2121">"</span><span style="color: #666666">.</span>format(gd_clf<span style="color: #666666">.</span>score(X_test_scaled,y_test)))
|
||||
|
||||
<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)
|
||||
|
||||
@@ -205,7 +205,7 @@ xg_clf<span style="color: #666666">.</span>fit(X_train_scaled,y_train)
|
||||
|
||||
y_test <span style="color: #666666">=</span> xg_clf<span style="color: #666666">.</span>predict(X_test_scaled)
|
||||
|
||||
<span style="color: #008000">print</span>(<span style="color: #BA2121">"Test set accuracy with Random Forests and scaled data: </span><span style="color: #BB6688; font-weight: bold">{:.2f}</span><span style="color: #BA2121">"</span><span style="color: #666666">.</span>format(xg_clf<span style="color: #666666">.</span>score(X_test_scaled,y_test)))
|
||||
<span style="color: #008000">print</span>(<span style="color: #BA2121">"Test set accuracy with Gradient Boosting and scaled data: </span><span style="color: #BB6688; font-weight: bold">{:.2f}</span><span style="color: #BA2121">"</span><span style="color: #666666">.</span>format(xg_clf<span style="color: #666666">.</span>score(X_test_scaled,y_test)))
|
||||
|
||||
<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)
|
||||
|
||||
@@ -687,20 +687,13 @@ observations that are missed in the previous iterations.
|
||||
<pre style="font-size: 80%; line-height: 125%;"><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>)
|
||||
DecisionTreeClassifier(max_depth=<span style="color: #B452CD">2</span>), n_estimators=<span style="color: #B452CD">200</span>,
|
||||
algorithm=<span style="color: #CD5555">"SAMME.R"</span>, learning_rate=<span style="color: #B452CD">0.01</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
ada_clf.fit(X_train, y_train)
|
||||
|
||||
<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_scaled, y_train)
|
||||
y_pred = ada_clf.predict(X_test_scaled)
|
||||
y_pred = ada_clf.predict(X_test)
|
||||
skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=<span style="color: #8B008B; font-weight: bold">True</span>)
|
||||
plt.show()
|
||||
y_probas = ada_clf.predict_proba(X_test_scaled)
|
||||
y_probas = ada_clf.predict_proba(X_test)
|
||||
skplt.metrics.plot_roc(y_test, y_probas)
|
||||
plt.show()
|
||||
skplt.metrics.plot_cumulative_gain(y_test, y_probas)
|
||||
@@ -924,7 +917,7 @@ gd_clf.fit(X_train_scaled, y_train)
|
||||
<span style="color: #228B22">#Cross validation</span>
|
||||
accuracy = cross_validate(gd_clf,X_test_scaled,y_test,cv=<span style="color: #B452CD">10</span>)[<span style="color: #CD5555">'test_score'</span>]
|
||||
<span style="color: #658b00">print</span>(accuracy)
|
||||
<span style="color: #658b00">print</span>(<span style="color: #CD5555">"Test set accuracy with Random Forests and scaled data: {:.2f}"</span>.format(gd_clf.score(X_test_scaled,y_test)))
|
||||
<span style="color: #658b00">print</span>(<span style="color: #CD5555">"Test set accuracy with Gradient boosting and scaled data: {:.2f}"</span>.format(gd_clf.score(X_test_scaled,y_test)))
|
||||
|
||||
<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)
|
||||
@@ -1077,7 +1070,7 @@ xg_clf.fit(X_train_scaled,y_train)
|
||||
|
||||
y_test = xg_clf.predict(X_test_scaled)
|
||||
|
||||
<span style="color: #658b00">print</span>(<span style="color: #CD5555">"Test set accuracy with Random Forests and scaled data: {:.2f}"</span>.format(xg_clf.score(X_test_scaled,y_test)))
|
||||
<span style="color: #658b00">print</span>(<span style="color: #CD5555">"Test set accuracy with Gradient Boosting and scaled data: {:.2f}"</span>.format(xg_clf.score(X_test_scaled,y_test)))
|
||||
|
||||
<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)
|
||||
|
||||
@@ -603,20 +603,13 @@ observations that are missed in the previous iterations.
|
||||
<pre style="line-height: 125%;"><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>)
|
||||
DecisionTreeClassifier(max_depth=<span style="color: #B452CD">2</span>), n_estimators=<span style="color: #B452CD">200</span>,
|
||||
algorithm=<span style="color: #CD5555">"SAMME.R"</span>, learning_rate=<span style="color: #B452CD">0.01</span>, random_state=<span style="color: #B452CD">42</span>)
|
||||
ada_clf.fit(X_train, y_train)
|
||||
|
||||
<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_scaled, y_train)
|
||||
y_pred = ada_clf.predict(X_test_scaled)
|
||||
y_pred = ada_clf.predict(X_test)
|
||||
skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=<span style="color: #8B008B; font-weight: bold">True</span>)
|
||||
plt.show()
|
||||
y_probas = ada_clf.predict_proba(X_test_scaled)
|
||||
y_probas = ada_clf.predict_proba(X_test)
|
||||
skplt.metrics.plot_roc(y_test, y_probas)
|
||||
plt.show()
|
||||
skplt.metrics.plot_cumulative_gain(y_test, y_probas)
|
||||
@@ -821,7 +814,7 @@ gd_clf.fit(X_train_scaled, y_train)
|
||||
<span style="color: #228B22">#Cross validation</span>
|
||||
accuracy = cross_validate(gd_clf,X_test_scaled,y_test,cv=<span style="color: #B452CD">10</span>)[<span style="color: #CD5555">'test_score'</span>]
|
||||
<span style="color: #658b00">print</span>(accuracy)
|
||||
<span style="color: #658b00">print</span>(<span style="color: #CD5555">"Test set accuracy with Random Forests and scaled data: {:.2f}"</span>.format(gd_clf.score(X_test_scaled,y_test)))
|
||||
<span style="color: #658b00">print</span>(<span style="color: #CD5555">"Test set accuracy with Gradient boosting and scaled data: {:.2f}"</span>.format(gd_clf.score(X_test_scaled,y_test)))
|
||||
|
||||
<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)
|
||||
@@ -973,7 +966,7 @@ xg_clf.fit(X_train_scaled,y_train)
|
||||
|
||||
y_test = xg_clf.predict(X_test_scaled)
|
||||
|
||||
<span style="color: #658b00">print</span>(<span style="color: #CD5555">"Test set accuracy with Random Forests and scaled data: {:.2f}"</span>.format(xg_clf.score(X_test_scaled,y_test)))
|
||||
<span style="color: #658b00">print</span>(<span style="color: #CD5555">"Test set accuracy with Gradient Boosting and scaled data: {:.2f}"</span>.format(xg_clf.score(X_test_scaled,y_test)))
|
||||
|
||||
<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)
|
||||
|
||||
@@ -680,20 +680,13 @@ observations that are missed in the previous iterations.
|
||||
<pre style="line-height: 125%;"><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>)
|
||||
DecisionTreeClassifier(max_depth<span style="color: #666666">=2</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.01</span>, random_state<span style="color: #666666">=42</span>)
|
||||
ada_clf<span style="color: #666666">.</span>fit(X_train, y_train)
|
||||
|
||||
<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_scaled, y_train)
|
||||
y_pred <span style="color: #666666">=</span> ada_clf<span style="color: #666666">.</span>predict(X_test_scaled)
|
||||
y_pred <span style="color: #666666">=</span> ada_clf<span style="color: #666666">.</span>predict(X_test)
|
||||
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; font-weight: bold">True</span>)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
y_probas <span style="color: #666666">=</span> ada_clf<span style="color: #666666">.</span>predict_proba(X_test_scaled)
|
||||
y_probas <span style="color: #666666">=</span> ada_clf<span style="color: #666666">.</span>predict_proba(X_test)
|
||||
skplt<span style="color: #666666">.</span>metrics<span style="color: #666666">.</span>plot_roc(y_test, y_probas)
|
||||
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)
|
||||
@@ -898,7 +891,7 @@ gd_clf<span style="color: #666666">.</span>fit(X_train_scaled, y_train)
|
||||
<span style="color: #408080; font-style: italic">#Cross validation</span>
|
||||
accuracy <span style="color: #666666">=</span> cross_validate(gd_clf,X_test_scaled,y_test,cv<span style="color: #666666">=10</span>)[<span style="color: #BA2121">'test_score'</span>]
|
||||
<span style="color: #008000">print</span>(accuracy)
|
||||
<span style="color: #008000">print</span>(<span style="color: #BA2121">"Test set accuracy with Random Forests and scaled data: </span><span style="color: #BB6688; font-weight: bold">{:.2f}</span><span style="color: #BA2121">"</span><span style="color: #666666">.</span>format(gd_clf<span style="color: #666666">.</span>score(X_test_scaled,y_test)))
|
||||
<span style="color: #008000">print</span>(<span style="color: #BA2121">"Test set accuracy with Gradient boosting and scaled data: </span><span style="color: #BB6688; font-weight: bold">{:.2f}</span><span style="color: #BA2121">"</span><span style="color: #666666">.</span>format(gd_clf<span style="color: #666666">.</span>score(X_test_scaled,y_test)))
|
||||
|
||||
<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)
|
||||
@@ -1050,7 +1043,7 @@ xg_clf<span style="color: #666666">.</span>fit(X_train_scaled,y_train)
|
||||
|
||||
y_test <span style="color: #666666">=</span> xg_clf<span style="color: #666666">.</span>predict(X_test_scaled)
|
||||
|
||||
<span style="color: #008000">print</span>(<span style="color: #BA2121">"Test set accuracy with Random Forests and scaled data: </span><span style="color: #BB6688; font-weight: bold">{:.2f}</span><span style="color: #BA2121">"</span><span style="color: #666666">.</span>format(xg_clf<span style="color: #666666">.</span>score(X_test_scaled,y_test)))
|
||||
<span style="color: #008000">print</span>(<span style="color: #BA2121">"Test set accuracy with Gradient Boosting and scaled data: </span><span style="color: #BB6688; font-weight: bold">{:.2f}</span><span style="color: #BA2121">"</span><span style="color: #666666">.</span>format(xg_clf<span style="color: #666666">.</span>score(X_test_scaled,y_test)))
|
||||
|
||||
<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)
|
||||
|
||||
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 40 KiB |
@@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7a978d39",
|
||||
"id": "0390330f",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -14,7 +14,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e0283e6d",
|
||||
"id": "ed227e0a",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -29,7 +29,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a3136428",
|
||||
"id": "a929ebc6",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -57,7 +57,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e2e0134a",
|
||||
"id": "85e77790",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -68,7 +68,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "2fdb28db",
|
||||
"id": "5e91cc51",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -168,7 +168,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "eb3a5ee9",
|
||||
"id": "f274de50",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -188,7 +188,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b793724a",
|
||||
"id": "a3ee5d55",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -202,7 +202,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "f2c22ac4",
|
||||
"id": "2618a55d",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -214,7 +214,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "cbaa4a6f",
|
||||
"id": "597685fa",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -231,7 +231,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "c0ea84be",
|
||||
"id": "8c005547",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -243,7 +243,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "94736458",
|
||||
"id": "f0d95638",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -257,7 +257,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b41565d5",
|
||||
"id": "e1458787",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -269,7 +269,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "c1b8efd9",
|
||||
"id": "ee5a736f",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -282,7 +282,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7f7e8a84",
|
||||
"id": "bed00bbe",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -294,7 +294,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ed8d7b77",
|
||||
"id": "1fe3bb5f",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -304,7 +304,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "4246f00d",
|
||||
"id": "df99ec7e",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -332,7 +332,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6ccbc0e9",
|
||||
"id": "e4b524c4",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -348,7 +348,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "4b4f4548",
|
||||
"id": "19c819b0",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -360,7 +360,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "f5434423",
|
||||
"id": "8d109790",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -371,7 +371,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a4c33651",
|
||||
"id": "ee081a3a",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -383,7 +383,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d25fd438",
|
||||
"id": "b2bae97d",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -393,7 +393,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "261f7514",
|
||||
"id": "5223b5c2",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -405,7 +405,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ee46c495",
|
||||
"id": "ce26055f",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -415,7 +415,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "4b6cf657",
|
||||
"id": "fc99c7cc",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -427,7 +427,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "07fd8905",
|
||||
"id": "3a9d23a2",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -437,7 +437,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "17699be3",
|
||||
"id": "760e7406",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -449,7 +449,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "91046f02",
|
||||
"id": "40c20004",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -463,7 +463,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b886c010",
|
||||
"id": "9b3e0a3b",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -479,7 +479,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b5f82299",
|
||||
"id": "2130f355",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -491,7 +491,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "9843cd00",
|
||||
"id": "e0dd6c3b",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -507,7 +507,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "1090524c",
|
||||
"id": "2caa0cd9",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -519,7 +519,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "f3088911",
|
||||
"id": "5c322d03",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -529,7 +529,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "4ba3fedb",
|
||||
"id": "43bc091e",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -541,7 +541,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6e447640",
|
||||
"id": "74f9b600",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -553,7 +553,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a114cfe7",
|
||||
"id": "8fa9b8d2",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -565,7 +565,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a00f5ba6",
|
||||
"id": "c5fb7346",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -576,7 +576,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ea0be85b",
|
||||
"id": "6265022d",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -588,7 +588,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a65ab9b7",
|
||||
"id": "9427f3b7",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -599,7 +599,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b7cffa99",
|
||||
"id": "41e09593",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -611,7 +611,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "081d507c",
|
||||
"id": "4e5d6ddd",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -621,7 +621,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6e734ee3",
|
||||
"id": "ceaf8ca9",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -633,7 +633,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ee564d2c",
|
||||
"id": "fdfb1c53",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -645,7 +645,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a9cc2890",
|
||||
"id": "3c2001ad",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -657,7 +657,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "3a89610f",
|
||||
"id": "caddc076",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -669,7 +669,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a2b97b3f",
|
||||
"id": "bd6ceda0",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -679,7 +679,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "edd6b448",
|
||||
"id": "2d13c739",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -691,7 +691,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6e5b95b5",
|
||||
"id": "b0bf2d85",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -701,7 +701,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "3e656f64",
|
||||
"id": "a903716f",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -713,7 +713,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "871fb2d1",
|
||||
"id": "5759332b",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -723,7 +723,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "80d6e316",
|
||||
"id": "926af936",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -735,7 +735,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "939363d6",
|
||||
"id": "4b2ec03e",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -745,7 +745,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "70e5b39d",
|
||||
"id": "4adaec50",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -757,7 +757,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "1394fd74",
|
||||
"id": "33247b99",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -767,7 +767,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6909eec6",
|
||||
"id": "459b88e8",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -779,7 +779,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d7b56142",
|
||||
"id": "fb1c0ed4",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -799,7 +799,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a31c3041",
|
||||
"id": "16fab3df",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -811,7 +811,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a771e5f4",
|
||||
"id": "c3a727d8",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -821,7 +821,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "9a9c96d1",
|
||||
"id": "53dbd815",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -837,7 +837,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "07323be9",
|
||||
"id": "41b2997e",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -849,7 +849,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "3c996e3d",
|
||||
"id": "c5fe12ab",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -877,7 +877,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "39637844",
|
||||
"id": "2473e65c",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -890,7 +890,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "76903ecb",
|
||||
"id": "d8294a5a",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -900,20 +900,13 @@
|
||||
"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",
|
||||
" DecisionTreeClassifier(max_depth=2), n_estimators=200,\n",
|
||||
" algorithm=\"SAMME.R\", learning_rate=0.01, random_state=42)\n",
|
||||
"ada_clf.fit(X_train, y_train)\n",
|
||||
"\n",
|
||||
"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_scaled, y_train)\n",
|
||||
"y_pred = ada_clf.predict(X_test_scaled)\n",
|
||||
"y_pred = ada_clf.predict(X_test)\n",
|
||||
"skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)\n",
|
||||
"plt.show()\n",
|
||||
"y_probas = ada_clf.predict_proba(X_test_scaled)\n",
|
||||
"y_probas = ada_clf.predict_proba(X_test)\n",
|
||||
"skplt.metrics.plot_roc(y_test, y_probas)\n",
|
||||
"plt.show()\n",
|
||||
"skplt.metrics.plot_cumulative_gain(y_test, y_probas)\n",
|
||||
@@ -922,7 +915,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ca8755d2",
|
||||
"id": "978e8480",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -940,7 +933,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "f0463b3c",
|
||||
"id": "a523f5cf",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -953,7 +946,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "8b514ec6",
|
||||
"id": "2f8962b5",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -965,7 +958,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "423db9ff",
|
||||
"id": "b589f52f",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -975,7 +968,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "06b275d6",
|
||||
"id": "6789a65a",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -987,7 +980,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "4ca06fe0",
|
||||
"id": "5b79bf7a",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -997,7 +990,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "da5754bd",
|
||||
"id": "e29a5715",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1009,7 +1002,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "c0f54e05",
|
||||
"id": "76985d66",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1022,7 +1015,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "9152ac2b",
|
||||
"id": "0856533f",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1034,7 +1027,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a4d9623f",
|
||||
"id": "62fddf2a",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1046,7 +1039,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "5c95acd3",
|
||||
"id": "793e5b50",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1058,7 +1051,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "08667505",
|
||||
"id": "ef01915e",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1068,7 +1061,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "95940c93",
|
||||
"id": "9ad855b9",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1080,7 +1073,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "888345e6",
|
||||
"id": "c9ecda21",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1090,7 +1083,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "3aa4d471",
|
||||
"id": "bb743a44",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1106,7 +1099,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7778dcfd",
|
||||
"id": "dcabad2c",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1118,7 +1111,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "70b44d33",
|
||||
"id": "3203ed8a",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1139,7 +1132,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "4ca117e7",
|
||||
"id": "72d87e5d",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1150,7 +1143,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "2039b018",
|
||||
"id": "6952ec4a",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -1202,7 +1195,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6db0b31b",
|
||||
"id": "541e23cb",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1213,7 +1206,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "de26bfe7",
|
||||
"id": "20ea1ea2",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -1246,7 +1239,7 @@
|
||||
"#Cross validation\n",
|
||||
"accuracy = cross_validate(gd_clf,X_test_scaled,y_test,cv=10)['test_score']\n",
|
||||
"print(accuracy)\n",
|
||||
"print(\"Test set accuracy with Random Forests and scaled data: {:.2f}\".format(gd_clf.score(X_test_scaled,y_test)))\n",
|
||||
"print(\"Test set accuracy with Gradient boosting and scaled data: {:.2f}\".format(gd_clf.score(X_test_scaled,y_test)))\n",
|
||||
"\n",
|
||||
"import scikitplot as skplt\n",
|
||||
"y_pred = gd_clf.predict(X_test_scaled)\n",
|
||||
@@ -1264,7 +1257,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "98629401",
|
||||
"id": "3743f453",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1287,7 +1280,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "70f7d4cc",
|
||||
"id": "0a0e233f",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1298,7 +1291,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "01dab946",
|
||||
"id": "09ac4619",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -1350,7 +1343,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "f132426b",
|
||||
"id": "b6b421c6",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1363,7 +1356,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "7bed8a59",
|
||||
"id": "69a4d95f",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -1397,7 +1390,7 @@
|
||||
"\n",
|
||||
"y_test = xg_clf.predict(X_test_scaled)\n",
|
||||
"\n",
|
||||
"print(\"Test set accuracy with Random Forests and scaled data: {:.2f}\".format(xg_clf.score(X_test_scaled,y_test)))\n",
|
||||
"print(\"Test set accuracy with Gradient Boosting and scaled data: {:.2f}\".format(xg_clf.score(X_test_scaled,y_test)))\n",
|
||||
"\n",
|
||||
"import scikitplot as skplt\n",
|
||||
"y_pred = xg_clf.predict(X_test_scaled)\n",
|
||||
|
||||
@@ -420,20 +420,13 @@ Using _Scikit-Learn_ it is easy to apply the adaptive boosting algorithm, as don
|
||||
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)
|
||||
DecisionTreeClassifier(max_depth=2), n_estimators=200,
|
||||
algorithm="SAMME.R", learning_rate=0.01, random_state=42)
|
||||
ada_clf.fit(X_train, y_train)
|
||||
|
||||
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_scaled, y_train)
|
||||
y_pred = ada_clf.predict(X_test_scaled)
|
||||
y_pred = ada_clf.predict(X_test)
|
||||
skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)
|
||||
plt.show()
|
||||
y_probas = ada_clf.predict_proba(X_test_scaled)
|
||||
y_probas = ada_clf.predict_proba(X_test)
|
||||
skplt.metrics.plot_roc(y_test, y_probas)
|
||||
plt.show()
|
||||
skplt.metrics.plot_cumulative_gain(y_test, y_probas)
|
||||
@@ -606,7 +599,7 @@ gd_clf.fit(X_train_scaled, y_train)
|
||||
#Cross validation
|
||||
accuracy = cross_validate(gd_clf,X_test_scaled,y_test,cv=10)['test_score']
|
||||
print(accuracy)
|
||||
print("Test set accuracy with Random Forests and scaled data: {:.2f}".format(gd_clf.score(X_test_scaled,y_test)))
|
||||
print("Test set accuracy with Gradient boosting and scaled data: {:.2f}".format(gd_clf.score(X_test_scaled,y_test)))
|
||||
|
||||
import scikitplot as skplt
|
||||
y_pred = gd_clf.predict(X_test_scaled)
|
||||
@@ -720,7 +713,7 @@ xg_clf.fit(X_train_scaled,y_train)
|
||||
|
||||
y_test = xg_clf.predict(X_test_scaled)
|
||||
|
||||
print("Test set accuracy with Random Forests and scaled data: {:.2f}".format(xg_clf.score(X_test_scaled,y_test)))
|
||||
print("Test set accuracy with Gradient Boosting and scaled data: {:.2f}".format(xg_clf.score(X_test_scaled,y_test)))
|
||||
|
||||
import scikitplot as skplt
|
||||
y_pred = xg_clf.predict(X_test_scaled)
|
||||
|
||||