Skip to content

PLS Predict Scaling and Y-Values. Scaling always applied to Y-Values. #39

@DavidMartinOnGitHub

Description

@DavidMartinOnGitHub

The predict function of the PLS Class optionally scales the X values but always reverse scaling on the Y-Values. Shouldn't the Y scaling be embedded within an if(this.scale) block?

Code as-is:

predict(dataset) {
    let X = Matrix.checkMatrix(dataset);
    if (this.scale) {
      X = X.subRowVector(this.meanX).divRowVector(this.stdDevX);
    }
    let Y = X.mmul(this.PBQ);
    Y = Y.mulRowVector(this.stdDevY).addRowVector(this.meanY);
    return Y;
  }

Proposed fix:

predict(dataset) {
    let X = Matrix.checkMatrix(dataset);
    if (this.scale) {
      X = X.subRowVector(this.meanX).divRowVector(this.stdDevX);
    }
    let Y = X.mmul(this.PBQ);
    if (this.scale) {
       Y = Y.mulRowVector(this.stdDevY).addRowVector(this.meanY);
    }
    return Y;
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions