als-statistics
Version:
Modular JS statistics toolkit for Node.js and the browser: descriptive stats, correlations (Pearson/Spearman/Kendall), t-tests & ANOVA (Student/Welch), reliability (Cronbach’s alpha), regression (linear/logistic), clustering (DBSCAN/HDBSCAN), and table/co
18 lines (16 loc) • 814 B
JavaScript
import test from 'node:test';
import assert from 'node:assert/strict';
import Regression from '../../../lib/analyze/regression/index.js';
test('Regression: htmlTables (и внутренние RegressionBase.htmlTable) доступны', () => {
const r = new Regression(
{ y: [1,2,3,4,5], x1: [0,1,1,2,3] },
{ yName: 'y', xNames: ['x1'], type: 'linear' }
);
// добиваем шаг add next() чтобы прогнать .next и склейку htmlTables
r.next(['x1*x1']);
const html = r.htmlTables;
assert.equal(typeof html, 'string');
assert.ok(html.includes('Linear regression to predict y'));
// в результирующем HTML должны быть хотя бы два блока (за 2 шага)
assert.ok((html.match(/<hr>/g) || []).length >= 1);
});