New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unable to predict from load previous model #34
Comments
To restore an existing prediction model you should use Example: var svm = require('node-svm');
var persistedModel = JSON.parse(fs.readFileSync('./model/poker_sim_test.json'));
var clf = svm.restore(persistedModel); BR |
Thank you but I still face this... assert.js:89 Thanks!! |
my test code is here, train and predict in a js file. |
Try this instead: nodesvm.read(pathToTrainingData).then(function (dataset) {
var clf = new nodesvm.NU_SVC({
kFold: 4,
normalize: false,
reduce: false,
kernelType: 'RBF',
gamma: [0.03125, 0.125, 0.5, 2, 8]
});
clf.train(dataset).spread(function (model, report) {
fs.writeFileSync('./model/poker_sim_test.json', JSON.stringify(model));
}).then(function(){
var persistedModel = JSON.parse(fs.readFileSync('./model/poker_sim_test.json'));
var restoredClf = nodesvm.restore(persistedModel);
restoredClf.predictSync([4, 10, 4, 11, 4, 1, 4, 13, 4, 12]);
});
}); |
It seems to appear another error Assertion failed: (elt->IsNumber()), function setModel, file ../src/node-svm/node-svm.h, line 229. my dataset is like this: sorry for bothering |
it seems that this error comes from your dataset but I can't help you with that... |
Hello I can use the model from external file latter. I originally use this and it can generate a model but can't predict as above discussion. Latter I create a model file by 'node-svm train [train file] [model path]'. And I use the sane dataset and the same prediction code, then everything works. FYI thank you!!! |
Thank you for your feedback! |
Hello, I train a data set and store it into other folder. (in index.js)
After that, I create a file called predict.js, main code is like:
var persistedModel = JSON.parse(fs.readFileSync('./model/poker_sim_test.json'));
var clf = new svm.NuSVC({ model: persistedModel });
var prediction = clf.predict(guess);
when I run it I face a problem that:
assert.js:89
throw new assert.AssertionError({
^
AssertionError: false == true
at NuSVC.SVM.predict (/Users/ives/Downloads/SVM_PokerHand/node_modules/node-svm/lib/core/svm.js:147:5)
How can I fix problems.
Thanks!!
The text was updated successfully, but these errors were encountered: