...

/

ROC Curve and Saving the Model

ROC Curve and Saving the Model

Plot the ROC curve, and save the final best model for later use.

We'll cover the following...

Since scaled features are giving us the best results, this will be our final model.

ROC curve

Let's plot the ROC curve and save the final model for later use.

Press + to interact
# Required imports from scikit-learn
from sklearn.metrics import roc_curve, roc_auc_score
# Area Under the ROC Curve
grid_auc = roc_auc_score(y_test, grid.predict_proba(X_test)[:,1])
# setting the figure size
plt.figure(figsize = (18, 6))
# Computing Receiver operating characteristic (ROC)
fpr_grid, tpr_grid, thresholds_grid = roc_curve(y_test, grid.predict_proba(X_test)[:,1])
# plot no skill - A line for random guess
plt.plot([0, 1], [0, 1], linestyle='--', label = 'Random guess' )
# plotting ROC Curve for skilled svm model
plt.plot(fpr_grid, tpr_grid, marker='.', label = 'ROC - AUC - Grid-Search SVC: %.3f' % grid_auc)
# good to put title and labels
plt.title('SVM results after Grid-Search on scaled features')
plt.ylabel('True Positive Rate')
plt.xlabel('False Positive Rate')
# putting the legends
plt.legend();

We have discussed many important concepts and ways to improve our model’s performance and make computation efficient. We may not be able ...