public class Rule extends java.lang.Object implements java.io.Serializable, RevisionHandler
| Modifier and Type | Field and Description |
|---|---|
protected static int |
LEFT |
protected RuleNode |
m_topOfTree
the top of the m5 tree for this rule
|
protected static int |
RIGHT |
| Constructor and Description |
|---|
Rule()
Constructor declaration
|
| Modifier and Type | Method and Description |
|---|---|
protected static double |
absDev(int attr,
Instances inst)
Returns the absolute deviation value of the supplied attribute index.
|
void |
buildClassifier(Instances data)
Generates a single rule or m5 model tree.
|
double |
classifyInstance(Instance instance)
Calculates a prediction for an instance using this rule or M5 model tree
|
void |
freeNotCoveredInstances()
Free up memory consumed by the set of instances not covered by this rule.
|
RuleNode |
getM5RootNode() |
double |
getMinNumInstances()
Get the minimum number of instances to allow at a leaf node
|
boolean |
getRegressionTree()
Get the value of regressionTree.
|
java.lang.String |
getRevision()
Returns the revision string.
|
boolean |
getSmoothing()
Get whether or not smoothing has been turned on
|
boolean |
getUnpruned()
Get whether unpruned tree/rules are being generated
|
boolean |
getUseTree()
get whether an m5 tree is being used rather than rules
|
Instances |
notCoveredInstances()
Get the instances not covered by this rule
|
void |
setMinNumInstances(double minNum)
Set the minumum number of instances to allow at a leaf node
|
void |
setRegressionTree(boolean newregressionTree)
Set the value of regressionTree.
|
protected void |
setSaveInstances(boolean save)
Sets whether instances at each node in an M5 tree should be saved for visualization purposes.
|
void |
setSmoothing(boolean s)
Smooth predictions
|
void |
setUnpruned(boolean unpruned)
Use unpruned tree/rules
|
void |
setUseTree(boolean u)
Use an m5 tree rather than generate rules
|
protected static double |
stdDev(int attr,
Instances inst)
Returns the standard deviation value of the supplied attribute index.
|
RuleNode |
topOfTree()
Returns the top of the tree.
|
java.lang.String |
toString()
Return a description of the m5 tree or rule
|
protected static int LEFT
protected static int RIGHT
protected RuleNode m_topOfTree
public void buildClassifier(Instances data) throws java.lang.Exception
data - set of instances serving as training datajava.lang.Exception - if the rule has not been generated successfullypublic double classifyInstance(Instance instance) throws java.lang.Exception
instance - the instance whos class value is to be predictedjava.lang.Exception - if a prediction can't be made.public RuleNode topOfTree()
public java.lang.String toString()
toString in class java.lang.Objectpublic void setUnpruned(boolean unpruned)
unpruned - true if unpruned tree/rules are to be generatedpublic boolean getUnpruned()
public void setUseTree(boolean u)
u - true if m5 tree is to be usedpublic boolean getUseTree()
public void setSmoothing(boolean s)
s - true if smoothing is to be usedpublic boolean getSmoothing()
public Instances notCoveredInstances()
public void freeNotCoveredInstances()
protected static final double stdDev(int attr,
Instances inst)
attr - an attribute indexinst - the instancesprotected static final double absDev(int attr,
Instances inst)
attr - an attribute indexinst - the instancesprotected void setSaveInstances(boolean save)
save - a boolean valuepublic boolean getRegressionTree()
public void setRegressionTree(boolean newregressionTree)
newregressionTree - Value to assign to regressionTree.public void setMinNumInstances(double minNum)
minNum - the minimum number of instancespublic double getMinNumInstances()
double valuepublic RuleNode getM5RootNode()
public java.lang.String getRevision()
getRevision in interface RevisionHandler