I am calculating the Precision Recall score for 3 different models. For my first model, the plot does not match the auc score which is 0.85 but it should be 0.5.
Here is my code:
precision, recall, thresholds = precision_recall_curve(y_test, pred1)
print(pred1)
fig, ax = plt.subplots()
ax.plot(recall, precision, color='red')
ax.set_title('Precision-Recall curve')
ax.set_ylabel('Precision')
ax.set_xlabel('Recall')
plt.show()
auc_precision_recall = auc(recall, precision)
CodePudding user response:
Sorry I don't have enough rep to comment.
Notice your y-axis, it is between 0.7-1, so an AUC of 0.85 seems to match the plot. The AUC would be 0.5 if the y-axis ranges from 0-1.
You can set the y-axis to be between 0-1 with ax.set_ylim((0,1))