InputType
- The type of the input to the tree.public class RegressionTreeLearner<InputType> extends AbstractDecisionTreeLearner<InputType,java.lang.Double> implements SupervisedBatchLearner<InputType,java.lang.Double,RegressionTree<InputType>>
RegressionTreeLearner
class implements a learning algorithm for
a regression tree that makes use of a decider learner and a regression
learner. The tree grows as a decision tree until it gets to a leaf node
(determined by a minimum number of nodes), and then learns a regression
function at the leaf node.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_LEAF_COUNT_THRESHOLD
The default threshold for making a leaf node based on count.
|
static int |
DEFAULT_MAX_DEPTH
The default maximum depth to grow the tree to.
|
protected int |
leafCountThreshold
The threshold for making a node a leaf, determined by how many
instances fall in the threshold.
|
protected int |
maxDepth
The maximum depth for the tree.
|
protected BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>>,? extends Evaluator<? super InputType,java.lang.Double>> |
regressionLearner
The learning algorithm for the regression function.
|
deciderLearner
DEFAULT_ITERATION, iteration
Constructor and Description |
---|
RegressionTreeLearner()
Creates a new instance of RegressionTreeLearner
|
RegressionTreeLearner(DeciderLearner<? super InputType,java.lang.Double,?,?> deciderLearner)
Creates a new instance of CategorizationTreeLearner with a mean node
learner
|
RegressionTreeLearner(DeciderLearner<? super InputType,java.lang.Double,?,?> deciderLearner,
BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>>,? extends Evaluator<? super InputType,java.lang.Double>> regressionLearner)
Creates a new instance of CategorizationTreeLearner.
|
RegressionTreeLearner(DeciderLearner<? super InputType,java.lang.Double,?,?> deciderLearner,
BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>>,? extends Evaluator<? super InputType,java.lang.Double>> regressionLearner,
int leafCountThreshold,
int maxDepth)
Creates a new instance of CategorizationTreeLearner.
|
Modifier and Type | Method and Description |
---|---|
RegressionTreeLearner<InputType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
int |
getLeafCountThreshold()
Gets the leaf count threshold, which determines the number of elements
at which to learn a regression function.
|
int |
getMaxDepth()
Gets the maximum depth to grow the tree.
|
BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>>,? extends Evaluator<? super InputType,java.lang.Double>> |
getRegressionLearner()
Gets the regression learner that is to be used to fit a function
approximator to the values in the tree.
|
RegressionTree<InputType> |
learn(java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>> data)
The
learn method creates an object of ResultType using
data of type DataType , using some form of "learning" algorithm. |
protected RegressionTreeNode<InputType,?> |
learnNode(java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>> data,
AbstractDecisionTreeNode<InputType,java.lang.Double,?> parent)
Recursively learns the regression tree using the given collection
of data, returning the created node.
|
void |
setLeafCountThreshold(int leafCountThreshold)
Sets the leaf count threshold, which determines the number of elements
at which to learn a regression function.
|
void |
setMaxDepth(int maxDepth)
Sets the maximum depth to grow the tree.
|
void |
setRegressionLearner(BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>>,? extends Evaluator<? super InputType,java.lang.Double>> regressionLearner)
Sets the regression learner that is to be used to fit a function
approximator to the values in the tree.
|
areAllOutputsEqual, getDeciderLearner, learnChildNodes, setDeciderLearner, splitData
addIterativeAlgorithmListener, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, getIteration, getListeners, removeIterativeAlgorithmListener, setIteration, setListeners
public static final int DEFAULT_LEAF_COUNT_THRESHOLD
public static final int DEFAULT_MAX_DEPTH
protected BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>>,? extends Evaluator<? super InputType,java.lang.Double>> regressionLearner
protected int leafCountThreshold
protected int maxDepth
public RegressionTreeLearner()
public RegressionTreeLearner(DeciderLearner<? super InputType,java.lang.Double,?,?> deciderLearner)
deciderLearner
- The learner for the decision function.public RegressionTreeLearner(DeciderLearner<? super InputType,java.lang.Double,?,?> deciderLearner, BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>>,? extends Evaluator<? super InputType,java.lang.Double>> regressionLearner)
deciderLearner
- The learner for the decision function.regressionLearner
- The learner for the regression function.public RegressionTreeLearner(DeciderLearner<? super InputType,java.lang.Double,?,?> deciderLearner, BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>>,? extends Evaluator<? super InputType,java.lang.Double>> regressionLearner, int leafCountThreshold, int maxDepth)
deciderLearner
- The learner for the decision function.regressionLearner
- The learner for the regression function.leafCountThreshold
- The leaf count threshold, which determines the number of
elements at which to learn a regression function.maxDepth
- The maximum depth to learn the tree. Must be positive.public RegressionTreeLearner<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 AbstractDecisionTreeLearner<InputType,java.lang.Double>
public RegressionTree<InputType> learn(java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>> data)
BatchLearner
learn
method creates an object of ResultType
using
data of type DataType
, using some form of "learning" algorithm.learn
in interface BatchLearner<java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>>,RegressionTree<InputType>>
data
- The data that the learning algorithm will use to create an
object of ResultType
.protected RegressionTreeNode<InputType,?> learnNode(java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>> data, AbstractDecisionTreeNode<InputType,java.lang.Double,?> parent)
learnNode
in class AbstractDecisionTreeLearner<InputType,java.lang.Double>
data
- The set of data to learn a node from.parent
- The parent node.public BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>>,? extends Evaluator<? super InputType,java.lang.Double>> getRegressionLearner()
public void setRegressionLearner(BatchLearner<? super java.util.Collection<? extends InputOutputPair<? extends InputType,java.lang.Double>>,? extends Evaluator<? super InputType,java.lang.Double>> regressionLearner)
regressionLearner
- The regression learner.public int getLeafCountThreshold()
public void setLeafCountThreshold(int leafCountThreshold)
leafCountThreshold
- The leaf count threshold. Must be non-negative.public int getMaxDepth()
public void setMaxDepth(int maxDepth)
maxDepth
- The maximum depth to grow the tree. Zero or less means no
maximum depth.