How to use the qminer.analytics.SVC function in qminer

To help you get started, we’ve selected a few qminer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
// create a new SVC object
	 var SVC = new analytics.SVC();
	 // create the matrix containing the input features and the input vector for each matrix column.
	 var matrix = new la.Matrix([[1, 0, -1, 0], [0, 1, 0, -1]]);	
	 var vec = new la.Vector([1, 0, -1, -2]);
	 // fit the model
	 SVC.fit(matrix, vec);
	 // create output stream
	 var fout = fs.openWrite('svc_example.bin');
	 // save SVC object (model and parameters) to output stream and close it
	 SVC.save(fout);
	 fout.close();
	 // create input stream
	 var fin = fs.openRead('svc_example.bin');
	 // create a SVC object that loads the model and parameters from input stream
	 var SVC2 = new analytics.SVC(fin);	
	
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 9", function () {

	 // import the analytics and la modules
	 var analytics = require('qminer').analytics;
	 var la = require('qminer').la;
	 // create a new SVC object
	 var SVC = new analytics.SVC();
	 // create the matrix containing the input features and the input vector for each matrix.
	 var matrix = new la.Matrix([[1, 0, -1, 0], [0, 1, 0, -1]]);
	 var vec = new la.Vector([1, 1, -1, -1]);
	 // fit the model
	 SVC.fit(matrix, vec); // creates a model, where the hyperplane has the normal semi-equal to [1, 1]
	
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 2", function () {

 // import modules
 var la = require('qminer').la;
 var analytics = require('qminer').analytics;
 // CLASSIFICATION WITH SVC
 // set up fake train and test data
 // four training examples with number of features = 2
 var featureMatrix = new la.Matrix({ rows: 2, cols: 4, random: true });
 // classification targets for four examples
 var targets = new la.Vector([-1, -1, 1, 1]);
 // set up the classification model
 var SVC = new analytics.SVC({ verbose: false });
 // train classifier
 SVC.fit(featureMatrix, targets);
 // set up a fake test vector
 var test = new la.Vector([1.1, -0.5]);
 // predict the target value
 var prediction = SVC.predict(test);

});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 77", function () {

     // import analytics module
     var analytics = require('qminer').analytics;
     // create a SVC model
     var SVC = new analytics.SVC();
     // get the properties of the model
     var model = SVC.getModel(); // returns { weight: new require('qminer').la.Vector(); }
	
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 3", function () {

	 // import analytics module
	 var analytics = require('qminer').analytics;
	 // create a new SVC model with json
	 var SVC = new analytics.SVC({ c: 5, j: 10, batchSize: 2000, maxIterations: 12000, maxTime: 2, minDiff: 1e-10, verbose: true });
	 // get the parameters of the SVC model
	 // returns { algorithm: 'SGD' c: 5, j: 10, batchSize: 2000, maxIterations: 12000, maxTime: 2, minDiff: 1e-10, verbose: true }
	 var json = SVC.getParams(); 
	
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 6", function () {

	 // import the analytics and la modules
	 var analytics = require('qminer').analytics;
	 var la = require('qminer').la;
	 var fs = require('qminer').fs;
	 // create a new SVC object
	 var SVC = new analytics.SVC();
	 // create the matrix containing the input features and the input vector for each matrix column.
	 var matrix = new la.Matrix([[1, 0, -1, 0], [0, 1, 0, -1]]);	
	 var vec = new la.Vector([1, 0, -1, -2]);
	 // fit the model
	 SVC.fit(matrix, vec);
	 // create output stream
	 var fout = fs.openWrite('svc_example.bin');
	 // save SVC object (model and parameters) to output stream and close it
	 SVC.save(fout);
	 fout.close();
	 // create input stream
	 var fin = fs.openRead('svc_example.bin');
	 // create a SVC object that loads the model and parameters from input stream
	 var SVC2 = new analytics.SVC(fin);	
	
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 4", function () {

	 // import analytics module
	 var analytics = require('qminer').analytics;
	 // create a default SVC model
	 var SVC = new analytics.SVC();
	 // change the parameters of the SVC with the json { j: 5, maxIterations: 12000, minDIff: 1e-10 }
	 SVC.setParams({ j: 5, maxIterations: 12000, minDiff: 1e-10 }); // returns self
	
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 7", function () {

	 // import the analytics and la modules
	 var analytics = require('qminer').analytics;
	 var la = require('qminer').la;
	 // create a new SVC object
	 var SVC = new analytics.SVC();
	 // create the matrix containing the input features and the input vector for each matrix
	 var matrix = new la.Matrix([[1, 0], [0, -1]]);
	 var vec = new la.Vector([1, -1]);
	 // fit the model
	 SVC.fit(matrix, vec);
	 // create the vector you want to get the distance from the model
	 var vec2 = new la.Vector([2, 3]);
	 // use the decisionFunction to get the distance of vec2 from the model
	 var distance = SVC.decisionFunction(vec2); // returns something close to 5
	
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 5", function () {
 
	 // import the analytics and la modules
	 var analytics = require('qminer').analytics;
	 var la = require('qminer').la;
	 // create a new SVC object
	 var SVC = new analytics.SVC();
	 // create the matrix containing the input features and the input vector for each matrix.
	 var matrix = new la.Matrix([[1, 0, -1, 0], [0, 1, 0, -1]]);
	 var vec = new la.Vector([1, 1, -1, -1]);
	 // fit the model
	 SVC.fit(matrix, vec);
	 // get the weights
	 var weights = SVC.weights; // returns the coefficients of the normal vector of the hyperplane gained from the model: [1, 1]
	
});
});
github qminer / qminer / test / nodejs / svm.js View on Github external
*/

console.log(__filename)
var assert = require('assert');
var analytics = require('qminer').analytics;
var la = require('qminer').la;
var fs = require('qminer').fs;

var vec = new la.Vector({vals:4});
var mat = new la.Matrix({rows:2, cols:4});

var vec = new la.Vector({vals:4});
var mat = new la.Matrix({rows:2, cols:4});
var x = new la.Vector({vals:2});

var SVC = new analytics.SVC({verbose:false});
SVC.fit(mat,vec);
SVC.save(fs.openWrite('svc.bin')).close();

var y1 = SVC.predict(x);

var SVR = new analytics.SVR({verbose:false});
SVR.fit(mat,vec);
SVR.save(fs.openWrite('svr.bin')).close();

var y1 = SVR.predict(x);