I dislike the square look of this AUC curve (SKLearn).

The purpose of this question is "visual". Please post code snippets.

This question is not requesting the theory behind the AUC.

My goal is to make the curve look like a curve. Right now, the curve looks like a square.

Please refer to the sample code below.

precision, recall, _ = metrics.roc_curve(y_test, pos_probs)
plt.plot(precision , recall, marker='.')
RocCurveDisplay.from_predictions(y_test, pos_probs)

The code above produces the below ugly curves.

enter image description here

The curve appearance I want to achieve (red line only).

enter image description here

  • $\begingroup$ You could make up data until you get the curve you want. (That was a joke; don’t do that.) Aside from that, the curve looks how it looks. I’m not following the issue here. Could you please explain and clarify? $\endgroup$
    – Dave
    Feb 16, 2023 at 23:49
  • $\begingroup$ @Dave The red curve is what I want. The blue curve is what I am getting. $\endgroup$
    – Full Array
    Feb 16, 2023 at 23:51
  • $\begingroup$ You get what the data support. What’s the problem? $\endgroup$
    – Dave
    Feb 16, 2023 at 23:51
  • $\begingroup$ @Dave Correct. I understand that. Is there a method or are you aware of a method to make the AUC curve less square-ish? For example, adding additional plotting points without altering the final outcome. For example, when you do line charts/histograms in matplotlib, you can use a log method to "soften" (less square) the line appearance. $\endgroup$
    – Full Array
    Feb 16, 2023 at 23:55
  • 1
    $\begingroup$ More data Will give a less square result $\endgroup$ Feb 17, 2023 at 3:06

1 Answer 1


As Dave and Thiago are saying in the comments, the shape of the ROC curve depends on the data, especially the number of possible thresholds in the data.

(it's not called AUC curve btw, AUC stands for "Area Under Curve")

Here you can find an explanation about how the ROC curve is defined, which explains why it has a particular shape.

Your curve looks as if there are only 3 points, including the two extremes. You're right that this is not typical.

  • Imho the most likely is an error: check the values in pos_probs, because apparently they have only a few distinct values. Are these values obtained with predict or predict_proba? It should be the latter (common mistake, see here for instance).
  • Otherwise it's a matter of too few different points in the data: how many instances do you have? Are the instances diverse enough? If you only have a couple distinct instances, then this kind of curve would be normal. If so, making the curve artificially similar to the red line would be a mistake.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.