10 Commits

Author SHA1 Message Date
Pitchaya Boonsarngsuk
dd32d7b38c Add pivot hitrate console logs 2018-02-09 11:32:51 +00:00
Pitchaya Boonsarngsuk
a240f12b73 Merge branch 'master' into withConsoleLog 2018-02-09 09:30:16 +00:00
Pitchaya Boonsarngsuk
076e28d48f Merge branch 'master' into withConsoleLog 2018-02-06 13:40:34 +00:00
Pitchaya Boonsarngsuk
fad925d85a Update readme for the new API 2018-02-06 13:40:25 +00:00
Pitchaya Boonsarngsuk
e37d731f49 Update Readme for the new API (reverted from commit 23c173fd14) 2018-02-06 13:40:05 +00:00
Pitchaya Boonsarngsuk
23c173fd14 Update Readme for the new API 2018-02-06 13:37:37 +00:00
Pitchaya Boonsarngsuk
0ccbc345db Merge branch 'master' into withConsoleLog 2018-02-06 13:33:12 +00:00
Pitchaya Boonsarngsuk
35de97d6ba Link add logging 2018-02-06 13:20:04 +00:00
Pitchaya Boonsarngsuk
cdc97f8c81 Merge branch 'master' into withConsoleLog 2018-02-06 13:19:50 +00:00
Pitchaya Boonsarngsuk
34b666a668 Merge branch 'master' into withConsoleLog 2018-02-06 13:11:28 +00:00
2 changed files with 41 additions and 0 deletions

View File

@@ -30,6 +30,7 @@ export default function(sampleSet, remainderSet, numPivots, distanceFn, endingIt
let sets = takeSampleFrom(sampleSet, numPivots); let sets = takeSampleFrom(sampleSet, numPivots);
let pivots = sets.sample; let pivots = sets.sample;
let nonPivotSamples = sets.remainder; let nonPivotSamples = sets.remainder;
let correct = 0, wrong = 0, percentsOff = [];
let pivotsBuckets = []; // [ For each Pivot:[For each bucket:[each point in bucket]] ] let pivotsBuckets = []; // [ For each Pivot:[For each bucket:[each point in bucket]] ]
for (let i = 0; i < numPivots; i++) { for (let i = 0; i < numPivots; i++) {
@@ -130,6 +131,45 @@ export default function(sampleSet, remainderSet, numPivots, distanceFn, endingIt
if (sampleSubsetDistanceCache[k] === undefined) if (sampleSubsetDistanceCache[k] === undefined)
sampleSubsetDistanceCache[k] = distanceFn(node, sampleSubset[k]); sampleSubsetDistanceCache[k] = distanceFn(node, sampleSubset[k]);
} }
let nearestSample, nearestMinDist, sample, dist;
for (let j = sampleSet.length-1; j>=0; j--) {
sample = sampleSet[j];
dist = distanceFn(node, sample);
if (nearestSample === undefined || dist < nearestMinDist) {
nearestMinDist = dist;
nearestSample = sample;
}
}
if(minDist-nearestMinDist == 0) correct++;
else {
wrong++;
if(nearestMinDist!=0)percentsOff.push(minDist/nearestMinDist)
}
placeNearToNearestNeighbour(node, nearSample, minDist, sampleSubset, sampleSubsetDistanceCache, endingIts); placeNearToNearestNeighbour(node, nearSample, minDist, sampleSubset, sampleSubsetDistanceCache, endingIts);
} }
console.log("Correct", correct);
console.log("Wrong", wrong);
console.log("Correct percent", 100*correct/(correct+wrong));
StandardDeviation(percentsOff)
}
function StandardDeviation(numbersArr) {
//--CALCULATE AVAREGE--
var total = 0;
for(var key in numbersArr)
total += numbersArr[key];
var meanVal = total / numbersArr.length;
console.log("Average percent off", meanVal);
//--CALCULATE AVAREGE--
//--CALCULATE STANDARD DEVIATION--
var SDprep = 0;
for(var key in numbersArr)
SDprep += Math.pow((parseFloat(numbersArr[key]) - meanVal),2);
var SDresult = Math.sqrt(SDprep/numbersArr.length);
//--CALCULATE STANDARD DEVIATION--
console.log("SD percent off", SDresult);
} }

View File

@@ -60,6 +60,7 @@ export default function() {
if(velocityDiff<stableVelocity){ if(velocityDiff<stableVelocity){
stableVeloHandler(); stableVeloHandler();
} }
else console.log(velocityDiff);
} }
} }