weka.classifiers.trees
Class UserClassifier.TreeClass

java.lang.Object
  extended byweka.classifiers.trees.UserClassifier.TreeClass
Enclosing class:
UserClassifier

private class UserClassifier.TreeClass
extends java.lang.Object

Inner class used to represent the actual decision tree structure and data.


Field Summary
 int m_attrib1
           
 int m_attrib2
           
 Classifier m_classObject
          Used instead of the standard leaf if one exists.
 Filter m_filter
          Used on the instances while classifying if one exists.
 java.lang.String m_identity
          A string to uniquely identify this node.
 UserClassifier.TreeClass m_parent
           
 FastVector m_ranges
          This contains the info for the coords of the shape converted to attrib coords, for polygon the first attrib is the number of points, This is not more object oriented because that would be over kill.
 UserClassifier.TreeClass m_set1
           
 UserClassifier.TreeClass m_set2
           
 Instances m_training
           
 double m_weight
           
 
Constructor Summary
UserClassifier.TreeClass(FastVector r, int a1, int a2, int id, double w, Instances i, UserClassifier.TreeClass p)
          Constructs a TreeClass node with all the important information.
 
Method Summary
 double[] calcClassType(Instance i)
          This will recursively go through the tree and return inside the array the weightings of each of the class types for this instance.
 void getAlternateLabel(java.lang.StringBuffer s)
          Returns a string containing a bit of information about this node, in alternate form.
 void getLabel(java.lang.StringBuffer s)
          Returns a string containing a bit of information about this node.
 UserClassifier.TreeClass getNode(java.lang.String id)
          Goes through the tree structure recursively and returns the node that has the id.
private  boolean inPoly(FastVector ob, double x, double y)
          Call this to determine if an instance is in a polygon.
private  boolean inPolyline(FastVector ob, double x, double y)
          Call to find out if an instance is in a polyline.
 void objectStrings(java.lang.StringBuffer t)
          This will append the class Object in the tree to the string buffer.
 void setClassifier(Classifier c)
          Call this to set an alternate classifier For this node.
 void setInfo(int at1, int at2, FastVector ar)
          Call this to set this node with different information to what it was created with.
private  void setLeaf()
          This sets up the informtion about this node such as the s.d or the number of each class.
private  void setLinear()
          This function gets called to set the node to use a linear regression and attribute filter.
 void toDotty(java.lang.StringBuffer t)
          Converts The tree structure to a dotty string.
 void toString(int l, java.lang.StringBuffer t)
          Converts the tree structure to a string. for people to read.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_ranges

public FastVector m_ranges
This contains the info for the coords of the shape converted to attrib coords, for polygon the first attrib is the number of points, This is not more object oriented because that would be over kill.


m_attrib1

public int m_attrib1

m_attrib2

public int m_attrib2

m_set1

public UserClassifier.TreeClass m_set1

m_set2

public UserClassifier.TreeClass m_set2

m_parent

public UserClassifier.TreeClass m_parent

m_identity

public java.lang.String m_identity
A string to uniquely identify this node.


m_weight

public double m_weight

m_training

public Instances m_training

m_classObject

public Classifier m_classObject
Used instead of the standard leaf if one exists.


m_filter

public Filter m_filter
Used on the instances while classifying if one exists.

Constructor Detail

UserClassifier.TreeClass

public UserClassifier.TreeClass(FastVector r,
                                int a1,
                                int a2,
                                int id,
                                double w,
                                Instances i,
                                UserClassifier.TreeClass p)
                         throws java.lang.Exception
Constructs a TreeClass node with all the important information.

Parameters:
r - A FastVector containing the shapes, null if it's a leaf node.
a1 - The first attribute.
a2 - The second attribute.
id - The unique id number for this node.
w - The weight of this node.
i - The instances that make it to this node from the training data.
Throws:
java.lang.Exception - if can't use 'i' properly.
Method Detail

setClassifier

public void setClassifier(Classifier c)
                   throws java.lang.Exception
Call this to set an alternate classifier For this node.

Parameters:
c - The alternative classifier to use.
Throws:
java.lang.Exception - if alternate classifier can't build classification.

setInfo

public void setInfo(int at1,
                    int at2,
                    FastVector ar)
             throws java.lang.Exception
Call this to set this node with different information to what it was created with.

Parameters:
ar - The shapes at this node, null if leaf node, or alternate classifier.
Throws:
java.lang.Exception - if leaf node and cant't create leaf info.

setLeaf

private void setLeaf()
              throws java.lang.Exception
This sets up the informtion about this node such as the s.d or the number of each class.

Throws:
java.lang.Exception - if problem with training instances.

calcClassType

public double[] calcClassType(Instance i)
                       throws java.lang.Exception
This will recursively go through the tree and return inside the array the weightings of each of the class types for this instance. Note that this function returns an otherwise unreferenced double array so there are no worry's about making changes.

Parameters:
i - The instance to test
Returns:
A double array containing the results.
Throws:
java.lang.Exception - if can't use instance i properly.

setLinear

private void setLinear()
                throws java.lang.Exception
This function gets called to set the node to use a linear regression and attribute filter.

Throws:
If - can't set a default linear egression model.
java.lang.Exception

inPolyline

private boolean inPolyline(FastVector ob,
                           double x,
                           double y)
Call to find out if an instance is in a polyline.

Parameters:
ob - The polyline to check.
x - The value of attribute1 to check.
y - The value of attribute2 to check.
Returns:
True if inside, false if not.

inPoly

private boolean inPoly(FastVector ob,
                       double x,
                       double y)
Call this to determine if an instance is in a polygon.

Parameters:
ob - The polygon.
x - The value of attribute 1.
y - The value of attribute 2.
Returns:
True if in polygon, false if not.

getNode

public UserClassifier.TreeClass getNode(java.lang.String id)
Goes through the tree structure recursively and returns the node that has the id.

Parameters:
id - The node to find.
Returns:
The node that matches the id.

getAlternateLabel

public void getAlternateLabel(java.lang.StringBuffer s)
                       throws java.lang.Exception
Returns a string containing a bit of information about this node, in alternate form.

Parameters:
s - The string buffer to fill.
Throws:
java.lang.Exception - if can't create label.

getLabel

public void getLabel(java.lang.StringBuffer s)
              throws java.lang.Exception
Returns a string containing a bit of information about this node.

Parameters:
s - The stringbuffer to fill.
Throws:
java.lang.Exception - if can't create label.

toDotty

public void toDotty(java.lang.StringBuffer t)
             throws java.lang.Exception
Converts The tree structure to a dotty string.

Parameters:
t - The stringbuffer to fill with the dotty structure.
Throws:
java.lang.Exception - if can't convert structure to dotty.

objectStrings

public void objectStrings(java.lang.StringBuffer t)
This will append the class Object in the tree to the string buffer.

Parameters:
t - The stringbuffer.

toString

public void toString(int l,
                     java.lang.StringBuffer t)
              throws java.lang.Exception
Converts the tree structure to a string. for people to read.

Parameters:
l - How deep this node is in the tree.
t - The stringbuffer to fill with the string.
Throws:
java.lang.Exception - if can't convert th string.