Example #1
0
 it('should serialize and deserialize', function () {
     var matrix = new la.Matrix([[1, -1], [0, 0]]);
     var vec = new la.Vector([1, -1]);
     var SVR = new analytics.SVR({ algorithm: "LIBSVM" });
     SVR.fit(matrix, vec);
     SVR.save(require('qminer').fs.openWrite('svc_test.bin')).close();
     var SVR2 = new analytics.SVR(require('qminer').fs.openRead('svc_test.bin'));
     assert.deepEqual(SVR.getParams(), SVR2.getParams());
     assert.eqtol(SVR.weights.minus(SVR2.weights).norm(), 0, 1e-8);
 })
Example #2
0
 it("should return the parameters of the default SVR model as Json, without some key values", function () {
     var SVR = new analytics.SVR({ c: 3, eps: 2, maxTime: 1 });
     var SVRjSon = SVR.getParams();
     assert.equal(SVRjSon.c, 3);
     assert.equal(SVRjSon.eps, 2);
     assert.equal(SVRjSon.batchSize, 1000);
     assert.equal(SVRjSon.maxIterations, 10000);
     assert.equal(SVRjSon.maxTime, 1);
     assert.eqtol(SVRjSon.minDiff, 1e-6);
     assert.equal(SVRjSon.verbose, false);
 })
Example #3
0
 it("It should return a SVR created by Json, with added key values", function () {
     var SVR = new analytics.SVR({ alpha: 5, beta: 10, s: 3, batchSize: 10000, verbose: true });
     var SVRjSon = SVR.getParams();
     assert.equal(SVRjSon.c, 1);
     assert.equal(SVRjSon.eps, 1e-1);
     assert.equal(SVRjSon.batchSize, 10000);
     assert.equal(SVRjSon.maxIterations, 10000);
     assert.equal(SVRjSon.maxTime, 1);
     assert.eqtol(SVRjSon.minDiff, 1e-6);
     assert.equal(SVRjSon.verbose, true);
 });
Example #4
0
 it("should return the parameters of the default SVR model as Json", function () {
     var SVR = new analytics.SVR();
     var SVRjSon = SVR.getParams();
     assert.equal(SVRjSon.c, 1);
     assert.equal(SVRjSon.eps, 1e-1);
     assert.equal(SVRjSon.batchSize, 1000);
     assert.equal(SVRjSon.maxIterations, 10000);
     assert.equal(SVRjSon.maxTime, 1);
     assert.eqtol(SVRjSon.minDiff, 1e-6);
     assert.equal(SVRjSon.verbose, false);
 })
Example #5
0
 it("It should return a SVR created by an empty Json", function () {
     var SVR = new analytics.SVR({});
     var SVRjSon = SVR.getParams();
     assert.equal(SVRjSon.c, 1);
     assert.equal(SVRjSon.eps, 1e-1);
     assert.equal(SVRjSon.batchSize, 1000);
     assert.equal(SVRjSon.maxIterations, 10000);
     assert.equal(SVRjSon.maxTime, 1);
     assert.eqtol(SVRjSon.minDiff, 1e-6);
     assert.equal(SVRjSon.verbose, false);
 });
Example #6
0
 it("It should return a SVR created by Json, not all key values are given", function () {
     var SVR = new analytics.SVR({ c: 5, batchSize: 5, maxTime: 1, verbose: true });
     var SVRjSon = SVR.getParams();
     assert.equal(SVRjSon.c, 5);
     assert.equal(SVRjSon.eps, 1e-1);
     assert.equal(SVRjSon.batchSize, 5);
     assert.equal(SVRjSon.maxIterations, 10000);
     assert.equal(SVRjSon.maxTime, 1);
     assert.eqtol(SVRjSon.minDiff, 1e-6);
     assert.equal(SVRjSon.verbose, true);
 });
Example #7
0
 it("It should return a SVR created by Json", function () {
     var SVR = new analytics.SVR({ c: 5, eps: 5, batchSize: 5, maxIterations: 5, maxTime: 1, minDiff: 1e-10, verbose: true });
     var SVRjSon = SVR.getParams();
     assert.equal(SVRjSon.c, 5);
     assert.equal(SVRjSon.eps, 5);
     assert.equal(SVRjSon.batchSize, 5);
     assert.equal(SVRjSon.maxIterations, 5);
     assert.equal(SVRjSon.maxTime, 1);
     assert.eqtol(SVRjSon.minDiff, 1e-10);
     assert.equal(SVRjSon.verbose, true);
 });
Example #8
0
 it("It should return a default constructor", function () {
     var SVR = new analytics.SVR();
     var SVRjSon = SVR.getParams();
     assert.equal(SVRjSon.c, 1);
     assert.equal(SVRjSon.eps, 1e-1);
     assert.equal(SVRjSon.batchSize, 1000);
     assert.equal(SVRjSon.maxIterations, 10000);
     assert.equal(SVRjSon.maxTime, 1);
     assert.eqtol(SVRjSon.minDiff, 1e-6);
     assert.equal(SVRjSon.verbose, false);
 });
Example #9
0
 it("should return the existing SVR with the changed, added values", function () {
     var SVR = new analytics.SVR();
     SVR.setParams({ eps: 3, maxTime: 2, alpha: 5, z: 10 });
     var SVRjSon = SVR.getParams();
     assert.equal(SVRjSon.c, 1);
     assert.equal(SVRjSon.eps, 3);
     assert.equal(SVRjSon.batchSize, 1000);
     assert.equal(SVRjSon.maxIterations, 10000);
     assert.equal(SVRjSon.maxTime, 2);
     assert.eqtol(SVRjSon.minDiff, 1e-6);
     assert.equal(SVRjSon.verbose, false);
 })
Example #10
0
 it("It should return a SVR created by Json, with added key values", function () {
     var SVR = new analytics.SVR({ algorithm: "LIBSVM", alpha: 5, beta: 10, s: 3, batchSize: 10000, verbose: true });
     var SVRjSon = SVR.getParams();
     assert.equal(SVRjSon.kernel, "LINEAR");
     assert.equal(SVRjSon.svmType, "default");
     assert.equal(SVRjSon.c, 1);
     assert.equal(SVRjSon.j, 1);
     assert.equal(SVRjSon.eps, 0.001);
     assert.equal(SVRjSon.gamma, 1);
     assert.equal(SVRjSon.p, 0.1);
     assert.equal(SVRjSon.degree, 1);
     assert.equal(SVRjSon.nu, 0.01);
     assert.equal(SVRjSon.coef0, 1);
     assert.equal(SVRjSon.cacheSize, 100);
     assert.equal(SVRjSon.verbose, true);
 });
Example #11
0
 it("It should return a SVR created by an empty Json", function () {
     var SVR = new analytics.SVR({ algorithm: "LIBSVM" });
     var SVRjSon = SVR.getParams();
     assert.equal(SVRjSon.kernel, "LINEAR");
     assert.equal(SVRjSon.svmType, "default");
     assert.equal(SVRjSon.c, 1);
     assert.equal(SVRjSon.j, 1);
     assert.equal(SVRjSon.eps, 0.001);
     assert.equal(SVRjSon.gamma, 1);
     assert.equal(SVRjSon.p, 0.1);
     assert.equal(SVRjSon.degree, 1);
     assert.equal(SVRjSon.nu, 0.01);
     assert.equal(SVRjSon.coef0, 1);
     assert.equal(SVRjSon.cacheSize, 100);
     assert.equal(SVRjSon.verbose, false);
 });
Example #12
0
 it("It should return a SVR created by Json, not all key values are given", function () {
     var SVR = new analytics.SVR({ algorithm: "LIBSVM", c: 5, batchSize: 5, maxTime: 1, verbose: true });
     var SVRjSon = SVR.getParams();
     assert.equal(SVRjSon.kernel, "LINEAR");
     assert.equal(SVRjSon.svmType, "default");
     assert.equal(SVRjSon.c, 5);
     assert.equal(SVRjSon.j, 1);
     assert.equal(SVRjSon.eps, 0.001);
     assert.equal(SVRjSon.gamma, 1);
     assert.equal(SVRjSon.p, 0.1);
     assert.equal(SVRjSon.degree, 1);
     assert.equal(SVRjSon.nu, 0.01);
     assert.equal(SVRjSon.coef0, 1);
     assert.equal(SVRjSon.cacheSize, 100);
     assert.equal(SVRjSon.verbose, true);
 });
Example #13
0
 it("should return the parameters of the default SVR model as Json, with added key values", function () {
     var SVR = new analytics.SVR({ algorithm: "LIBSVM", alpha: 3, beta: 3, z: 3 });
     var SVRjSon = SVR.getParams();
     assert.equal(SVRjSon.kernel, "LINEAR");
     assert.equal(SVRjSon.svmType, "default");
     assert.equal(SVRjSon.c, 1);
     assert.equal(SVRjSon.j, 1);
     assert.equal(SVRjSon.eps, 0.001);
     assert.equal(SVRjSon.gamma, 1);
     assert.equal(SVRjSon.p, 0.1);
     assert.equal(SVRjSon.degree, 1);
     assert.equal(SVRjSon.nu, 0.01);
     assert.equal(SVRjSon.coef0, 1);
     assert.equal(SVRjSon.cacheSize, 100);
     assert.equal(SVRjSon.verbose, false);
 })
Example #14
0
 it("should return the existing SVR with the changed, added values", function () {
     var SVR = new analytics.SVR({ algorithm: "LIBSVM" });
     SVR.setParams({ eps: 3, maxTime: 2, alpha: 5, z: 10 });
     var SVRjSon = SVR.getParams();
     assert.equal(SVRjSon.kernel, "LINEAR");
     assert.equal(SVRjSon.svmType, "default");
     assert.equal(SVRjSon.c, 1);
     assert.equal(SVRjSon.j, 1);
     assert.equal(SVRjSon.eps, 3);
     assert.equal(SVRjSon.gamma, 1);
     assert.equal(SVRjSon.p, 0.1);
     assert.equal(SVRjSon.degree, 1);
     assert.equal(SVRjSon.nu, 0.01);
     assert.equal(SVRjSon.coef0, 1);
     assert.equal(SVRjSon.cacheSize, 100);
     assert.equal(SVRjSon.verbose, false);
 })