How to use the qminer.fs.openRead 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
var analytics = require('qminer').analytics;
	  var la = require('qminer').la;
	  var fs = require('qminer').fs;
	  // create a new Ridge Regression object
	  var regmod = new analytics.RidgeReg();
	  // create the test matrix and vector
	  var X = new la.Matrix([[1, 2], [1, -1]]);
	  var y = new la.Vector([3, 3]);
	  // fit the model with X and y
	  regmod.fit(X, y);
	  // create an output stream object and save the model
	  var fout = fs.openWrite('regmod_example.bin');
	  regmod.save(fout);
	  fout.close();
	  // create a new Ridge Regression model by loading the model
	  var fin = fs.openRead('regmod_example.bin');
	  var regmod2 = new analytics.RidgeReg(fin);
     
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
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
var analytics = require('qminer').analytics;
	 var la = require('qminer').la;
	 var fs = require('qminer').fs;
	 // create a Neural Networks model
	 var nnet = new analytics.NNet({ layout: [2, 3, 4] });
	 // create the matrices for the fitting of the model
	 var matIn = new la.Matrix([[1, 0], [0, 1]]);
	 var matOut = new la.Matrix([[1, 1], [1, 2], [-1, 8], [-3, -3]]);
	 // fit the model
	 nnet.fit(matIn, matOut);
	 // create an output stream object and save the model
	 var fout = fs.openWrite('nnet_example.bin');
	 nnet.save(fout);
	 fout.close();
	 // load the Neural Network model from the binary
	 var fin = fs.openRead('nnet_example.bin');
	 var nnet2 = new analytics.NNet(fin);
	
});
});
github qminer / qminer / test / nodejs / exampleladoc.js View on Github external
it("should make test number 97", function () {

	 // import fs module
	 var fs = require('qminer').fs;
	 var la = require('qminer').la;
	 // create an empty vector
	 var vec = new la.IntVector();
	 // open a read stream
	 var fin = fs.openRead('vec.dat');
	 // load the matrix
	 vec.loadascii(fin);
	
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
var fs = require('qminer').fs;
	  // create the logistic regression model
	  var logreg = new analytics.LogReg();
	  // 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 is used, fit the model
	  if (require('qminer').flags.blas) {
	      logreg.fit(mat, vec);
	  };
	  // create an output stream object and save the model
	  var fout = fs.openWrite('logreg_example.bin');
	  logreg.save(fout);
	  fout.close();
	  // create input stream
	  var fin = fs.openRead('logreg_example.bin');
	  // create a Logistic Regression object that loads the model and parameters from input stream
	  var logreg2 = new analytics.LogReg(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
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 / examplefsdoc.js View on Github external
it("should make test number 1", function () {

 // import module
 var fs = require('qminer').fs;
 // open file in write mode
 var fout = fs.openWrite('file.txt');
 // write sync and close
 fout.writeLine('example text');
 fout.close();
 // open file in read mode
 var fin = fs.openRead('file.txt');
 // read a line
 var str = fin.readLine();

});
});
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 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 / examplehtdoc.js View on Github external
var h = new ht.IntFltMap();
	 // Adding two key/dat pairs
	 h.put(5, 10.5);
	 h.put(15, 20.2);
	 // Getting data
	 h.hasKey(5); // returns true
	 h.get(15); // returns 20.2
	 h.key(1); // returns 15
	 h.dat(1); // returns 20.2
	 h.length; // returns 2	
	 // Saving and loading:
	 var fs = require('qminer').fs;
	 fout = fs.openWrite('map.dat'); // open write stream
	 h.save(fout).close(); // save and close write stream
	 var h2 = new ht.IntFltMap(); // new empty table
	 var fin = fs.openRead('map.dat'); // open read stream
	 h2.load(fin); // load
	
});
});