este es mi codigo
Código
'use strict'; var so = require('stringify-object'); var svm = require('../lib'); var xor = [ [[0, 0], 0], [[0, 1], 1], [[1, 0], 1], [[1, 1], 0] ]; // initialize predictor var clf = new svm.CSVC({ kFold: 1 }); clf.train(xor) .progress(function(progress){ console.log('training progress: %d%', Math.round(progress*100)); }) .spread(function (model, report) { console.log('training report: %s\nPredictions:', so(report)); xor.forEach(function(ex){ var prediction = clf.predictSync(ex[0]); console.log(' %d XOR %d => %d', ex[0][0], ex[0][1], prediction); }); });
como enviar la variable prediccion?
lo modifique asi
Código
'use strict'; var so = require('stringify-object'); var svm = require('../lib'); var xor = [ [[0, 0], 0], [[0, 1], 1], [[1, 0], 1], [[1, 1], 0] ]; var prediction; // initialize predictor var clf = new svm.CSVC({ kFold: 1 }); clf.train(xor) .progress(function(progress){ console.log('training progress: %d%', Math.round(progress*100)); }) .spread(function (model, report) { console.log('training report: %s\nPredictions:', so(report)); xor.forEach(function(ex){ prediction = clf.predictSync(ex[0]); console.log(' %d XOR %d => %d', ex[0][0], ex[0][1], prediction); prediction="prediciendo desde cbba"; return { prediction:1 }; }); }); exports.prediction =prediction;
pero no logro mostrar en el app.js, la variable llega undefined
Código:
var ror = require('./node_modules/node-svm/examples/evaluation-example');console.log(ror.prediction);
ayuda porfavor