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.
Diagonal lines occur in ROC curves when you have ties, that is when you have one or more observation with the exact same test value in both the positive and negative groups.
SVM classifiers output continuous probabilities. The chance to get a tie is normally very low. This is why you get a "steppy" curve.
On the other hand, due to the limited number of observations that make a k-NN decision, the output probabilities are typically not continuous. For instance if you considered a k-NN classifier with k = 3, probabilities can only be 1.0, 0.67, 0.33, 0. It is very likely that you observe these values in both groups, hence the tie and the diagonal line.