update
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user