Issue
I am trying to plot Precision Recall curve using PrecisionRecallDisplay from scikit-learn.
I have model predicted values in y_pred
and actual values in y_true
. I can plot precision recall curve using the following syntax:
metrics.PrecisionRecallDisplay.from_predictions(y_true, y_pred)
But I want to plot multiple curves (say by applying model on training or validation data) in the same plot.
So is it possible to achieve this using PrecisionRecallDisplay
? Or Is there some other standard way to achieve this using scikit-learn?
Solution
Since sklearn display routines are basically just matplotlib wrappers, the easiest way seems to be utilizing the ax
argument, like this:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
PrecisionRecallDisplay.from_predictions(y_train, y_pred_train, ax=ax)
PrecisionRecallDisplay.from_predictions(y_test, y_pred, ax=ax)
plt.show()
Answered By - dx2-66
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.