Class MultipleLinearRegressionSGD

java.lang.Object
com.jml.core.Model<double[][],​double[]>
com.jml.linear_models.MultipleLinearRegression
com.jml.linear_models.MultipleLinearRegressionSGD

public class MultipleLinearRegressionSGD extends MultipleLinearRegression
Model for least squares linear regression of multiple variables by stochastic gradient descent.

MultipleLinearRegressionSGD fits a model y = b0 + b1x1 + ... + bnxn to the datasets by minimizing the residuals of the sum of squares (i.e. the sum of square errors) between the values in the target dataset and the values predicted by the model. This is minimized using stochastic gradient descent.
  • Constructor Details

  • Method Details

    • fit

      public MultipleLinearRegressionSGD fit(double[][] features, double[] targets)
      Fits or trains the model with the given features and targets. For both the features and targets parameters, if they are 2D arrays, then the number of rows in each must match and will be the number of samples in the data. The number of columns in each will be the number of features and targets in a single sample.

      For instance, if the features array has shape n-by-m and the targets array has shape n-by-k. Then there are n samples in the dataset, each individual sample has m features, and each individual sample has k targets.
      Overrides:
      fit in class MultipleLinearRegression
      Parameters:
      features - The features of the training set.
      targets - The targets of the training set.
      Returns:
      This. i.e. the trained model.
    • getLossHist

      public double[] getLossHist()
      Gets the loss history from the optimizer.
      Returns:
      Returns the loss for each iteration of the optimization algorithm in an array. The index of the array corresponds to the iteration the loss was computed for.