InputType
- Input class for the basis functions, for example, Double,
Vector, String.@CodeReview(reviewer="Kevin R. Dixon", date="2008-09-02", changesNeeded=false, comments={"Made minor changes to javadoc","Looks fine."}) @PublicationReference(author="Wikipedia", title="Linear regression", type=WebPage, year=2008, url="http://en.wikipedia.org/wiki/Linear_regression") public class LinearBasisRegression<InputType> extends AbstractCloneableSerializable implements SupervisedBatchLearner<InputType,java.lang.Double,VectorFunctionLinearDiscriminant<InputType>>
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_PSEUDO_INVERSE_TOLERANCE
Tolerance for the pseudo inverse in the learn method, 1.0E-10.
|
Constructor and Description |
---|
LinearBasisRegression(java.util.Collection<? extends Evaluator<? super InputType,java.lang.Double>> basisFunctions)
Creates a new instance of LinearRegression
|
LinearBasisRegression(Evaluator<? super InputType,Vector> inputToVectorMap)
Creates a new instance of LinearRegression
|
LinearBasisRegression(ScalarBasisSet<InputType> inputToVectorMap)
Creates a new instance of LinearRegression
|
Modifier and Type | Method and Description |
---|---|
LinearBasisRegression<InputType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
Evaluator<? super InputType,Vector> |
getInputToVectorMap()
Getter for inputToVectorMap
|
boolean |
getUsePseudoInverse()
Getter for usePseudoInverse
|
VectorFunctionLinearDiscriminant<InputType> |
learn(java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>> data)
Computes the linear regression for the given Collection of
InputOutputPairs.
|
void |
setInputToVectorMap(Evaluator<? super InputType,Vector> inputToVectorMap)
Setter for inputToVectorMap
|
void |
setUsePseudoInverse(boolean usePseudoInverse)
Setter for usePseudoInverse
|
public static final double DEFAULT_PSEUDO_INVERSE_TOLERANCE
public LinearBasisRegression(java.util.Collection<? extends Evaluator<? super InputType,java.lang.Double>> basisFunctions)
basisFunctions
- Basis functions to create the ScalarBasisSet frompublic LinearBasisRegression(ScalarBasisSet<InputType> inputToVectorMap)
inputToVectorMap
- Function that maps the InputType to a Vectorpublic LinearBasisRegression<InputType> clone()
AbstractCloneableSerializable
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
public VectorFunctionLinearDiscriminant<InputType> learn(java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>> data)
learn
in interface BatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>>,VectorFunctionLinearDiscriminant<InputType>>
data
- Collection of InputOutputPairs for the variables. Can be
WeightedInputOutputPairs.public Evaluator<? super InputType,Vector> getInputToVectorMap()
public void setInputToVectorMap(Evaluator<? super InputType,Vector> inputToVectorMap)
inputToVectorMap
- Function that maps the InputType to a Vectorpublic boolean getUsePseudoInverse()
public void setUsePseudoInverse(boolean usePseudoInverse)
usePseudoInverse
- Flag to use a pseudoinverse. True to use the expensive, but more
accurate, pseudoinverse routine. False uses a very fast, but
numerically less stable LU solver. Default value is "true".