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

Package detail

ml-regression-base

mljs524.6kMIT4.0.0TypeScript support: included

Base class for regression modules

readme

regression-base

NPM version build status Test coverage npm download

Base class for regression modules.
This package is for ml.js internal use.

Usage

You only have to implement the _predict method. It is always called with a number.

The model should be created in the constructor.

Optional methods that can be implemented: toString, toLaTeX.

import BaseRegression from 'ml-regression-base';

class MyRegression extends BaseRegression {
  constructor(factor) {
    super();
    this.factor = factor;
  }
  _predict(x) {
    return x * this.factor;
  }
  toString() {
    return `f(x) = x * ${this.factor}`;
  }
}

maybeToPrecision(value, digits)

Convenience method to transform numbers to readable strings.

If digits is not specified, "value.toString()" is used. Otherwise "value.toPrecision(digits)" is used.

This method can be used to implement toString() or toLaTeX().

checkArrayLength(x, y)

Convenience method to check if the input and output arrays passed to a regression constructor are effectively arrays with the same length.

License

MIT

changelog

Changelog

4.0.0 (2024-05-16)

⚠ BREAKING CHANGES

  • remove default export and update dependencies

Miscellaneous Chores

  • remove default export and update dependencies (83ee60f)

3.0.0 (2023-08-15)

⚠ BREAKING CHANGES

  • migrate to typescript (#15)

Code Refactoring

2.1.6 (2022-01-21)

Bug Fixes

2.1.5 (2021-11-16)

Bug Fixes

  • add type definitions to auxiliary functions (#9) (c041fd9)

2.1.4 (2021-10-12)

Bug Fixes

  • typings: add precision to toString and toLaTeX methods (#7) (8350ea7)

2.1.3 (2021-03-24)

Bug Fixes

  • allow full range of is-any-array-versions (d49cc93)

2.1.2 (2021-03-24)

2.1.1 (2020-02-04)

Bug Fixes

  • allows any array for predict and score (23bfb60)

2.1.0 (2020-02-04)

Features

2.0.1 (2019-04-30)

Bug Fixes

  • include TS definitions in npm package (21ca3e0)

2.0.0 (2019-04-30)

chore

  • remove support for Node.js 6 (d7031cd)

BREAKING CHANGES

  • Support for Node.js 6 was removed.

1.2.1 (2019-04-15)

1.2.0 (2017-04-28)

Features

  • add checkArrayLength method (3cc5515)

1.1.1 (2017-04-28)

1.1.0 (2017-04-28)

Features

1.0.0 (2017-04-28)

Features

  • implement BaseRegression (7920fce)