January 2020
Beginner to intermediate
432 pages
11h 24m
English
The ROC curve loses its credibility when it comes to evaluating the performance of the model when we are dealing with class imbalance. That is why, in such cases, we should use another curve—the Precision-Recall curve. That is because, for calculating both precision and recall, we do not use the true negatives, and only consider the correct prediction of the minority class (the positive one).
Calculate precision and recall for different thresholds:
y_pred_prob = tree_classifier.predict_proba(X_test_ohe)[:, 1]precision, recall, thresholds = metrics.precision_recall_curve(y_test, y_pred_prob)
Having calculated the required elements, we can plot the curve:
ax = plt.subplot()ax.plot(recall, precision, label=f'PR-AUC = {metrics.auc(recall, ...Read now
Unlock full access