Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ml-regression

mljs111kMIT6.2.0

Regression algorithms

regression, data, mining, datamining, machine, learning

readme

ml-regression

NPM version build status npm download

Regression algorithms.

Installation

$ npm install ml-regression

Examples

Simple linear regression

const SLR = require("ml-regression").SLR;
let inputs = [80, 60, 10, 20, 30];
let outputs = [20, 40, 30, 50, 60];

let regression = new SLR(inputs, outputs);
regression.toString(3) === "f(x) = - 0.265 * x + 50.6";

Check this cool blog post for a detailed example: https://hackernoon.com/machine-learning-with-javascript-part-1-9b97f3ed4fe5

Polynomial regression

const PolynomialRegression = require("ml-regression").PolynomialRegression;
const x = [50, 50, 50, 70, 70, 70, 80, 80, 80, 90, 90, 90, 100, 100, 100];
const y = [
  3.3, 2.8, 2.9, 2.3, 2.6, 2.1, 2.5, 2.9, 2.4, 3.0, 3.1, 2.8, 3.3, 3.5, 3.0,
];
const degree = 5; // setup the maximum degree of the polynomial
const regression = new PolynomialRegression(x, y, degree);
console.log(regression.predict(80)); // Apply the model to some x value. Prints 2.6.
console.log(regression.coefficients); // Prints the coefficients in increasing order of power (from 0 to degree).
console.log(regression.toString(3)); // Prints a human-readable version of the function.
console.log(regression.toLaTeX());

License

MIT

changelog

5.0.0 (2019-06-29)

chore

  • update dependencies and remove support for Node.js 6 (e1296b1)

BREAKING CHANGES

  • Node.js 6 is no longer supported

6.2.0 (2024-10-17)

Features

Bug Fixes

  • update robust-polynomial to avoid multiple import of regression-base (6a8853d)

6.1.0 (2024-05-03)

Features

  • throw if polynomial regression 2d can not be done because not enough points (5784863)

Bug Fixes

6.0.0 (2024-05-03)

⚠ BREAKING CHANGES

  • throw error if insufficient number of points

Features

  • throw error if insufficient number of points (00eb422)

4.4.2 (2017-07-21)

4.4.1 (2017-06-29)

4.4.0 (2017-06-28)

Bug Fixes

Features

  • add MultivariateLinearRegression (152478f)

4.3.0 (2017-06-22)

Features

  • add RobustPolynomialRegression (dffb44c)

4.2.1 (2017-04-25)

4.2.0 (2016-10-21)

4.1.1 (2016-09-21)

Bug Fixes

4.1.0 (2016-09-21)

Features

  • theil-sen-regression: add Theil-Sen regression and his test (69517b2)

4.0.1 (2016-08-16)

Features

1.1.1 / 2015-11-21

  • fix(KRR): prediction function is now working

1.1.0 / 2015-11-19

  • Add Kernel Ridge Regression
  • SLR: add toString method
  • SLR: add computeX method

1.0.0 / 2015-09-07

  • first release