# Shapes of ROC curves for different classifiers ('steppy' for SVM and smooth for k-NN)

When constructing the ROC curve for various classifiers I've noticed that their actual shapes tend to be very different for models such as logistic regression or SVM compared to k-NN. For instance, in the image below we see a ROC curve that corresponds to a k-NN classifier, and as it can be seen there are hardly any 'steps' or jumps, if any at all, hence being quite smooth. On the other hand, if we observe the ROC curve that I obtain for the SVM model the steps are definitely more abundant. I've tried this for various datasets, and steps or jumps always seem to be absent in the case of the ROC curve for k-NN in scikit-learn; I don't know if R does this as well. Does anybody know why the ROC curve for k-NN might adopt this specific shape, whereas the ones for SVM or LR involve noticeably more steps? Thanks a lot in advance.

• How are you creating these ROC curves? Really every ROC curve should look like your second example: it must make discrete jumps as new data points become classified as being members of the positive class. It really can't happen that an ROC curve is piecewise linear, as in the first example. Aug 28 '17 at 3:06
• @MatthewDrury Piecewise linearity can happen, depending on how you deal with ties.
– Sycorax
Aug 28 '17 at 3:52
• ....Thinking.... Aug 28 '17 at 3:58
• @MatthewDrury These ROC curves are being created on scikit-learn, and for the k-NN one $k=9$ and $p=1$. Conversely, for SVM $\gamma=0.1$ and $C=2^{-5}$. And it definitely can happen, as I said, I've verified this with multiple datasets. Also, if you have a look at this link that I found on the internet, they seem to obtain a similar ROC curve shape for k-NN as me: stat.washington.edu/courses/stat391/spring13/_images/…, Aug 28 '17 at 11:37

• That's an extremely helpful response, and it makes complete sense! My k-NN currently uses $k=9$ and $p=1$, that is, Manhattan distance, but I guess the principle that you have laid out applies to my model too. Furthermore, for my test set I only have 13 1s out of 88 outcomes, which is a very small fraction compared to the 0s. Therefore, this might be influence this as well. Do you know of any book or reference which seem to mention your explanation? Also, whenever a ROC curve has a lot of steps, this implies that a lot of thresholds can be fixed, right? Again, amazing explanation. Aug 28 '17 at 11:57