Package Exports
- ml-regression-base
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-base) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ml-regression-base
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 * 2';
}
}
maybeToPrecision(value, digits)
This package also exports a 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()
.