How to use the qminer.la.Vector 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.js View on Github external
it("should make test number 34", function () {

	 // import la module
	 var la = require('qminer').la;
	 // create two vectors, one sparse and one dense
	 var sparse = new la.SparseVector([[0, 1], [3, 2], [4, -5]]);
	 var dense = new la.Vector([3, -4, 2, 0.5, -1]);
	 // get the inner product of the vectors
	 sparse.inner(dense); // returns the value 9
	
});
});
github qminer / qminer / test / nodejs / exampleladoc.js View on Github external
it("should make test number 79", function () {

	 // import fs module
	 var fs = require('qminer').fs;
	 var la = require('qminer').la;
	 // create an empty vector
	 var vec = new la.Vector();
	 // 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
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 / exampleladoc.js View on Github external
it("should make test number 26", function () {

	 // import la module
	 var la = require('qminer').la;
	 // create a matrix
	 var mat = new la.Matrix([[1, -3, 2], [9, 2, -4],  [-2, 3, 3]]);
	 // create a vector
	 var vec = new la.Vector([-3, 2, 2]);
	 // set the first row of the matrix with the vector
	 // the changed matrix is now
	 // -3    2    2
	 //  9    2   -4
	 // -2    3    3
	 mat.setRow(0, vec);
	
});
});
github qminer / qminer / test / nodejs / exampleladoc_structures.js View on Github external
it("should make test number 26", function () {

	 // import la module
	 var la = require('qminer').la;
	 // create a matrix
	 var mat = new la.Matrix([[1, -3, 2], [9, 2, -4],  [-2, 3, 3]]);
	 // create a vector
	 var vec = new la.Vector([-3, 2, 2]);
	 // set the first row of the matrix with the vector
	 // the changed matrix is now
	 // -3    2    2
	 //  9    2   -4
	 // -2    3    3
	 mat.setRow(0, vec);
	
});
});
github qminer / qminer / test / nodejs / exampleladoc.js View on Github external
it("should make test number 74", function () {

	 var la = require('qminer').la;
	 // create two vectors
	 var x = new la.Vector([1, 0]);
	 var y = new la.Vector([0, 1]);
	 // calculate the cosine between those two vectors
	 var num = x.cosine(y); // returns 0
	
});
});
github qminer / qminer / test / nodejs / exampleladoc.js View on Github external
it("should make test number 72", function () {

	 var la = require('qminer').la;
	 // create a new vector
	 var vec = new la.Vector([1, 2, 3]);
	 // trunc all elements with index 1 or more
	 vec.trunc(1); // returns vector [1]
	
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 14", function () {

	  // import the modules
	  var analytics = require('qminer').analytics;
	  var la = require('qminer').la;
	  // 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);
	  // get the distance between the model and the given vector
	  var vec2 = new la.Vector([-5, 1]);
	  var distance = SVR.decisionFunction(vec2);
     
});
});
github qminer / qminer / test / nodejs / exampleladoc_structures.js View on Github external
it("should make test number 8", function () {

	 // import la module
	 var la = require('qminer').la;
	 // create a new matrix
	 var mat = new la.Matrix([[1, 2], [-1, 5]]);
	 // create a new vector
	 var vec = new la.Vector([1, -1]);
	 //multiply mat and vec
	 var vec2 = mat.multiplyT(vec); // returns vector [2, -3]
	
});
});
github qminer / qminer / test / nodejs / sigmoid.js View on Github external
it('should return the prediction of the vector of values', function () {
            var s = new analytics.Sigmoid();
            var X = new la.Vector([-3, -2, -1, 1, 2, 3]);
            var y = new la.Vector([-1, -1, -1, 1, 1, 1]);
            s.fit(X, y);
            var test = new la.Vector([-3, 0, 3]);
            var prediction = s.predict(test);
            assert(prediction[0] < 0.10);
            assert.eqtol(prediction[1], 0.5);
            assert(prediction[2] > 0.90);
        })
    });