weka.classifiers.rules.car
Class JCBA

java.lang.Object
  extended by weka.classifiers.AbstractClassifier
      extended by weka.classifiers.rules.car.CarClassifier
          extended by weka.classifiers.rules.car.JCBA
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Classifier, AdditionalMeasureProducer, CapabilitiesHandler, OptionHandler, RevisionHandler, TechnicalInformationHandler

public class JCBA
extends CarClassifier
implements OptionHandler, AdditionalMeasureProducer, CapabilitiesHandler, TechnicalInformationHandler

Class implemting a java version of the CBA algorithm using a CrTree. Alternatively the classifier can be used as a standard decision list classifier. The Tree Structure is described in: W. Li, J. Han, J.Pei: CMAR: Accurate and Efficient Classification Based on Multiple Class-Association Rules. In ICDM'01:369-376,2001. The CBA algorithm is described in: B. Liu, W. Hsu, Y. Ma: Integrating Classification and Association Rule Mining. In KDD'98:80-86,1998. Valid options are:

-A Class Association Rule Miner String
Class Association Rule Miner String should contain the full class name of a scheme included for selection followed by options to the Class Association Rule Miner.

-C confidence value
Sets the confidence value for the optional pessimistic-error-rate-based pruning (default 0.25).

-E
If set the optional pessimistic-error-rate-based pruning is enabled.

-N
If set the optional and the obligatory pruning step are disabled. Classifier behaves like a standard decision list classifier.

-V
If set the mined rule set is printed out as well.

Version:
$Revision: 8108 $
Author:
Stefan Mutter
See Also:
Serialized Form

Constructor Summary
JCBA()
           
 
Method Summary
 void buildClassifier(Instances newInstances)
          Generates the classifier.
 java.lang.String carMinerTipText()
          Gets the tipText for this option.
 java.lang.String CBATipText()
          Gets the tipText for the specified option.
 java.lang.String CFTipText()
          Gets the tipText for the specified option.
 double classifyInstance(Instance instance)
          Classifies an instance
 double[] distributionForInstance(Instance newInstance)
          Returns the class distribution for an instance
 java.util.Enumeration enumerateMeasures()
          Lists all additional statistics that are available
 Capabilities getCapabilities()
          Returns default capabilities of the base associator.
 CARuleMiner getCarMiner()
          Gets the class association rule miner
 boolean getCBA()
          Gets whether or not CBA or a standard decision list classifier is used
 float getCF()
          Gets the confidence value for pessimistic-error-rate-based pruning
 double getMeasure(java.lang.String additionalMeasureName)
          Gets the additional statistics
 java.lang.String[] getOptions()
          Gets the current settings of the Classifier.
 boolean getOptPruning()
          Gets whether or not optional pruning is turned on
 JCBAPruning getPrune()
          Gets the pruning algorithm: JCBAPruning
 java.lang.String getRevision()
          Returns the revision string.
 TechnicalInformation getTechnicalInformation()
          Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.
 boolean getTreeOutput()
          Gets whether or not the mined rule set is part of the output
 java.lang.String globalInfo()
          Gets a description of the JCBA algorithm
 double intermediateClassificationForInstance(Instance instance, JCBAPruning tree, Instances instances)
          Does the intermediate classification step during the CBA's obligatory pruning
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options
static void main(java.lang.String[] argv)
          Main method for testing this class.
 double measureMiningTime()
          Gets the mining time
 double measureNumClassRules()
          Gets the number of rules used for classification
 double measureNumMinedRules()
          Gets the number of mined rules
 double measureNumPrunedRules()
          Gets the number of rules after the optional pruning step
 double measurePruningTime()
          Gets the pruning time in seconds
 java.lang.String optPruningTipText()
          Gets the tipText for the specified option.
 void setCarMiner(CARuleMiner assoc)
          Sets the class association rule miner
 void setCBA(boolean flag)
          Sets whether or not CBA or a standard decision list classifier is used
 void setCF(float value)
          Sets the confidence value for pessimistic-error-rate-based pruning
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 void setOptPruning(boolean flag)
          Sets optional pruning
 void setTreeOutput(boolean flag)
          Sets whether or not mined rule set is part of the output
 java.lang.String toString()
          Prints the rules
 java.lang.String treeOutputTipText()
          Gets the tipText for the specified option.
 
Methods inherited from class weka.classifiers.rules.car.CarClassifier
sortAttributes
 
Methods inherited from class weka.classifiers.AbstractClassifier
debugTipText, forName, getDebug, makeCopies, makeCopy, runClassifier, setDebug
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JCBA

public JCBA()
Method Detail

getCapabilities

public Capabilities getCapabilities()
Returns default capabilities of the base associator.

Specified by:
getCapabilities in interface Classifier
Specified by:
getCapabilities in interface CapabilitiesHandler
Overrides:
getCapabilities in class AbstractClassifier
Returns:
the capabilities of the base classifier

getTechnicalInformation

public TechnicalInformation getTechnicalInformation()
Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.

Specified by:
getTechnicalInformation in interface TechnicalInformationHandler
Returns:
the technical information about this class

globalInfo

public java.lang.String globalInfo()
Gets a description of the JCBA algorithm

Returns:
a description of the JCBA algorithm

listOptions

public java.util.Enumeration listOptions()
Returns an enumeration describing the available options

Specified by:
listOptions in interface OptionHandler
Overrides:
listOptions in class AbstractClassifier
Returns:
an enumeration of all the available options

setOptions

public void setOptions(java.lang.String[] options)
                throws java.lang.Exception
Parses a given list of options. Valid options are:

-A Class Association Rule Miner String
Class Association Rule Miner String should contain the full class name of a scheme included for selection followed by options to the Class Association Rule Miner.

-C confidence value
Sets the confidence value for the optional pessimistic-error-rate-based pruning (default 0.25). -E
If set the optional pessimistic-error-rate-based pruning is enabled.

-N
If set the optional and the obligatory pruning step are disabled. Classifier behaves like a standard decision list classifier.

-V
If set the mined rule set is printed out as well.

Specified by:
setOptions in interface OptionHandler
Overrides:
setOptions in class AbstractClassifier
Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported

getOptions

public java.lang.String[] getOptions()
Gets the current settings of the Classifier.

Specified by:
getOptions in interface OptionHandler
Overrides:
getOptions in class AbstractClassifier
Returns:
an array of strings suitable for passing to setOptions

carMinerTipText

public java.lang.String carMinerTipText()
Gets the tipText for this option.

Returns:
the tipText for this option.

setCarMiner

public void setCarMiner(CARuleMiner assoc)
Sets the class association rule miner

Parameters:
assoc - the class association rule miner

getCarMiner

public CARuleMiner getCarMiner()
Gets the class association rule miner

Returns:
the class association rule miner

getPrune

public JCBAPruning getPrune()
Gets the pruning algorithm: JCBAPruning

Returns:
the pruning algorithm

optPruningTipText

public java.lang.String optPruningTipText()
Gets the tipText for the specified option.

Returns:
the tipText for the specified option.

setOptPruning

public void setOptPruning(boolean flag)
Sets optional pruning

Parameters:
flag - boolean flag

getOptPruning

public boolean getOptPruning()
Gets whether or not optional pruning is turned on

Returns:
true if optional pruning is turned on, false otherwise.

CFTipText

public java.lang.String CFTipText()
Gets the tipText for the specified option.

Returns:
the tipText for the specified option.

setCF

public void setCF(float value)
Sets the confidence value for pessimistic-error-rate-based pruning

Parameters:
value - the confidence value

getCF

public float getCF()
Gets the confidence value for pessimistic-error-rate-based pruning

Returns:
the confidence value

treeOutputTipText

public java.lang.String treeOutputTipText()
Gets the tipText for the specified option.

Returns:
the tipText for the specified option.

setTreeOutput

public void setTreeOutput(boolean flag)
Sets whether or not mined rule set is part of the output

Parameters:
flag - boolean flag

getTreeOutput

public boolean getTreeOutput()
Gets whether or not the mined rule set is part of the output

Returns:
true if mined rule set is part of the output, false otherwise

CBATipText

public java.lang.String CBATipText()
Gets the tipText for the specified option.

Returns:
the tipText for the specified option.

setCBA

public void setCBA(boolean flag)
Sets whether or not CBA or a standard decision list classifier is used

Parameters:
flag - true if CBA is used, false otherwise

getCBA

public boolean getCBA()
Gets whether or not CBA or a standard decision list classifier is used

Returns:
true if CBA is used, false otherwise

buildClassifier

public void buildClassifier(Instances newInstances)
                     throws java.lang.Exception
Generates the classifier.

Specified by:
buildClassifier in interface Classifier
Parameters:
newInstances - set of instances serving as training data
Throws:
java.lang.Exception - if the classifier has not been generated successfully

classifyInstance

public double classifyInstance(Instance instance)
                        throws java.lang.Exception
Classifies an instance

Specified by:
classifyInstance in interface Classifier
Overrides:
classifyInstance in class AbstractClassifier
Parameters:
instance - the instance
Returns:
the predicted class
Throws:
java.lang.Exception - exception if instance cannot be classified

distributionForInstance

public double[] distributionForInstance(Instance newInstance)
                                 throws java.lang.Exception
Returns the class distribution for an instance

Specified by:
distributionForInstance in interface Classifier
Overrides:
distributionForInstance in class AbstractClassifier
Parameters:
newInstance - the instance
Returns:
the class distribution
Throws:
java.lang.Exception - exception if it cannot be calculated

intermediateClassificationForInstance

public double intermediateClassificationForInstance(Instance instance,
                                                    JCBAPruning tree,
                                                    Instances instances)
                                             throws java.lang.Exception
Does the intermediate classification step during the CBA's obligatory pruning

Parameters:
instance - the instance to classifiy
tree - the actual CrTree with the actual rule set
instances - the instances
Returns:
the predicted class label
Throws:
java.lang.Exception - exception if instance cannot be classified

toString

public java.lang.String toString()
Prints the rules

Overrides:
toString in class java.lang.Object
Returns:
the rules

enumerateMeasures

public java.util.Enumeration enumerateMeasures()
Lists all additional statistics that are available

Specified by:
enumerateMeasures in interface AdditionalMeasureProducer
Returns:
list of the names of the additional measures

getMeasure

public double getMeasure(java.lang.String additionalMeasureName)
Gets the additional statistics

Specified by:
getMeasure in interface AdditionalMeasureProducer
Parameters:
additionalMeasureName - the name of the additional measure
Returns:
the value of the measure

measureMiningTime

public double measureMiningTime()
Gets the mining time

Returns:
the mining time in seconds

measurePruningTime

public double measurePruningTime()
Gets the pruning time in seconds

Returns:
the pruning time in seconds

measureNumMinedRules

public double measureNumMinedRules()
Gets the number of mined rules

Returns:
the number of mined rules

measureNumPrunedRules

public double measureNumPrunedRules()
Gets the number of rules after the optional pruning step

Returns:
the number of rules after the optional pruning step

measureNumClassRules

public double measureNumClassRules()
Gets the number of rules used for classification

Returns:
the number of rules used for classification

getRevision

public java.lang.String getRevision()
Returns the revision string.

Specified by:
getRevision in interface RevisionHandler
Overrides:
getRevision in class AbstractClassifier
Returns:
the revision

main

public static void main(java.lang.String[] argv)
Main method for testing this class.

Parameters:
argv - the options