InputType
- The input type for the decision tree.OutputType
- The output type for the decision tree.public abstract class AbstractDecisionTreeLearner<InputType,OutputType> extends AbstractIterativeAlgorithm implements java.io.Serializable
AbstractDecisionTreeLearner
implements common functionality for
learning algorithms that learn a decision tree.Modifier and Type | Field and Description |
---|---|
protected DeciderLearner<? super InputType,OutputType,?,?> |
deciderLearner
The learning algorithm for the decision function.
|
DEFAULT_ITERATION, iteration
Constructor and Description |
---|
AbstractDecisionTreeLearner()
Creates a new instance of AbstractDecisionTreeLearner
|
AbstractDecisionTreeLearner(DeciderLearner<? super InputType,OutputType,?,?> deciderLearner)
Creates a new instance of AbstractDecisionTreeLearner.
|
Modifier and Type | Method and Description |
---|---|
boolean |
areAllOutputsEqual(java.util.Collection<? extends InputOutputPair<? extends InputType,OutputType>> data)
Determines if all of the output values in the collection are equal.
|
AbstractDecisionTreeLearner<InputType,OutputType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
DeciderLearner<? super InputType,OutputType,?,?> |
getDeciderLearner()
Gets the learner for the decision function.
|
protected <DecisionType> |
learnChildNodes(AbstractDecisionTreeNode<InputType,OutputType,DecisionType> node,
java.util.Collection<? extends InputOutputPair<? extends InputType,OutputType>> data,
Categorizer<? super InputType,? extends DecisionType> decider)
Learns the child nodes for a node using the given data at the node
plus the decision function for the node.
|
protected abstract AbstractDecisionTreeNode<InputType,OutputType,?> |
learnNode(java.util.Collection<? extends InputOutputPair<? extends InputType,OutputType>> data,
AbstractDecisionTreeNode<InputType,OutputType,?> parent)
Recursively learns the decision tree using the given collection
of data, returning the created node.
|
void |
setDeciderLearner(DeciderLearner<? super InputType,OutputType,?,?> deciderLearner)
Sets the learner for the decision function.
|
<DecisionType> |
splitData(java.util.Collection<? extends InputOutputPair<? extends InputType,OutputType>> data,
Categorizer<? super InputType,? extends DecisionType> decider)
Splits the data into new lists based on the given decision function.
|
addIterativeAlgorithmListener, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, getIteration, getListeners, removeIterativeAlgorithmListener, setIteration, setListeners
protected DeciderLearner<? super InputType,OutputType,?,?> deciderLearner
public AbstractDecisionTreeLearner()
public AbstractDecisionTreeLearner(DeciderLearner<? super InputType,OutputType,?,?> deciderLearner)
deciderLearner
- The learner for the decision functionpublic AbstractDecisionTreeLearner<InputType,OutputType> 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 AbstractIterativeAlgorithm
protected abstract AbstractDecisionTreeNode<InputType,OutputType,?> learnNode(java.util.Collection<? extends InputOutputPair<? extends InputType,OutputType>> data, AbstractDecisionTreeNode<InputType,OutputType,?> parent)
data
- The set of data to learn a node from.parent
- The parent node.protected <DecisionType> void learnChildNodes(AbstractDecisionTreeNode<InputType,OutputType,DecisionType> node, java.util.Collection<? extends InputOutputPair<? extends InputType,OutputType>> data, Categorizer<? super InputType,? extends DecisionType> decider)
DecisionType
- The type of decision function.node
- The node to learn the children for. The child nodes are added
by this method.data
- The data at the node to learn the children for.decider
- The decision function to use.public <DecisionType> java.util.Map<DecisionType,java.util.LinkedList<InputOutputPair<? extends InputType,OutputType>>> splitData(java.util.Collection<? extends InputOutputPair<? extends InputType,OutputType>> data, Categorizer<? super InputType,? extends DecisionType> decider)
DecisionType
- The type of decision function.data
- The data to split.decider
- The decision function.public boolean areAllOutputsEqual(java.util.Collection<? extends InputOutputPair<? extends InputType,OutputType>> data)
data
- The data to check for equality on the outputs.public DeciderLearner<? super InputType,OutputType,?,?> getDeciderLearner()
public void setDeciderLearner(DeciderLearner<? super InputType,OutputType,?,?> deciderLearner)
deciderLearner
- The learner for the decision function