All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.classifiers.rules.ConjunctiveRule

java.lang.Object
    |
    +----weka.classifiers.Classifier
            |
            +----weka.classifiers.DistributionClassifier
                    |
                    +----weka.classifiers.rules.ConjunctiveRule

public class ConjunctiveRule
extends DistributionClassifier
implements OptionHandler, WeightedInstancesHandler
This class implements a single conjunctive rule learner that can predict for numeric and nominal class labels.

A rule consists of antecedents "AND"ed together and the consequent (class value) for the classification/regression. In this case, the consequent is the distribution of the available classes (or numeric value) in the dataset. If the test instance is not covered by this rule, then it's predicted using the default class distributions/value of the data not covered by the rule in the training data.
This learner selects an antecedent by computing the Information Gain of each antecendent and prunes the generated rule using Reduced Error Prunning (REP).

For classification, the Information of one antecedent is the weighted average of the entropies of both the data covered and not covered by the rule.
For regression, the Information is the weighted average of the mean-squared errors of both the data covered and not covered by the rule.

In pruning, weighted average of accuracy rate of the pruning data is used for classification while the weighted average of the mean-squared errors of the pruning data is used for regression.

Version:
$Revision: 1.6 $

Constructor Index

 o ConjunctiveRule()
 

Method Index

 o buildClassifier(Instances)
Builds a single rule learner with REP dealing with nominal classes or numeric classes.
 o distributionForInstance(Instance)
Computes class distribution for the given instance.
 o getExclusive()
 
 o getFolds()
 
 o getMinNo()
 
 o getNumAntds()
 
 o getOptions()
Gets the current settings of the Classifier.
 o getRandomized()
 
 o getSeed()
 
 o hasAntds()
Whether this rule has antecedents, i.e.
 o isCover(Instance)
Whether the instance covered by this rule
 o listOptions()
Returns an enumeration describing the available options Valid options are:

-N number
Set number of folds for REP.

 o main(String[])
Main method.
 o setExclusive(boolean)
 
 o setFolds(int)
The access functions for parameters
 o setMinNo(double)
 
 o setNumAntds(int)
 
 o setOptions(String[])
Parses a given list of options.
 o setRandomized(boolean)
 
 o setSeed(long)
 
 o toString()
Prints this rule
 o toString(String, String)
Prints this rule with the specified class label

Constructor Detail

 o ConjunctiveRule
public ConjunctiveRule()

Method Detail

 o listOptions
public java.util.Enumeration listOptions()
          Returns an enumeration describing the available options Valid options are:

-N number
Set number of folds for REP. One fold is used as the pruning set. (Default: 3)

-R
Set if NOT randomize the data before split to growing and pruning data. If NOT set, the seed of randomization is specified by the -S option. (Default: randomize)

-S
Seed of randomization. (Default: 1)

-E
Set whether consider the exclusive expressions for nominal attribute split. (Default: false)

-M number
Set the minimal weights of instances within a split. (Default: 2)

-P number
Set the number of antecedents allowed in the rule if pre-pruning is used. If this value is other than -1, then pre-pruning will be used, otherwise the rule uses REP. (Default: -1)

Returns:
an enumeration of all the available options
 o setOptions
public void setOptions(java.lang.String options[]) throws java.lang.Exception
          Parses a given list of options.
Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported
 o getOptions
public java.lang.String[] getOptions()
          Gets the current settings of the Classifier.
Returns:
an array of strings suitable for passing to setOptions
 o setFolds
public void setFolds(int folds)
          The access functions for parameters
 o getFolds
public int getFolds()
 o setSeed
public void setSeed(long s)
 o getSeed
public long getSeed()
 o getRandomized
public boolean getRandomized()
 o setRandomized
public void setRandomized(boolean r)
 o getExclusive
public boolean getExclusive()
 o setExclusive
public void setExclusive(boolean e)
 o setMinNo
public void setMinNo(double m)
 o getMinNo
public double getMinNo()
 o setNumAntds
public void setNumAntds(int n)
 o getNumAntds
public int getNumAntds()
 o buildClassifier
public void buildClassifier(Instances instances) throws java.lang.Exception
          Builds a single rule learner with REP dealing with nominal classes or numeric classes. For nominal classes, this rule learner predicts a distribution on the classes. For numeric classes, this learner predicts a single value.
Parameters:
instances - the training data
Throws:
java.lang.Exception - if classifier can't be built successfully
Overrides:
buildClassifier in class Classifier
 o distributionForInstance
public double[] distributionForInstance(Instance instance) throws java.lang.Exception
          Computes class distribution for the given instance.
Parameters:
instance - the instance for which distribution is to be computed
Returns:
the class distribution for the given instance
Overrides:
distributionForInstance in class DistributionClassifier
 o isCover
public boolean isCover(Instance datum)
          Whether the instance covered by this rule
Parameters:
inst - the instance in question
Returns:
the boolean value indicating whether the instance is covered by this rule
 o hasAntds
public boolean hasAntds()
          Whether this rule has antecedents, i.e. whether it is a default rule
Returns:
the boolean value indicating whether the rule has antecedents
 o toString
public java.lang.String toString(java.lang.String att,
                       java.lang.String cl)
          Prints this rule with the specified class label
Parameters:
att - the string standing for attribute in the consequent of this rule
cl - the string standing for value in the consequent of this rule
Returns:
a textual description of this rule with the specified class label
 o toString
public java.lang.String toString()
          Prints this rule
Returns:
a textual description of this rule
Overrides:
toString in class java.lang.Object
 o main
public static void main(java.lang.String args[])
          Main method.
Parameters:
args - the options for the classifier

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home