I'd expect that for a precision-recall curve, precision decreases while recall increases monotonically. I have a plot that is not smooth and looks funny. I used scikit learn the values for plotting the curve. Is the curve below abnormal? If yes, why and how can I correct it considering scikit learn automatically sorts the true and predicted labels. If the plot is OK, how best do I explain this behaviour?
-
$\begingroup$ It's normal: Are precision and recall supposed to be monotonic to classification threshold. Welcome to the site! $\endgroup$ – Emre Nov 21 '17 at 19:24
This is definitely possible. When you are reducing the threshold, you will never decrease the recall (you can only flag more of the positive examples as positive). Precision is looking at all the examples that you flag positively, and of those the fraction that are truly positive. This means when you are reducing the threshold, you might not add any true positives but only false positives, thereby lowering your precision. Let's take a look at a fabricated example, where P is positive and N is negative. The samples are ranked by score/probability. Everything before the threshold is flagged as positive:
PPNPNNPNNN
If we put the threshold between items 2 and 3, we get a precision of $1$ and a recall of $0.5$:
PP - NPNNPNNN
When we put it between items 3 and 4, we keep the same recall but our precision drops to $0.6667$:
PPN - PNNPNNN
-
$\begingroup$ Thank you! Does this also apply to PR curves that start from (0,0) ? $\endgroup$ – Anderlecht Nov 21 '17 at 22:56
-