Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should make test number 26", function () {
// import analytics module
var analytics = require('qminer').analytics;
// create the Sigmoid model
var s = new analytics.Sigmoid();
// set the parameters
// doesn't change the model
s.setParams({});
});
});
it("should make test number 28", function () {
// import modules
var analytics = require('qminer').analytics;
var la = require('qminer').la;
// create the Sigmoid model
var s = new analytics.Sigmoid();
// create the predicted values and the binary labels
var X = new la.Vector([-3, -2, -1, 1, 2, 3]);
var y = new la.Vector([-1, -1, -1, 1, 1, 1]);
// fit the model
// changes the internal A and B values of the model
// (these values can be obtained with the getModel method)
s.fit(X, y);
});
});
it("should make test number 31", function () {
// import modules
var analytics = require('qminer').analytics;
var la = require('qminer').la;
var fs = require('qminer').fs;
// create the Sigmoid model
var s = new analytics.Sigmoid();
// create the predicted values and the binary labels
var X = new la.Vector([-3, -2, -1, 1, 2, 3]);
var y = new la.Vector([-1, -1, -1, 1, 1, 1]);
// fit the model
s.fit(X, y);
// create an output stream object and save the model
var fout = fs.openWrite('sigmoid_example.bin');
s.save(fout);
fout.close();
// create a new Sigmoid model by loading the model
var fin = fs.openRead('sigmoid_example.bin');
var s2 = new analytics.Sigmoid(fin);
});
});
it("should make test number 29", function () {
// import modules
var analytics = require('qminer').analytics;
var la = require('qminer').la;
// create the Sigmoid model
var s = new analytics.Sigmoid();
// create the predicted values and the binary labels
var X = new la.Vector([-3, -2, -1, 1, 2, 3]);
var y = new la.Vector([-1, -1, -1, 1, 1, 1]);
// fit the model
s.fit(X, y);
// predict the probability of the value 0 on this model
// returns 0.5
var prediction = s.decisionFunction(0.5);
});
});
it("should make test number 30", function () {
// import modules
var analytics = require('qminer').analytics;
var la = require('qminer').la;
// create the Sigmoid model
var s = new analytics.Sigmoid();
// create the predicted values and the binary labels
var X = new la.Vector([-3, -2, -1, 1, 2, 3]);
var y = new la.Vector([-1, -1, -1, 1, 1, 1]);
// fit the model
s.fit(X, y);
// predict the probability of the value 0 on this model
// returns 0.5
var prediction = s.predict(0.5);
});
});
var la = require('qminer').la;
var fs = require('qminer').fs;
// create the Sigmoid model
var s = new analytics.Sigmoid();
// create the predicted values and the binary labels
var X = new la.Vector([-3, -2, -1, 1, 2, 3]);
var y = new la.Vector([-1, -1, -1, 1, 1, 1]);
// fit the model
s.fit(X, y);
// create an output stream object and save the model
var fout = fs.openWrite('sigmoid_example.bin');
s.save(fout);
fout.close();
// create a new Sigmoid model by loading the model
var fin = fs.openRead('sigmoid_example.bin');
var s2 = new analytics.Sigmoid(fin);
});
});
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.decisionFunction(test);
assert(prediction[0] < 0.10);
assert.eqtol(prediction[1], 0.5);
assert(prediction[2] > 0.90);
})
});
it('should return an empty json object', function () {
var s = new analytics.Sigmoid();
var params = s.getParams();
assert.deepEqual(params, {});
})
})
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);
})
});
it('should fit the model with the values, symmetric', 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 model = s.getModel();
assert(model.A > 0);
assert.equal(model.B, 0);
})
it('should fit the model with the values, not symmetric', function () {