Skip to content

Commit

Permalink
feat: add throw if insufficient number of points
Browse files Browse the repository at this point in the history
  • Loading branch information
EscapedGibbon committed May 10, 2024
1 parent c919fa2 commit d85a924
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/PolynomialRegression2D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ function train(input: DataXY, y: NumberArray | Matrix, order: number) {

const examples = x.rows;
const nbCoefficients = ((order + 2) * (order + 1)) / 2;

if (examples < nbCoefficients) {
throw new TypeError(
'Insufficient number of points to create regression model.',
);
}
const x1 = x.getColumnVector(0);
const x2 = x.getColumnVector(1);

Expand Down

0 comments on commit d85a924

Please sign in to comment.