net.sf.myra.antree.representation
Class Tree

java.lang.Object
  extended by net.sf.myra.antree.representation.Tree
All Implemented Interfaces:
java.lang.Cloneable, net.sf.myra.datamining.Model

public class Tree
extends java.lang.Object
implements net.sf.myra.datamining.Model, java.lang.Cloneable

Version:
$Revision: 2332 $ $Date:: 2011-08-06 22:30:28#$
Author:
Fernando Esteban Barril Otero

Nested Class Summary
static class Tree.DefaultGatherer
           
 
Constructor Summary
Tree()
          Default constructor.
Tree(Node root)
          Creates a new tree.
 
Method Summary
 void adjust(net.sf.myra.datamining.data.Dataset dataset)
          Adjust the leaf node predictions based on the specified data set.
 net.sf.myra.datamining.data.Label classify(net.sf.myra.datamining.data.Instance instance)
          Returns the label predicted for the specified instance.
 Tree clone()
           
 int countInternalNodes()
          Returns the number of leaf nodes of the tree.
 int countLeaves()
          Returns the number of leaf nodes of the tree.
 Statistics gather(net.sf.myra.datamining.data.Dataset dataset)
          Computes the nodes statistics.
 Node get(int index)
          Returns a node of the tree specified by its index.
 Branch getBranch(Node node)
          Returns the branch leading to the specified node.
 net.sf.myra.datamining.Gatherer getGatherer()
           
 int getIndex(Node node)
          Returns the index of the specified node.
 net.sf.myra.datamining.Unit<?> getQuality()
          Returns the quality of the tree.
 Node getRoot()
          Returns the root of the tree.
 java.util.Collection<java.lang.Integer> indexes(java.lang.Class<? extends Node> type)
          Returns the indexes of nodes.
 java.util.Collection<LeafNode> leaves()
          Returns the number of leaf nodes of the tree.
 void setQuality(net.sf.myra.datamining.Unit<?> quality)
          Sets the quality of the tree.
 void setRoot(Node root)
          Sets the root node of the tree.
 void setStatistics(Statistics statistics)
          Sets the nodes statistics to be used to deal with missing values.
 int size()
          Returns the number of nodes of the tree.
 net.sf.myra.datamining.model.RuleSet toRuleSet(net.sf.myra.datamining.data.Metadata metadata)
          Returns the tree represented as a set of rules.
 java.lang.String toString()
           
 java.lang.String toString(Statistics statistics)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tree

public Tree()
Default constructor.


Tree

public Tree(Node root)
Creates a new tree.

Parameters:
root - the root node of the tree.
Method Detail

setRoot

public void setRoot(Node root)
Sets the root node of the tree.

Parameters:
root - the root node to set.

getRoot

public Node getRoot()
Returns the root of the tree.

Returns:
the root of the tree.

setStatistics

public void setStatistics(Statistics statistics)
Sets the nodes statistics to be used to deal with missing values.

Parameters:
statistics - the statistics to set.

get

public Node get(int index)
Returns a node of the tree specified by its index.

Parameters:
index - the node index.
Returns:
a node of the tree specified by its index.

getIndex

public int getIndex(Node node)
Returns the index of the specified node.

Parameters:
node - the node to look for the index.
Returns:
the index of the specified node.

getBranch

public Branch getBranch(Node node)
Returns the branch leading to the specified node.

Parameters:
node - the node at the end of the branch.
Returns:
the branch leading to the specified node.

indexes

public java.util.Collection<java.lang.Integer> indexes(java.lang.Class<? extends Node> type)
Returns the indexes of nodes.

Parameters:
type - the type of the nodes.
Returns:
the indexes of nodes.

adjust

public void adjust(net.sf.myra.datamining.data.Dataset dataset)
Adjust the leaf node predictions based on the specified data set. This method should be used if the structure of the tree is changed (e.g. during the pruning of the tree).

Parameters:
dataset - the current data set.

getQuality

public net.sf.myra.datamining.Unit<?> getQuality()
Returns the quality of the tree.

Returns:
the quality of the tree.

setQuality

public void setQuality(net.sf.myra.datamining.Unit<?> quality)
Sets the quality of the tree.

Parameters:
quality - the quality to set.

size

public int size()
Returns the number of nodes of the tree.

Returns:
the number of nodes of the tree.

countInternalNodes

public int countInternalNodes()
Returns the number of leaf nodes of the tree.

Returns:
the number of leaf nodes of the tree.

countLeaves

public int countLeaves()
Returns the number of leaf nodes of the tree.

Returns:
the number of leaf nodes of the tree.

leaves

public java.util.Collection<LeafNode> leaves()
Returns the number of leaf nodes of the tree.

Returns:
the number of leaf nodes of the tree.

classify

public net.sf.myra.datamining.data.Label classify(net.sf.myra.datamining.data.Instance instance)
Returns the label predicted for the specified instance.

Specified by:
classify in interface net.sf.myra.datamining.Model
Parameters:
instance - the instance to classify.
Returns:
the label predicted for the specified instance.

gather

public Statistics gather(net.sf.myra.datamining.data.Dataset dataset)
Computes the nodes statistics.

Parameters:
dataset - the current dataset.
Returns:
the statistics of the nodes based on the specified dataset.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(Statistics statistics)

toRuleSet

public net.sf.myra.datamining.model.RuleSet toRuleSet(net.sf.myra.datamining.data.Metadata metadata)
Returns the tree represented as a set of rules.

Parameters:
metadata - the data set metadata.
Returns:
the tree represented as a set of rules.
See Also:
Rule

clone

public Tree clone()
Overrides:
clone in class java.lang.Object

getGatherer

public net.sf.myra.datamining.Gatherer getGatherer()
Specified by:
getGatherer in interface net.sf.myra.datamining.Model


Copyright © 2013. All Rights Reserved.