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

	 var la = require('qminer').la;
	 // create a new vector
	 var vec = new la.IntVector([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 41", function () {

	 // import modules
	 var analytics = require('qminer').analytics;
	 var la = require('qminer').la;
	 // create a new NearestNeighborAD object
	 var neighbor = new analytics.NearestNeighborAD({rate:0.05, windowSize:3});
	 // 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 and provide a vector record IDs
	 neighbor.fit(matrix, new la.IntVector([3541,1112,4244]));
	 // create a new sparse vector
	 var vector = new la.SparseVector([[0, 4], [1, 0]]);
	 // check if the vector is an anomaly
	 var explanation = neighbor.explain(vector); // returns an explanation
	
});
});
github qminer / qminer / test / nodejs / exampleladoc.js View on Github external
it("should make test number 95", 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 vector
	 vec.load(fin);
	
});
});
github qminer / qminer / test / nodejs / exampleladoc.js View on Github external
it("should make test number 91", function () {

	 var la = require('qminer').la;
	 // create a new vector
	 var vec = new la.IntVector([-2, 1, 3]);
	 // sort ascending
	 vec.sort(); // sorts to: [-2, 1, 3]
	 // sort using callback
	 vec.sort(function(arg1, arg2) { return Math.abs(arg1) - Math.abs(arg2); }); // sorts to: [1, -2, 3]
	
});
});
github qminer / qminer / test / nodejs / exampleladoc.js View on Github external
it("should make test number 90", function () {

	 var la = require('qminer').la;
	 // create a new vector
	 var vec = new la.IntVector([1, 2, 3]);
	 // splice the vector by removing the last two elements and adding 4, 5
	 vec.splice(1, 2, 4, 5)// returns vector [1, 4, 5]
	
});
});
github qminer / qminer / test / nodejs / exampleladoc.js View on Github external
it("should make test number 93", function () {

	 var la = require('qminer').la;
	 // create a new vector
	 var vec = new la.IntVector([1, 2, 3]);
	 // create vector as string
	 vec.toString(); // returns '1, 2, 3'
	
});
});
github qminer / qminer / test / nodejs / exampleladoc.js View on Github external
it("should make test number 94", 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 vector and close write stream
	 vec.save(fout).close();
	
});
});
github qminer / qminer / test / nodejs / nearestNeighborAD.js View on Github external
it('should explain differences for the given vector', function () {
            var neighbor = new analytics.NearestNeighborAD({ windowSize: 3 });
            var matrix = new la.SparseMatrix([[[0, 1], [1, 2]], [[0, -2], [1, 3]], [[0, 0], [1, 1]]]);
            var idVec = new la.IntVector([1, 2, 3]);
            neighbor.fit(matrix, idVec);

            var vector = new la.SparseVector([[1, 4]]);
            var explain = neighbor.explain(vector);
            assert.equal(explain.nearestDat, 1);
            assert.equal(explain.distance, 5);
            assert.equal(explain.features[0].id, 0);
            assert.equal(explain.features[0].val, 0);
            assert.equal(explain.features[0].nearVal, 1);
            assert.equal(explain.features[0].contribution, 0.2);
            assert.equal(explain.features[1].id, 1);
            assert.equal(explain.features[1].val, 4);
            assert.equal(explain.features[1].nearVal, 2);
            assert.equal(explain.features[1].contribution, 0.8);
        })
    });
github qminer / qminer / test / nodejs / preprocessing.js View on Github external
it('should return the binarized vector, la.IntVector', function () {
            var vec = new la.IntVector([0, 1, 1, 0, 2]);
            var bin = analytics.preprocessing.binarize(vec, 1);
            assert.equal(bin[0], -1);
            assert.equal(bin[1], 1);
            assert.equal(bin[2], 1);
            assert.equal(bin[3], -1);
            assert.equal(bin[4], -1);
        })
        it('should return the binarized vector, la.StrVector', function () {