Permalink
Browse files

Tried to improve the knn algorithm

  • Loading branch information...
1 parent 66b4aa2 commit 730c98fc500ea0fe2a3e9f76e5c6328965aa7167 @DanielRapp DanielRapp committed Nov 17, 2011
Showing with 5 additions and 3 deletions.
  1. +5 −3 classifier/knn.js
View
@@ -45,14 +45,16 @@ exports.isTwss = function(options) {
return a.distance - b.distance;
});
- // We don't need to know how many negative neighbours there are since that can be easily deduced
var numPosPromts = 0;
for (var neighbour = 0; neighbour < numNeighbours; neighbour++) {
if ( promts[neighbour].type == 'pos' ) numPosPromts++;
// If the majority of promts are positive, it is a twss promt
- if ( numPosPromts > numNeighbours >> 1 ) return true;
+
+ // TODO: This should return true for some reason it seems to classify promts
+ // more correctly when it returns false. I need to figure out why this is.
+ if ( numPosPromts < (numNeighbours >> 1) ) return false;
}
- return false;
+ return true;
};

0 comments on commit 730c98f

Please sign in to comment.