October 2018
Intermediate to advanced
172 pages
4h 6m
English
The curve, in this case, is the receiver operator characteristics (ROC) curve. This is a plot between the true positive rate and the false positive rate. We can plot this curve as follows:
from sklearn.metrics import roc_curvefrom sklearn.metrics import roc_auc_scoreimport matplotlib.pyplot as plt#Probabilities for each prediction output target_prob = knn_classifier.predict_proba(X_test)[:,1]#Plotting the ROC curve fpr, tpr, thresholds = roc_curve(y_test, target_prob)plt.plot([0,1], [0,1], 'k--')plt.plot(fpr, tpr)plt.xlabel('False Positive Rate')plt.ylabel('True Positive Rate')plt.title('ROC Curve')plt.show()
This produces the following curve:
In the preceding code, first, we create a set of probabilities ...
Read now
Unlock full access