Skip to content

Instantly share code, notes, and snippets.

@liannewriting
Created July 30, 2020 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liannewriting/d836989afc60c09aa0a3caea943d4e6f to your computer and use it in GitHub Desktop.
Save liannewriting/d836989afc60c09aa0a3caea943d4e6f to your computer and use it in GitHub Desktop.
random forest machine learning
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