knn
knn copied to clipboard
Uncaught TypeError: Cannot read property 'nearest' of undefined at O.getSinglePrediction (knn.js:91)
when i use web version, it pops me this error. Uncaught TypeError: Cannot read property 'nearest' of undefined at O.getSinglePrediction (knn.js:91)
it seems that's a dependency problem, can you show me how did you get that error, it works well on node?
cool. seems a version problem. will check it.
thx
I have changed to the current version which is 2.2.0. It pops me another error when I used the example listed in the readme document.
script.js:61 Uncaught TypeError: ML.SL.KNN is not a constructor at HTMLInputElement.train (script.js:61)
the same program works well in the previous version...
I've solved this issue like that @freezeyang :
var dataset = [[0, 0, 0], [0, 1, 1], [1, 1, 0], [2, 2, 2], [1, 2, 2], [2, 1, 2]];
var predictions = [0, 0, 0, 1, 1, 1];
var knn = new ML.KNN.default(dataset, predictions);
knn.predict(dataset)
and works fine.