From 229d88eded32419e30b679af2112415cddb4f8d8 Mon Sep 17 00:00:00 2001 From: Roman Feldbauer Date: Thu, 5 Nov 2015 15:51:22 +0100 Subject: [PATCH] fixed tie handling --- knn_classification.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/knn_classification.m b/knn_classification.m index 123a0ae..5e248d4 100644 --- a/knn_classification.m +++ b/knn_classification.m @@ -52,11 +52,11 @@ % "tie": use nearest neighbor if (length(id) > 1) - if (seed_class == nn_class) + if (seed_class == nn_class(1)) acc(j) = acc(j) + 1/n; corr(i,j) = 1; end - cmat(seed_class, nn_class) = cmat(seed_class, nn_class) + 1; + cmat(seed_class, nn_class(1)) = cmat(seed_class, nn_class(1)) + 1; % majority vote else