Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Matrix } from 'ml-matrix';
import { KernelRidgeRegression } from '..';
var nSamples = 10;
var nVars = 2;
var Xs = Matrix.random(nSamples, nVars);
Xs.sub(0.5);
var Ys = Matrix.zeros(nSamples, 1);
for (var i = 0; i < nSamples; i++) {
Ys.set(
i,
0,
Xs.get(i, 0) * Xs.get(i, 0) +
2 * Xs.get(i, 0) * Xs.get(i, 1) +
Xs.get(i, 1) * Xs.get(i, 1)
);
}
describe('Kernel ridge regression', function () {
it('constant outputs', function () {
var model = new KernelRidgeRegression([[0, 0], [1, 1]], [[0], [0]]);
expect(model.predict([[1, 1], [2, 5], [4, 7]])).toStrictEqual([