Package regress
Class Regression
java.lang.Object
regress.Regression
- All Implemented Interfaces:
Serializable
Class for multivariate polynomial regression models.
- Since:
- 2004.05.22
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRegression
(int dim, int deg) Create a multivariate polynomial regression model.Regression
(table.TableMapper map, int deg) Create a multivariate polynomial regression model.Regression
(table.Table atts, int deg) Create a multivariate polynomial regression model. -
Method Summary
Modifier and TypeMethodDescriptionvoid
aggregate
(double[] vec, double wgt) Aggregate a data vector.double
execute
(double[] vec) Execute a regression function.double[]
Get all regression coefficients.int[][]
Get the exponents of all regression terms.table.Table
Get the regression model as a table.table.Table
getAsTable
(boolean zeros) Get the regression model as a table.table.Table
getAsTable
(boolean zeros, double min) Get the regression model as a table.table.Table
getAsTable
(double min) Get the regression model as a table.double
getCoeff
(int i) Get a regression coefficient.int
Get the number of regression coefficients.int
Get the degree of the regression polynomial.table.Table
Get the domains of the variables.int[]
getExpos
(int i) Get the exponents of a regression term.double
getLim()
Get the limit for the Tikhonov regularization.table.TableMapper
Get the underlying table mapper.double
getMax()
Get the maximum for a logit transformation.double
getMin()
Get the minimum for a logit transformation.double
getReg()
Get the initial Tikhonov regularization.double
getSSE()
Compute the sum of squared errors.double
getSum()
Get the sum of the data vector weights.int
Get the number of variables (including the output).getVarName
(int id) Get the name of a variable.static double
logistic
(double x) Compute logistic function.static void
Main function for testing basic functionality.static Regression
parse
(util.Scanner scan) Parse a regression description.static Regression
parse
(util.Scanner scan, table.Table atts) Parse a regression description.void
setLim
(double lim) Set the limit for the Tikhonov regularization.void
setMax
(double max) Set the maximum for a logit transformation.void
setMin
(double min) Set the minimum for a logit transformation.void
setMinMax
(double min, double max) Set the range for a logit transformation.void
setReg
(double reg) Set the initial Tikhonov regularization.void
setRegLim
(double reg, double lim) Set initial value and limit for the Tikhonov regularization.void
solve()
Set up and solve the regression equation system.toString()
Describe the regression function.toString
(double min) Describe the regression function.Describe the regression function.
-
Constructor Details
-
Regression
Create a multivariate polynomial regression model.- Parameters:
atts
- the underlying variablesdeg
- the degree of the polynomial- Throws:
RegException
- if there are too many regression terms- Since:
- 2004.05.22 (Christian Borgelt)
-
Regression
Create a multivariate polynomial regression model.- Parameters:
map
- the underlying table mapperdeg
- the degree of the polynomial- Throws:
RegException
- if there are too many regression terms- Since:
- 2007.05.16 (Christian Borgelt)
-
Regression
Create a multivariate polynomial regression model.- Parameters:
dim
- the number of variables of the data (including the output variable)deg
- the degree of the polynomial- Throws:
RegException
- if there are too many regression terms- Since:
- 2004.05.22 (Christian Borgelt)
-
-
Method Details
-
logistic
public static double logistic(double x) Compute logistic function.- Parameters:
x
- the function argument- Returns:
- the logistic function value
- Since:
- 2015.08.12 (Christian Borgelt)
-
getDomains
public table.Table getDomains()Get the domains of the variables.Domains of the variables are available only if the regression model has been created from a table or a table mapper.
- Returns:
- the domains of the variables as a table
- Since:
- 2007.05.16 (Christian Borgelt)
-
getMapper
public table.TableMapper getMapper()Get the underlying table mapper.A table mapper is available only if the regression model has been created from a table or a table mapper.
- Returns:
- the underlying table mapper
- Since:
- 2007.05.16 (Christian Borgelt)
-
setMin
public void setMin(double min) Set the minimum for a logit transformation.- Parameters:
min
- the minimum for a logit transformation- Since:
- 2015.08.12 (Christian Borgelt)
-
getMin
public double getMin()Get the minimum for a logit transformation.- Returns:
- the minimum for a logit transformation
- Since:
- 2015.08.12 (Christian Borgelt)
-
setMax
public void setMax(double max) Set the maximum for a logit transformation.- Parameters:
max
- the maximum for a logit transformation- Since:
- 2007.04.12 (Christian Borgelt)
-
getMax
public double getMax()Get the maximum for a logit transformation.- Returns:
- the maximum for a logit transformation
- Since:
- 2007.04.12 (Christian Borgelt)
-
setMinMax
public void setMinMax(double min, double max) Set the range for a logit transformation.- Parameters:
min
- the minimum for a logit transformationmax
- the maximum for a logit transformation- Since:
- 2015.08.12 (Christian Borgelt)
-
setReg
public void setReg(double reg) Set the initial Tikhonov regularization.- Parameters:
reg
- the initial regularization value- Since:
- 2015.08.12 (Christian Borgelt)
-
getReg
public double getReg()Get the initial Tikhonov regularization.- Returns:
- the initial regularization value
- Since:
- 2015.08.12 (Christian Borgelt)
-
setLim
public void setLim(double lim) Set the limit for the Tikhonov regularization.- Parameters:
lim
- the limit for the regularization value- Since:
- 2015.08.12 (Christian Borgelt)
-
getLim
public double getLim()Get the limit for the Tikhonov regularization.- Returns:
- the limit for the regularization value
- Since:
- 2015.08.12 (Christian Borgelt)
-
setRegLim
public void setRegLim(double reg, double lim) Set initial value and limit for the Tikhonov regularization.- Parameters:
reg
- the initial regularization valuelim
- the limit for the regularization value- Since:
- 2015.08.12 (Christian Borgelt)
-
getDegree
public int getDegree()Get the degree of the regression polynomial.- Returns:
- the degree of the regression polynomial
- Since:
- 2004.05.22 (Christian Borgelt)
-
getVarCount
public int getVarCount()Get the number of variables (including the output).- Returns:
- the number of variables
- Since:
- 2004.05.22 (Christian Borgelt)
-
getVarName
Get the name of a variable.- Parameters:
id
- the index of the variable- Returns:
- the name of the i-th variable
- Since:
- 2004.05.22 (Christian Borgelt)
-
getCoeffCount
public int getCoeffCount()Get the number of regression coefficients.- Returns:
- the number of regression coefficients
- Since:
- 2004.05.22 (Christian Borgelt)
-
getCoeff
public double getCoeff(int i) Get a regression coefficient.- Parameters:
i
- the index of the regression coefficient- Returns:
- the i-th regression coefficient
- Since:
- 2004.05.22 (Christian Borgelt)
-
getAllCoeffs
public double[] getAllCoeffs()Get all regression coefficients.- Returns:
- the regression coefficients
- Since:
- 2004.05.22 (Christian Borgelt)
-
getExpos
public int[] getExpos(int i) Get the exponents of a regression term.- Parameters:
i
- the index of the regression term- Returns:
- the exponents of the i-th regression term
- Since:
- 2007.04.13 (Christian Borgelt)
-
getAllExpos
public int[][] getAllExpos()Get the exponents of all regression terms.- Returns:
- the exponents of all regression terms
- Since:
- 2004.05.22 (Christian Borgelt)
-
getSum
public double getSum()Get the sum of the data vector weights.- Returns:
- the sum of the data vector weights
- Since:
- 2007.05.16 (Christian Borgelt)
-
aggregate
Aggregate a data vector.It is assumed that the value of the output/response variable is in the element with index
getVarCount()-1
.- Parameters:
vec
- the data vectorwgt
- the weight of the data point- Throws:
RegException
- if the logit transformation failed- Since:
- 2004.05.22 (Christian Borgelt)
-
solve
Set up and solve the regression equation system.- Throws:
RegException
- if the computation failed- Since:
- 2004.05.22 (Christian Borgelt)
-
getSSE
public double getSSE()Compute the sum of squared errors.This functions computes the sum of squared errors from the regression coefficients and the Cholesky decomposition of the regression matrix. As this is numerically unstable, the result should be taken with a grain of salt.
- Returns:
- the sum of squared errors
- Since:
- 2004.05.22 (Christian Borgelt)
-
execute
public double execute(double[] vec) Execute a regression function.- Parameters:
vec
- the data vector for which to execute the function- Returns:
- the value of the regression function
- Since:
- 2004.05.22 (Christian Borgelt)
-
getAsTable
public table.Table getAsTable()Get the regression model as a table.- Returns:
- the regression model as a table
- Since:
- 2007.04.13 (Christian Borgelt)
-
getAsTable
public table.Table getAsTable(boolean zeros) Get the regression model as a table.- Parameters:
zeros
- whether to show zero exponents- Returns:
- the regression model as a table
- Since:
- 2007.05.18 (Christian Borgelt)
-
getAsTable
public table.Table getAsTable(double min) Get the regression model as a table.- Parameters:
min
- the minimum absolute value of a coefficient- Returns:
- the regression model as a table
- Since:
- 2007.03.19 (Christian Borgelt)
-
getAsTable
public table.Table getAsTable(boolean zeros, double min) Get the regression model as a table.- Parameters:
zeros
- whether to show zero exponentsmin
- the minimum absolute value of a coefficient- Returns:
- the regression model as a table
- Since:
- 2007.05.18 (Christian Borgelt)
-
toString
Describe the regression function. -
toString
Describe the regression function.- Parameters:
header
- the text to add as a header- Returns:
- a description of the regression function
- Since:
- 2004.05.22 (Christian Borgelt)
-
toString
Describe the regression function.- Parameters:
min
- the minimum absolute value of a coefficient- Returns:
- a description of the regression function
- Since:
- 2004.05.22 (Christian Borgelt)
-
parse
Parse a regression description.- Parameters:
scan
- the scanner to read the description from- Returns:
- the parsed regression description
- Throws:
IOException
- if a read error occurs- Since:
- 2007.05.16 (Christian Borgelt)
-
parse
Parse a regression description.- Parameters:
scan
- the scanner to read the description fromatts
- the variable domains as a table- Returns:
- the parsed regression description
- Throws:
IOException
- if a read error occurs- Since:
- 2007.05.16 (Christian Borgelt)
-
main
Main function for testing basic functionality.- Parameters:
args
- the command line arguments- Since:
- 2004.06.02 (Christian Borgelt)
-