-
Notifications
You must be signed in to change notification settings - Fork 3
Move cheminfo-types to dev dependencies #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
import { type NumberArray } from 'cheminfo-types'; | ||
import { Matrix, MatrixTransposeView, solve } from 'ml-matrix'; | ||
import { | ||
BaseRegression, | ||
checkArrayLength, | ||
maybeToPrecision, | ||
} from 'ml-regression-base'; | ||
|
||
export type NumberArray = | ||
| number[] | ||
| Int8Array | ||
| Uint8Array | ||
| Uint8ClampedArray | ||
| Int16Array | ||
| Uint16Array | ||
| Int32Array | ||
| Uint32Array | ||
| Float32Array | ||
| Float64Array; | ||
|
||
interface PolynomialRegressionOptions { | ||
interceptAtZero?: boolean; | ||
} | ||
|
@@ -13,12 +24,12 @@ | |
degree: number; | ||
powers: number[]; | ||
coefficients: number[]; | ||
/** | ||
* @param x - independent or explanatory variable | ||
* @param y - dependent or response variable | ||
* @param degree - degree of the polynomial regression, or array of powers to be used. When degree is an array, intercept at zero is forced to false/ignored. | ||
* @example `new PolynomialRegression(x, y, 2)`, in this case, you can pass the option `interceptAtZero`, if you need it. | ||
* @param options | ||
Check warning on line 32 in src/index.ts
|
||
* @example `new PolynomialRegression(x, y, [1, 3, 5])` | ||
* Each of the degrees corresponds to a column, so if you have them switched, just do: | ||
* @example `new PolynomialRegression(x, y, [3, 1, 5])` | ||
|
@@ -122,14 +133,14 @@ | |
} | ||
} | ||
|
||
/** | ||
Check warning on line 136 in src/index.ts
|
||
* Perform a polynomial regression on the given data set. | ||
* This is an internal function. | ||
* @param x - independent or explanatory variable | ||
* @param y - dependent or response variable | ||
* @param degree - degree of the polynomial regression | ||
* @param options.interceptAtZero - force the polynomial regression so that $f(0) = 0$ | ||
Check warning on line 142 in src/index.ts
|
||
* @param options | ||
Check warning on line 143 in src/index.ts
|
||
*/ | ||
function regress( | ||
x: NumberArray, | ||
|
Uh oh!
There was an error while loading. Please reload this page.