Package weka.classifiers.trees.j48
Class GraftSplit
- java.lang.Object
-
- weka.classifiers.trees.j48.ClassifierSplitModel
-
- weka.classifiers.trees.j48.GraftSplit
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Comparable,RevisionHandler
public class GraftSplit extends ClassifierSplitModel implements java.lang.Comparable
Class implementing a split for nodes added to a tree during grafting.- Version:
- $Revision 1.0 $
- Author:
- Janice Boughton (jrbought@infotech.monash.edu.au)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description GraftSplit(int a, double v, int t, double c, double l)constructorGraftSplit(int a, double v, int t, double oC, double[][] counts)constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intattribute()voidbuildClassifier(Instances data)builds m_graftdistro using the passed datadoubleclassProb(int classIndex, Instance instance, int theSubset)returns the probability for instance for the specified classintcompareTo(java.lang.Object g)method needed for sorting a collection of GraftSplits by laplace valuevoiddeleteGraftedCases(Instances data)deletes the cases in data that belong to leaf pointed to by the test (i.e.java.lang.StringdumpLabelG(int index, Instances data)Prints label for subset index of instances (eg class).NoSplitgetLeaf()NoSplitgetOtherLeaf()java.lang.StringgetRevision()Returns the revision string.doublelaplaceForSubsetOfInterest()java.lang.StringleftSide(Instances data)Prints left side of condition satisfied by instances.intmaxClassForSubsetOfInterest()doublepositives(int subset)doublepositivesForSubsetOfInterest()java.lang.StringrightSide(int index, Instances data)Prints condition satisfied by instances in subset index.java.lang.StringsourceExpression(int index, Instances data)Returns a string containing java source code equivalent to the test made at this node.doublesplitPoint()intsubsetOfInterest()inttestType()returns the test typejava.lang.StringtoString(Instances data)method for returning information about this GraftSplitdoubletotalForSubset(int subset)doubletotalForSubsetOfInterest()double[]weights(Instance instance)Returns weights if instance is assigned to more than one subset.intwhichSubset(Instance instance)Returns index of subset instance is assigned to.-
Methods inherited from class weka.classifiers.trees.j48.ClassifierSplitModel
checkModel, classifyInstance, classProbLaplace, clone, codingCost, distribution, dumpLabel, dumpModel, numSubsets, resetDistribution, sourceClass, split
-
-
-
-
Constructor Detail
-
GraftSplit
public GraftSplit(int a, double v, int t, double c, double l)constructor- Parameters:
a- the attribute to split onv- the value of a where split occurst- the test type (0 is <=, 1 is >, 2 is =, 3 is !)c- the class to label the leaf node pointed to by test as.l- the laplace value (needed when sorting GraftSplits)
-
GraftSplit
public GraftSplit(int a, double v, int t, double oC, double[][] counts) throws java.lang.Exceptionconstructor- Parameters:
a- the attribute to split onv- the value of a where split occurst- the test type (0 is <=, 1 is >, 2 is =, 3 is !=)oC- the class to label the leaf node not pointed to by test as.counts- the distribution for this split- Throws:
java.lang.Exception
-
-
Method Detail
-
deleteGraftedCases
public void deleteGraftedCases(Instances data)
deletes the cases in data that belong to leaf pointed to by the test (i.e. the subset of interest). this is useful so the instances belonging to that leaf aren't passed down the other branch.- Parameters:
data- the instances to delete from
-
buildClassifier
public void buildClassifier(Instances data) throws java.lang.Exception
builds m_graftdistro using the passed data- Specified by:
buildClassifierin classClassifierSplitModel- Parameters:
data- the instances to use when creating the distribution- Throws:
java.lang.Exception- if something goes wrong
-
getLeaf
public NoSplit getLeaf()
- Returns:
- the NoSplit object for the leaf pointed to by m_testType branch
-
getOtherLeaf
public NoSplit getOtherLeaf()
- Returns:
- the NoSplit object for the leaf not pointed to by m_testType branch
-
dumpLabelG
public final java.lang.String dumpLabelG(int index, Instances data) throws java.lang.ExceptionPrints label for subset index of instances (eg class).- Parameters:
index- the bag to dump label fordata- to get attribute names and such- Returns:
- the label as a string
- Throws:
java.lang.Exception- if something goes wrong
-
subsetOfInterest
public int subsetOfInterest()
- Returns:
- the subset that is specified by the test type
-
positivesForSubsetOfInterest
public double positivesForSubsetOfInterest()
- Returns:
- the number of positive cases in the subset of interest
-
positives
public double positives(int subset)
- Parameters:
subset- the subset to get the positives for- Returns:
- the number of positive cases in the specified subset
-
totalForSubsetOfInterest
public double totalForSubsetOfInterest()
- Returns:
- the number of instances in the subset of interest
-
totalForSubset
public double totalForSubset(int subset)
- Parameters:
subset- the index of the bag to get the total for- Returns:
- the number of instances in the subset
-
leftSide
public java.lang.String leftSide(Instances data)
Prints left side of condition satisfied by instances.- Specified by:
leftSidein classClassifierSplitModel- Parameters:
data- the data.
-
attribute
public int attribute()
- Returns:
- the index of the attribute to split on
-
rightSide
public final java.lang.String rightSide(int index, Instances data)Prints condition satisfied by instances in subset index.- Specified by:
rightSidein classClassifierSplitModel
-
sourceExpression
public final java.lang.String sourceExpression(int index, Instances data)Returns a string containing java source code equivalent to the test made at this node. The instance being tested is called "i".- Specified by:
sourceExpressionin classClassifierSplitModel- Parameters:
index- index of the nominal value testeddata- the data containing instance structure info- Returns:
- a value of type 'String'
-
weights
public double[] weights(Instance instance)
Description copied from class:ClassifierSplitModelReturns weights if instance is assigned to more than one subset. Returns null if instance is only assigned to one subset.- Specified by:
weightsin classClassifierSplitModel- Parameters:
instance- the instance to produce the weights for- Returns:
- a double array of weights, null if only belongs to one subset
-
whichSubset
public int whichSubset(Instance instance)
Description copied from class:ClassifierSplitModelReturns index of subset instance is assigned to. Returns -1 if instance is assigned to more than one subset.- Specified by:
whichSubsetin classClassifierSplitModel- Parameters:
instance- the instance for which to determine the subset- Returns:
- an int indicating the subset this instance belongs to
-
splitPoint
public double splitPoint()
- Returns:
- the value of the split point
-
maxClassForSubsetOfInterest
public int maxClassForSubsetOfInterest()
- Returns:
- the dominate class for the subset of interest
-
laplaceForSubsetOfInterest
public double laplaceForSubsetOfInterest()
- Returns:
- the laplace value for maxClass of subset of interest
-
testType
public int testType()
returns the test type- Returns:
- value of testtype
-
compareTo
public int compareTo(java.lang.Object g)
method needed for sorting a collection of GraftSplits by laplace value- Specified by:
compareToin interfacejava.lang.Comparable- Parameters:
g- the graft split to compare to this one- Returns:
- -1, 0, or 1 if this GraftSplit laplace is <, = or > than that of g
-
classProb
public final double classProb(int classIndex, Instance instance, int theSubset) throws java.lang.Exceptionreturns the probability for instance for the specified class- Overrides:
classProbin classClassifierSplitModel- Parameters:
classIndex- the index of the classinstance- the instance to get the probability fortheSubset- the subset- Throws:
java.lang.Exception- if something goes wrong
-
toString
public java.lang.String toString(Instances data)
method for returning information about this GraftSplit- Parameters:
data- instances for determining names of attributes and values- Returns:
- a string showing this GraftSplit's information
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Returns:
- the revision
-
-