包详细信息

ml-regression-polynomial

mljs368kMIT3.0.2

Polynomial Regression

自述文件

regression-polynomial

NPM version npm download build status Test coverage

Polynomial Regression.

Installation

$ npm i ml-regression-polynomial

Usage

import { PolynomialRegression } from 'ml-regression-polynomial';

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());
console.log(regression.score(x, y));

Options

An interceptAtZero option is available, to force $f(0) = 0$. Also, a "powers array" can be specified.

  • Using interceptAtZero
const regression = new PolynomialRegression(x, y, degree, {
  interceptAtZero: true,
});
  • Using the powers array
const powers = [0, 1, 2, 3, 4, 5];
const regression = new PolynomialRegression(x, y, powers);

powers could also be [1,2,3,4,5]or[1,3,5] and so on.

For intercepting at zero using an array, skip the zero in the array (the option interceptAtZero is ignored in this case.)

License

MIT

更新日志

Changelog

3.0.2 (2025-05-22)

Bug Fixes

  • remove dependency on cheminfo-types (#15) (eda138f)

3.0.1 (2024-05-16)

Bug Fixes

  • update dependencies. Force release for removal of default in base-regression (c3c00e3)

3.0.0 (2023-10-02)

⚠ BREAKING CHANGES

  • use named exports to ease transition to TypeScript
  • migrate to TypeScript (#8)

Features

  • allow users to pass interceptAtZero parameter (5f9aa0e)

Bug Fixes

  • determine the degree from max power, not power length (5f9aa0e)

Code Refactoring

  • migrate to TypeScript (#8) (5f9aa0e)
  • use named exports to ease transition to TypeScript (5f9aa0e)

2.2.0 (2021-06-10)

Features

2.1.0 (2020-02-04)

Features

2.0.0 (2019-06-29)

chore

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

BREAKING CHANGES

  • Node.js 6 is no longer supported.

1.0.3 (2017-07-21)

1.0.2 (2017-04-28)

1.0.1 (2017-04-28)

1.0.0 (2017-04-28)

Features

  • implement polynomial regression (ed6a198)