UNPKG

707 BJavaScriptView Raw
1'use strict';
2
3var expect = require('chai').expect;
4var PolynomialKernel = require('./polynomial.js');
5
6describe('Kernel.PolynomialKernel', function () {
7 describe('.apply', function () {
8 it('should calculate the Polynomial kernel with gamma 1, no bias and of degree 2 when called with default parameters', function () {
9 expect(new PolynomialKernel().apply([1, 2], [3, 4])).to.closeTo(121, 1e-5);
10 });
11
12 it('should correctly calculate the Polynomial kernel with custom parameters', function () {
13 var kernel = new PolynomialKernel({
14 gamma: 3,
15 coef0: 2,
16 degree: 4
17 });
18 expect(kernel.apply([1, 2], [3, 4])).to.closeTo(1500625, 1e-5);
19 });
20 });
21});
\No newline at end of file