knn icon indicating copy to clipboard operation
knn copied to clipboard

Uncaught TypeError: Cannot read property 'nearest' of undefined at O.getSinglePrediction (knn.js:91)

Open freezeyang opened this issue 7 years ago • 4 comments

when i use web version, it pops me this error. Uncaught TypeError: Cannot read property 'nearest' of undefined at O.getSinglePrediction (knn.js:91)

freezeyang avatar Feb 02 '18 22:02 freezeyang

it seems that's a dependency problem, can you show me how did you get that error, it works well on node?

JeffersonH44 avatar Feb 02 '18 22:02 JeffersonH44

cool. seems a version problem. will check it.

thx

freezeyang avatar Feb 02 '18 23:02 freezeyang

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...

freezeyang avatar Feb 02 '18 23:02 freezeyang

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.

netoolii avatar May 15 '18 14:05 netoolii