ml-regression-base
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

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

/ml-regression-base/

    Package Sidebar

    Install

    npm i ml-regression-base

    Weekly Downloads

    29,036

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    33.6 kB

    Total Files

    33

    Last publish

    Collaborators

    • stropitek
    • targos
    • lpatiny
    • mljs-bot
    • maasencioh
    • jeffersonh44
    • andcastillo