Package weka.classifiers.rules
Class JRip.RipperRule
- java.lang.Object
-
- weka.classifiers.rules.Rule
-
- weka.classifiers.rules.JRip.RipperRule
-
- All Implemented Interfaces:
java.io.Serializable
,Copyable
,RevisionHandler
,WeightedInstancesHandler
- Enclosing class:
- JRip
public class JRip.RipperRule extends Rule
This class implements a single rule that predicts specified class. A rule consists of antecedents "AND"ed together and the consequent (class value) for the classification. In this class, the Information Gain (p*[log(p/t) - log(P/T)]) is used to select an antecedent and Reduced Error Prunning (REP) with the metric of accuracy rate p/(p+n) or (TP+TN)/(P+N) is used to prune the rule.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description RipperRule()
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
copy()
Get a shallow copy of this ruleboolean
covers(Instance datum)
Whether the instance covered by this ruleFastVector
getAntds()
Return the antecedentsdouble
getConsequent()
Gets the internal representation of the class label to be predictedjava.lang.String
getRevision()
Returns the revision string.void
grow(Instances data)
Build one rule using the growing databoolean
hasAntds()
Whether this rule has antecedents, i.e.void
prune(Instances pruneData, boolean useWhole)
Prune all the possible final sequences of the rule using the pruning data.void
setConsequent(double cl)
Sets the internal representation of the class label to be predicteddouble
size()
the number of antecedents of the rulejava.lang.String
toString(Attribute classAttr)
Prints this rule
-
-
-
Method Detail
-
setConsequent
public void setConsequent(double cl)
Sets the internal representation of the class label to be predicted- Parameters:
cl
- the internal representation of the class label to be predicted
-
getConsequent
public double getConsequent()
Gets the internal representation of the class label to be predicted- Specified by:
getConsequent
in classRule
- Returns:
- the internal representation of the class label to be predicted
-
copy
public java.lang.Object copy()
Get a shallow copy of this rule
-
covers
public boolean covers(Instance datum)
Whether the instance covered by this rule
-
hasAntds
public boolean hasAntds()
Whether this rule has antecedents, i.e. whether it is a default rule
-
getAntds
public FastVector getAntds()
Return the antecedents- Returns:
- the vector of antecedents
-
size
public double size()
the number of antecedents of the rule
-
grow
public void grow(Instances data) throws java.lang.Exception
Build one rule using the growing data
-
prune
public void prune(Instances pruneData, boolean useWhole)
Prune all the possible final sequences of the rule using the pruning data. The measure used to prune the rule is based on flag given.- Parameters:
pruneData
- the pruning data used to prune the ruleuseWhole
- flag to indicate whether use the error rate of the whole pruning data instead of the data covered
-
toString
public java.lang.String toString(Attribute classAttr)
Prints this rule- Parameters:
classAttr
- the class attribute in the data- Returns:
- a textual description of this rule
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Returns:
- the revision
-
-