Created
July 30, 2020 14:44
-
-
Save liannewriting/d836989afc60c09aa0a3caea943d4e6f to your computer and use it in GitHub Desktop.
random forest machine learning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fpr_dt, tpr_dt, thresholds_lstm = roc_curve(y_test, y_test_pred_dt[:,1]) | |
fpr_rf, tpr_rf, thresholds_lstm = roc_curve(y_test, y_test_pred_rf[:,1]) | |
dt_auc = roc_auc_score(y_test, y_test_pred_dt[:,1]) | |
rf_auc = roc_auc_score(y_test, y_test_pred_rf[:,1]) | |
plt.figure(figsize=(10,8)) | |
plt.plot([0, 1], [0, 1], 'k--') | |
plt.plot(fpr_dt, tpr_dt, label='Decision Tree (AUC = {:.3f})'.format(dt_auc)) | |
plt.plot(fpr_rf, tpr_rf, label='Random Forest (AUC = {:.3f})'.format(rf_auc)) | |
plt.xlabel('False positive rate') | |
plt.ylabel('True positive rate') | |
plt.title('ROC curve') | |
plt.legend(loc='best') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment