public class PolynomialRegression extends BaseRegression
f(x,y,z) = a + b * x + c * x2 + d * y + e * y2 + ...
Usage: <order>
Modifier and Type | Field and Description |
---|---|
protected double[] |
coefficients
Coefficients of each term in the polynomial
|
protected int |
order
Desired order of polynomial
|
AttributeSelector, trained, TrainingStats, validated, ValidationStats
Constructor and Description |
---|
PolynomialRegression() |
Modifier and Type | Method and Description |
---|---|
PolynomialRegression |
clone() |
static double[][] |
expandAttributes(double[][] attributes,
int order)
Expand attribute array in order to allow it to be used to fit a polynomial
model.
|
static double[] |
fitPolynomialModel(double[][] attributes,
int order,
double[] classVariable)
Fit a polynomial model based on a matrix of attribute values.
|
double[] |
getCoefficients()
Get coefficients of model.
|
int |
getNFittingParameters()
Number of fitting parameters in a model.
|
protected java.lang.String |
printModel_protected()
Internal method that handles printing the model as a string.
|
java.util.List<java.lang.String> |
printModelDescriptionDetails(boolean htmlFormat)
Print details of the model.
|
java.lang.String |
printUsage()
Print out required format for options.
|
void |
run_protected(Dataset TrainData)
Run a model without checking if stuff is trained (use carefully)
|
static double[] |
runPolynomialModel(double[][] attributes,
int order,
double[] coefficients)
Run a polynomial model based on a matrix of attribute values.
|
void |
setOptions(java.util.List Options)
Set any options for this object.
|
void |
setOrder(int order)
Define order of polynomial.
|
protected void |
train_protected(Dataset TrainData)
Train a model without evaluating performance
|
doRobustRegression, getRobustRegressionQ, robustTraining, runCommand, setRobustRegressionQ
about, crossValidate, externallyValidate, getAttributeSelector, getCitations, getFilter, getTrainTime, getValidationMethod, handleSetCommand, isTrained, isValidated, loadState, printCommand, printDescription, printModel, resetModel, run, saveCommand, saveState, setAttributeSelector, setComponent, setFilter, train, train
protected int order
protected double[] coefficients
public void setOptions(java.util.List Options) throws java.lang.Exception
Options
Options
- Array of options as Objects - can be null
java.lang.Exception
- if problem with inputspublic PolynomialRegression clone()
clone
in class BaseRegression
public java.lang.String printUsage()
Options
public void setOrder(int order)
order
- Desired order of polynomial.public double[] getCoefficients()
protected void train_protected(Dataset TrainData)
BaseModel
train_protected
in class BaseModel
TrainData
- Training datapublic void run_protected(Dataset TrainData)
BaseModel
run_protected
in class BaseModel
TrainData
- Training datapublic int getNFittingParameters()
AbstractRegressionModel
public static double[] fitPolynomialModel(double[][] attributes, int order, double[] classVariable)
Intercept, Coefficient of attribute1, Coefficient of attribute12, ..., Coefficient of attribute2, ...
attributes
- Matrix containing attributes for each entry (entries are rows, attributes columns)order
- Desired order of polynomialclassVariable
- Class variable for each entrypublic static double[][] expandAttributes(double[][] attributes, int order)
attributes
- Matrix containing attributes for each entry (entries are rows, attributes columns)order
- Desired order of polynomialpublic static double[] runPolynomialModel(double[][] attributes, int order, double[] coefficients)
Intercept, Coefficient of attribute1, Coefficient of attribute12, ..., Coefficient of attribute2, ...
attributes
- Matrix containing attributes for each entry (entries are rows, attributes columns)order
- Desired order of polynomialcoefficients
- Coefficients of polynomial modelprotected java.lang.String printModel_protected()
BaseModel
printModel_protected
in class BaseModel
public java.util.List<java.lang.String> printModelDescriptionDetails(boolean htmlFormat)
BaseModel
BaseModel.printDescription(boolean)
.
Implementation note: No not add indentation for details. That is handled
by BaseModel.printDescription(boolean)
. You should also call the super
operation to get the Normalizer and Attribute selector settings
printModelDescriptionDetails
in class BaseModel
htmlFormat
- Whether to use HTML format