How to manually perform what PrecisionRecallDisplay library does

Hi guys;

I’m interested in knowing how to manually generate this precision-recall curve. I want to use the Plotly graphing library, not the matplotlib one.

As such, I’m trying to break these steps down and would appreciate some guidance in doing so, as all the libraries that I would have used to do this are deprecated in this version of scikit-learn.

My goal in doing this course was to replicate every graph shown, using the Plotly graphing library. I’ve gotten to this point in the course figuring things out on my own, but now I’ve hit a wall.

I’m more than willing to share all my notebooks for this course, as they show how to do these graphs both in matplotlib, as well as plotly.

The plotly library has helped me understand concepts like hyper parameters, and what hyper parameter tuning does, in addition to other features.

Thus, I’d really like to figure out how to do this graph, but all references online are either depreciated (They worked in the previous version of the course, but since then there’s a new version of scikit-learn), or all point to PrecisionRecallDisplay library.

Thank you!

You can probably check the source code of the display:

But in short, you need to call precision_recall_curve as there: scikit-learn/precision_recall_curve.py at baf828ca126bcb2c0ad813226963621cafe38adb · scikit-learn/scikit-learn · GitHub

Then use this information and plot it. So look at the plot method then: scikit-learn/precision_recall_curve.py at baf828ca126bcb2c0ad813226963621cafe38adb · scikit-learn/scikit-learn · GitHub

The important point for precision-recall curve is to not linear interpolate between the point that is the default. You can see in the implementation that we use the following option in matplotlib:

line_kwargs = {"drawstyle": "steps-post"}

Nice!

Thank you for this suggestion, it didn’t even cross my mind to look at source code.

I will look at this and break it down.

I appreciate you pointing me in the right direction.

Cheers.

–Igor