How to use the ml-matrix.Matrix.isMatrix function in ml-matrix

To help you get started, we’ve selected a few ml-matrix examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mljs / regression / src / regression / poly-fit-regression2d.js View on Github external
train(X, y) {
    if (!Matrix.isMatrix(X)) X = new Matrix(X);
    if (!Matrix.isMatrix(y)) y = Matrix.columnVector(y);

    if (y.rows !== X.rows) {
      y = y.transpose();
    }

    if (X.columns !== 2) {
      throw new RangeError(
        `You give X with ${X.columns} columns and it must be 2`
      );
    }
    if (X.rows !== y.rows) {
      throw new RangeError('X and y must have the same rows');
    }

    var examples = X.rows;
    var coefficients = ((this.order + 2) * (this.order + 1)) / 2;
github mljs / regression / src / regression / poly-fit-regression2d.js View on Github external
train(X, y) {
    if (!Matrix.isMatrix(X)) X = new Matrix(X);
    if (!Matrix.isMatrix(y)) y = Matrix.columnVector(y);

    if (y.rows !== X.rows) {
      y = y.transpose();
    }

    if (X.columns !== 2) {
      throw new RangeError(
        `You give X with ${X.columns} columns and it must be 2`
      );
    }
    if (X.rows !== y.rows) {
      throw new RangeError('X and y must have the same rows');
    }

    var examples = X.rows;