Package com.jml.linear_models
Class PolynomialRegressionSGD
java.lang.Object
com.jml.core.Model<double[],double[]>
com.jml.linear_models.PolynomialRegression
com.jml.linear_models.PolynomialRegressionSGD
Model for least squares regression of polynomials using 
PolynomialRegression fits a model y = b0 + b1x + b2x2 + ... + bnxn 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 using Stochastic Gradient Descent.
Stochastic Gradient Descent.PolynomialRegression fits a model y = b0 + b1x + b2x2 + ... + bnxn 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 using Stochastic Gradient Descent.
- 
Constructor SummaryConstructorsConstructorDescriptionCreates aPolynomialRegressionSGDmodel.PolynomialRegressionSGD(int degree)Creates aPolynomialRegressionSGDmodel.PolynomialRegressionSGD(int degree, double learningRate)Creates aPolynomialRegressionSGDmodel.PolynomialRegressionSGD(int degree, double learningRate, int maxIterations)Creates aPolynomialRegressionSGDmodel.PolynomialRegressionSGD(int degree, double learningRate, int maxIterations, double threshold)Creates aPolynomialRegressionSGDmodel.
- 
Method SummaryModifier and TypeMethodDescriptionfit(double[] features, double[] targets)Fits or trains the model with the given features and targets.double[]Gets the loss history from training.
- 
Constructor Details- 
PolynomialRegressionSGDpublic PolynomialRegressionSGD()Creates aPolynomialRegressionSGDmodel. This will use a default learning rate of 0.002.
- 
PolynomialRegressionSGDpublic PolynomialRegressionSGD(int degree, double learningRate, int maxIterations, double threshold)Creates aPolynomialRegressionSGDmodel. When thefitmethod is called,Stochastic Gradient Descentwill use the provided learning rate and will stop if it does not converge within the threshold by the specified number of max iterations.- Parameters:
- degree- Degree of the polynomial to fit.
- learningRate- Learning rate to use during- Stochastic Gradient Descent
- threshold- Threshold for early stopping during- Stochastic Gradient Descent. If the loss is less than the specified threshold, gradient descent will stop early.
- maxIterations- Maximum number of iterations to run for during- Stochastic Gradient Descent.
 
- 
PolynomialRegressionSGDpublic PolynomialRegressionSGD(int degree, double learningRate, int maxIterations)Creates aPolynomialRegressionSGDmodel. When thefitmethod is called,Stochastic Gradient Descentwill use the provided learning rate and will stop if it does not converge by the specified number of max iterations.- Parameters:
- degree- Degree of the polynomial to fit.
- learningRate- Learning rate to use during- Stochastic Gradient Descent.
- maxIterations- Maximum number of iterations to run for during- Stochastic Gradient Descent.
 
- 
PolynomialRegressionSGDpublic PolynomialRegressionSGD(int degree, double learningRate)Creates aPolynomialRegressionSGDmodel. When thefitmethod is called,Stochastic Gradient Descentwill use the provided learning rate and will stop if it does not converge by the specified number of max iterations.- Parameters:
- degree- Degree of the polynomial to fit.
- learningRate- Learning rate to use during- Stochastic Gradient Descent.
 
- 
PolynomialRegressionSGDpublic PolynomialRegressionSGD(int degree)Creates aPolynomialRegressionSGDmodel. When thefitmethod is called,Stochastic Gradient Descentwill fit a polynomial of the specified degree using gradient descent.- Parameters:
- degree- Degree of the polynomial to fit.
 
 
- 
- 
Method Details- 
fitFits or trains the model with the given features and targets.- Overrides:
- fitin class- PolynomialRegression
- Parameters:
- features- The features of the training set.
- targets- The targets of the training set.
- Returns:
- Returns details of the fitting / training process.
- Throws:
- IllegalArgumentException- Can be thrown for the following reasons
 - If key, value pairs in- argsare unspecified or invalid arguments.
 - If the features and targets are not correctly sized per the specification when the model was compiled.
 
- 
getLossHistpublic double[] getLossHist()Gets the loss history from training.- Returns:
- The loss of every iteration stored in a List.
 
 
-