Package com.jml.linear_models
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
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.
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionfit(double[] features, double[] targets)
Fits or trains the model with the given features and targets.inspect()
Forms a string of the important aspects of the model.
same astoString()
toString()
Forms a string of the important aspects of the model.Methods inherited from class com.jml.linear_models.PolynomialRegression
getParams, predict, predict, saveModel
-
Constructor Details
-
LinearRegression
public LinearRegression()
-
-
Method Details
-
fit
Fits or trains the model with the given features and targets.- Overrides:
fit
in classPolynomialRegression
- 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
Forms a string of the important aspects of the model.
same astoString()
- Overrides:
inspect
in classPolynomialRegression
- Returns:
- Details of model as string.
-
toString
Forms a string of the important aspects of the model.- Overrides:
toString
in classPolynomialRegression
- Returns:
- String representation of model.
-