Package weka.classifiers.trees.j48
Class GraftSplit
java.lang.Object
weka.classifiers.trees.j48.ClassifierSplitModel
weka.classifiers.trees.j48.GraftSplit
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable
,RevisionHandler
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:
-
Constructor Summary
ConstructorsConstructorDescriptionGraftSplit
(int a, double v, int t, double c, double l) constructorGraftSplit
(int a, double v, int t, double oC, double[][] counts) constructor -
Method Summary
Modifier and TypeMethodDescriptionint
void
buildClassifier
(Instances data) builds m_graftdistro using the passed datafinal double
returns the probability for instance for the specified classint
method needed for sorting a collection of GraftSplits by laplace valuevoid
deleteGraftedCases
(Instances data) deletes the cases in data that belong to leaf pointed to by the test (i.e.final String
dumpLabelG
(int index, Instances data) Prints label for subset index of instances (eg class).getLeaf()
Returns the revision string.double
Prints left side of condition satisfied by instances.int
double
positives
(int subset) double
final String
Prints condition satisfied by instances in subset index.final String
sourceExpression
(int index, Instances data) Returns a string containing java source code equivalent to the test made at this node.double
int
int
testType()
returns the test typemethod for returning information about this GraftSplitdouble
totalForSubset
(int subset) double
double[]
Returns weights if instance is assigned to more than one subset.int
whichSubset
(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 Details
-
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
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 !=)oC
- the class to label the leaf node not pointed to by test as.counts
- the distribution for this split- Throws:
Exception
-
-
Method Details
-
deleteGraftedCases
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
builds m_graftdistro using the passed data- Specified by:
buildClassifier
in classClassifierSplitModel
- Parameters:
data
- the instances to use when creating the distribution- Throws:
Exception
- if something goes wrong
-
getLeaf
- Returns:
- the NoSplit object for the leaf pointed to by m_testType branch
-
getOtherLeaf
- Returns:
- the NoSplit object for the leaf not pointed to by m_testType branch
-
dumpLabelG
Prints 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:
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
Prints left side of condition satisfied by instances.- Specified by:
leftSide
in classClassifierSplitModel
- Parameters:
data
- the data.
-
attribute
public int attribute()- Returns:
- the index of the attribute to split on
-
rightSide
Prints condition satisfied by instances in subset index.- Specified by:
rightSide
in classClassifierSplitModel
-
sourceExpression
Returns a string containing java source code equivalent to the test made at this node. The instance being tested is called "i".- Specified by:
sourceExpression
in classClassifierSplitModel
- Parameters:
index
- index of the nominal value testeddata
- the data containing instance structure info- Returns:
- a value of type 'String'
-
weights
Description copied from class:ClassifierSplitModel
Returns weights if instance is assigned to more than one subset. Returns null if instance is only assigned to one subset.- Specified by:
weights
in classClassifierSplitModel
- Parameters:
instance
- the instance to produce the weights for- Returns:
- a double array of weights, null if only belongs to one subset
-
whichSubset
Description copied from class:ClassifierSplitModel
Returns index of subset instance is assigned to. Returns -1 if instance is assigned to more than one subset.- Specified by:
whichSubset
in 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
method needed for sorting a collection of GraftSplits by laplace value- Specified by:
compareTo
in interfaceComparable
- 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
returns the probability for instance for the specified class- Overrides:
classProb
in classClassifierSplitModel
- Parameters:
classIndex
- the index of the classinstance
- the instance to get the probability fortheSubset
- the subset- Throws:
Exception
- if something goes wrong
-
toString
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
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Returns:
- the revision
-