How to use the qminer.fs.openWrite 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 / exampleladoc_structures.js View on Github external
it("should make test number 53", function () {

	 // import the modules
	 var fs = require('qminer').fs;
	 var la = require('qminer').la;
	 // create a new sparse matrix
	 var mat = new la.SparseMatrix([[[0, 1]], [[0, 3], [1, 12]]]);
	 // open write stream
	 var fout = fs.openWrite('mat.dat');
	 // save matrix and close write stream
	 mat.save(fout).close();
	
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 31", function () {

	  // import modules
	  var analytics = require('qminer').analytics;
	  var la = require('qminer').la;
	  var fs = require('qminer').fs;
	  // create the Sigmoid model
	  var s = new analytics.Sigmoid();
	  // create the predicted values and the binary labels
	  var X = new la.Vector([-3, -2, -1, 1, 2, 3]);
	  var y = new la.Vector([-1, -1, -1, 1, 1, 1]);
	  // fit the model
	  s.fit(X, y);
	  // create an output stream object and save the model
	  var fout = fs.openWrite('sigmoid_example.bin');
	  s.save(fout);
	  fout.close();
	  // create a new Sigmoid model by loading the model
	  var fin = fs.openRead('sigmoid_example.bin');
	  var s2 = new analytics.Sigmoid(fin);
     
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 13", function () {

	 // import the modules
	 var analytics = require('qminer').analytics;
	 var la = require('qminer').la;
	 var fs = require('qminer').fs;
	 // create a new SVR object
	 var SVR = new analytics.SVR({ c: 10 });
	 // create a matrix and vector for the model
	 var matrix = new la.Matrix([[1, -1], [1, 1]]);
	 var vector = new la.Vector([1, 1]);
	 // create the model by fitting the values
	 SVR.fit(matrix, vector);
	 // save the model in a binary file
	 var fout = fs.openWrite('svr_example.bin');
	 SVR.save(fout);
	 fout.close();
	 // construct a SVR model by loading from the binary file
	 var fin = fs.openRead('svr_example.bin');
	 var SVR2 = new analytics.SVR()
	
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 35", function () {

	  // import modules
	  var analytics = require('qminer').analytics;
	  var la = require('qminer').la;
	  var fs = require('qminer').fs;
	  // create a new NearestNeighborAD object
	  var neighbor = new analytics.NearestNeighborAD();
	  // create a new sparse matrix
	  var matrix = new la.SparseMatrix([[[0, 1], [1, 2]], [[0, -2], [1, 3]], [[0, 0], [1, 1]]]);
	  // fit the model with the matrix
	  neighbor.fit(matrix);
	  // create an output stream object and save the model
	  var fout = fs.openWrite('neighbor_example.bin');
	  neighbor.save(fout);
	  fout.close();
	  // create a new Nearest Neighbor Anomaly model by loading the model
	  var fin = fs.openRead('neighbor_example.bin');
	  var neighbor2 = new analytics.NearestNeighborAD(fin);
     
});
});
github qminer / qminer / test / nodejs / exampleladoc.js View on Github external
it("should make test number 96", function () {

	 // import fs module
	 var fs = require('qminer').fs;
	 var la = require('qminer').la;
	 // create a new vector
	 var vec = new la.IntVector([1, 2, 3]);
	 // open write stream
	 var fout = fs.openWrite('vec.dat');
	 // save matrix and close write stream
	 vec.saveascii(fout).close();
	
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 48", function () {

	 // import modules
	 var analytics = require('qminer').analytics;
	 var la = require('qminer').la;
	 var fs = require('qminer').fs;
	 // create the Recursive Linear Regression model
	 var linreg = new analytics.RecLinReg({ dim: 2.0, recFact: 1e-10 });
	 // create a new dense matrix and target vector
	 var mat = new la.Matrix([[1, 2], [1, -1]]);
	 var vec = new la.Vector([3, 3]);
	 // fit the model with the matrix
	 linreg.fit(mat, vec);
	 // create an output stream object and save the model
	 var fout = fs.openWrite('linreg_example.bin');
	 linreg.save(fout);
	 fout.close();
	 // create a new Nearest Neighbor Anomaly model by loading the model
	 var fin = fs.openRead('linreg_example.bin');
	 var linreg2 = new analytics.RecLinReg(fin);
	
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 75", function () {

	 // import modules
	 var analytics = require('qminer').analytics;
	 var fs = require('qminer').fs;
	 // create a MDS instance
	 var mds = new analytics.MDS({ iter: 200, MaxStep: 10 });
	 // create the file output stream
	 var fout = new fs.openWrite('MDS.bin');
	 // save the MDS instance
	 mds.save(fout);
	 fout.close();
	 // load the MDS instance
	 var fin = fs.openRead('MDS.bin');
	 var mds2 = new analytics.MDS(fin);
	
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
// import modules
	  var analytics = require('qminer').analytics;
	  var la = require('qminer').la;
	  var fs = require('qminer').fs;
	  // create the Proportional Hazards model
	  var hazards = new analytics.PropHazards();
	  // create the input matrix and vector for fitting the model
	  var mat = new la.Matrix([[1, 0, -1, 0], [0, 1, 0, -1]]);
	  var vec = new la.Vector([1, 0, -1, -2]);
	  // if openblas used, fit the model
	  if (require('qminer').flags.blas) {
	      hazards.fit(mat, vec);
	  };
	  // create an output stream and save the model
	  var fout = fs.openWrite('hazards_example.bin');
	  hazards.save(fout);
	  fout.close();
	  // create input stream
	  var fin = fs.openRead('hazards_example.bin');
	  // create a Proportional Hazards object that loads the model and parameters from input stream
	  var hazards2 = new analytics.PropHazards(fin);	
	 
});
});
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);
github qminer / qminer / test / nodejs / svm.js View on Github external
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);