I post here because I don't know how to improve the performance of my binary KNN. The problem is that I have 99.8% Specificity and only 82% Sensitivity, but I'd rather have more Sensitivity than Specificity. I'm new to this field, and I've only been working on this for 1 month. In my study I've used an anomaly detector trained with only 1 class, and in that case, in order to raise the Sensitivity of the knn classifier I increased the value of the threshold... Now that I have to compare my anomaly detector with a 2 class classifier it seems that KNN works better in the first case... The geometric mean of Sensitivity and Specificity (√Se*Sp) is 0,95 in the one-class classifier, and only 0,91 in the two-classes because of the low Sensitivity. I expected the exact opposite... Can anyone help me?
Asked
Active
Viewed 601 times
0
-
Can you post a piece of code? I'm sure that'll help some people answering your question, even though your question is rather about the underlying basics of kNN and not really about the programming-part of it ;-) – tim Oct 12 '14 at 09:50
-
I reused the code created for the experiment with only one class, so it's not easy to understand because, for example, I don't use matlab's functions for the crossvalidation, but I divide manually the dataset into 10 subsets and then I test the classifier on each of these. The main function I used is fitcknn, with 1 neighbors and euclidean distance... Then, I used the predict function to test the classifier. My dataset has 51*3 colums with data red from an accelerometer on the 3 axis, and I pass those data to the classifier... So, the input of the knn classifier is a 153-dimensional vector – user4134164 Oct 12 '14 at 10:00
-
I assume you're only reporting figures for your positive class rather than both. One of the issues with KNN is that there isn't really a hyperparameter to play around with to adjust classification behaviour in the way you want. You could try altering *k*, but I wouldn't expect this to help... have you considered using something else? Logistic regression or an SVM would likely work well – Ben Allison Oct 13 '14 at 08:37
-
I tried to increase K but the results were about the same. I can't use SVM because I have to compare the differences between the two approaches with the knn... – user4134164 Oct 13 '14 at 18:02