Class LinearRegression

java.lang.Object
com.jml.core.Model<double[],​double[]>
com.jml.linear_models.PolynomialRegression
com.jml.linear_models.LinearRegression
Direct Known Subclasses:
LinearRegressionSGD

public class LinearRegression extends PolynomialRegression
Model for ordinary least squares linear regression of one variable.

LinearRegression fits a model y = b0 + b1x to the datasets by minimizing the residuals of the sum of squares between the values in the target dataset and the values predicted by the model. This is solved explicitly.
  • Constructor Details

    • LinearRegression

      public LinearRegression()
  • Method Details

    • fit

      public LinearRegression fit(double[] features, double[] targets)
      Fits or trains the model with the given features and targets.
      Overrides:
      fit in class PolynomialRegression
      Parameters:
      features - The features of the training set.
      targets - The targets of the training set.
      Returns:
      A 2D array containing the following on a row:
      - The coefficients of the line from lowest to highest degree.
      Throws:
      IllegalArgumentException - Thrown if the features and targets are not correctly sized per the specification when the model was compiled.
    • inspect

      public String inspect()
      Forms a string of the important aspects of the model.
      same as toString()
      Overrides:
      inspect in class PolynomialRegression
      Returns:
      Details of model as string.
    • toString

      public String toString()
      Forms a string of the important aspects of the model.
      Overrides:
      toString in class PolynomialRegression
      Returns:
      String representation of model.