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-learnfrom sklearn.metrics import roc_curve, roc_auc_score# Area Under the ROC Curvegrid_auc = roc_auc_score(y_test, grid.predict_proba(X_test)[:,1])# setting the figure sizeplt.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 guessplt.plot([0, 1], [0, 1], linestyle='--', label = 'Random guess' )# plotting ROC Curve for skilled svm modelplt.plot(fpr_grid, tpr_grid, marker='.', label = 'ROC - AUC - Grid-Search SVC: %.3f' % grid_auc)# good to put title and labelsplt.title('SVM results after Grid-Search on scaled features')plt.ylabel('True Positive Rate')plt.xlabel('False Positive Rate')# putting the legendsplt.legend();
We have discussed many important concepts and ways to improve our model’s performance and make computation efficient. We may not be able ...