How to use the qminer.analytics 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
it("should make test number 110", function () {

         // import analytics module
         var analytics = require('qminer').analytics;
         // create a new KMeans object
         var KMeans = new analytics.KMeans({ iter: 1000, k: 3 });
         // create a matrix to be fitted
         var X = new la.Matrix([[1, -2, -1], [1, 1, -3]]);
         // create the model with the matrix X
         KMeans.fit(X);
        
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 46", function () {

	 // import analytics module
	 var analytics = require('qminer').analytics;
	 // create a new Recursive Linear Regression model
	 var linreg = new analytics.RecLinReg({ dim: 10 });
	 // set the parameters of the model
	 linreg.setParams({ dim: 3, recFact: 1e2, forgetFact: 0.5 });
	
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 72", function () {

	 // import analytics module
	 var analytics = require('qminer').analytics;
	 // create a MDS instance
	 var mds = new analytics.MDS();
	 // get the (default) parameters of the instance
	 // returns { maxStep: 5000, maxSecs: 300, minDiff: 1e-4, distType: "Euclid" }
	 var params = mds.getParams();
	
});
});
github qminer / qminer / test / nodejs / metrics.js View on Github external
/**
 * Copyright (c) 2015, Jozef Stefan Institute, Quintelligence d.o.o. and contributors
 * All rights reserved.
 * 
 * This source code is licensed under the FreeBSD license found in the
 * LICENSE file in the root directory of this source tree.
 */

var assert = require('../../src/nodejs/scripts/assert.js');
var qm = require('qminer');
var analytics = qm.analytics;

describe('Classification Metrics Tests', function () {

    describe('Constructor Tests', function () {
        it('should not throw an exception', function () {
            assert.doesNotThrow(function () {
                // ClassificationScore constructor tests
                new analytics.metrics.ClassificationScore();
                new analytics.metrics.ClassificationScore([1, 0], [0, 1]);
                new analytics.metrics.ClassificationScore(new qm.la.Vector([1, 0]), new qm.la.Vector([0, 1]));
                // PredictionCurve constructor tests
                new analytics.metrics.PredictionCurve();
                new analytics.metrics.PredictionCurve([1, 0], [0, 1]);
                new analytics.metrics.PredictionCurve(new qm.la.Vector([1, 0]), new qm.la.Vector([0, 1]));
            });
        });
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 91", function () {

     // import metrics module
     var metrics = require('qminer').analytics.metrics;
    
     // true and predicted lables
     var true_lables = [0, 1, 0, 0, 1];
     var pred_prob = [0.3, 0.5, 0.2, 0.5, 0.8];
    
     // create predictionCurve instance
     var predictionCurve = new metrics.PredictionCurve();
    
     // simulate data flow
     for (var i in true_lables) {
        // push new value
        predictionCurve.push(true_lables[i], pred_prob[i]);
    }
    
     var roc = predictionCurve.roc(); // get ROC
     var auc = predictionCurve.auc(); // get AUC
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 27", function () {

	 // import analytics module
	 var analytics = require('qminer').analytics;
	 // create the Sigmoid model
	 var s = new analytics.Sigmoid();
	 // get the model parameters
	 // returns a Json object { A: 0, B: 0 }
	 var model = s.getModel();
	
});
});
github qminer / qminer / test / nodejs / onevsall.js View on Github external
///////////////////////////////////////////////////////////
// One vs All Unit Tests

var assert = require('../../src/nodejs/scripts/assert.js');
var analytics = require('qminer').analytics;
var la = require('qminer').la;

describe('OneVsAll Tests', function () {
    
    describe('Constructor Tests', function () {
        it('should not throw an exception', function () {
            var json = { c: 10, maxTime: 12000 };
            assert.doesNotThrow(function () {
                var onevsall = new analytics.OneVsAll({ model: analytics.SVC, modelParam: json, cats: 10 });
            });
        })
        it('should throw an exception if there are missing crucial parameters', function () {
            assert.throws(function () {
                var onevsall = new analytics.OneVsAll();
            });
        })
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 51", function () {

	 // import analytics module
	 var analytics = require('qminer').analytics;
	 // create a logistic regression model
	 var logreg = new analytics.LogReg({ lambda: 10 });
	 // set the parameters of the model
	 logreg.setParams({ lambda: 1 });
	
});
});
github qminer / qminer / test / nodejs / exampleanalyticsdoc.js View on Github external
it("should make test number 63", function () {

	 // import modules
	 var analytics = require('qminer').analytics;
	 var la = require('qminer').la;
	 // 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);
	
});
});
github qminer / qminer / test / nodejs / regression.js View on Github external
/**
 * Copyright (c) 2015, Jozef Stefan Institute, Quintelligence d.o.o. and contributors
 * All rights reserved.
 *
 * This source code is licensed under the FreeBSD license found in the
 * LICENSE file in the root directory of this source tree.
 */

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

console.log("Regression", "Starting test based on a random sample");

var dims = 10; // dimensions
var examples = 500; // examples

var X = la.randn(dims, examples);
var w = la.randn(dims);
var y = X.multiplyT(w);

// gaussian noise
var noiseSigma = 0.1;
var Ng = la.randn(dims, examples).multiply(noiseSigma);
var Xg = X.plus(Ng);
var yg = Xg.multiplyT(w);