JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 118549
  • Score
    100M100P100Q188458F
  • License MIT

Simple Linear Regression

Package Exports

  • ml-regression-simple-linear

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ml-regression-simple-linear) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

regression-simple-linear

NPM version build status npm download

Simple Linear Regression.

Installation

$ npm install --save ml-regression-simple-linear

Usage

import SimpleLinearRegression from 'ml-regression-simple-linear';

const x = [0.5, 1, 1.5, 2, 2.5];
const y = [0, 1, 2, 3, 4];

const regression = new SimpleLinearRegression(x, y);

regression.slope // 2
regression.intercept // -1
regression.coefficients // [-1, 2]

regression.predict(3); // 5
regression.computeX(3.5); // 2.25

regression.toString(); // 'f(x) = 2 * x - 1'

regression.score(x, y);
// { r: 1, r2: 1, chi2: 0, rmsd: 0 }

const json = regression.toJSON();
// { name: 'simpleLinearRegression', slope: 2, intercept: -1 }
const loaded = SimpleLinearRegression.load(json);
loaded.predict(5) // 9

License

MIT