weka.classifiers.rules
Class FR3

java.lang.Object
  extended by weka.classifiers.Classifier
      extended by weka.classifiers.SingleClassifierEnhancer
          extended by weka.classifiers.RandomizableSingleClassifierEnhancer
              extended by weka.classifiers.rules.FR3
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, PreferenceStructureHandler, weka.core.CapabilitiesHandler, weka.core.OptionHandler, weka.core.Randomizable, weka.core.RevisionHandler, weka.core.TechnicalInformationHandler, weka.core.WeightedInstancesHandler

public class FR3
extends weka.classifiers.RandomizableSingleClassifierEnhancer
implements weka.core.OptionHandler, weka.core.TechnicalInformationHandler, weka.core.WeightedInstancesHandler, PreferenceStructureHandler

FR3 - Fuzzy Round Robin Ripper
The FR3 algorithm is a pairwise classification algorithm which uses a modified version of the Ripper algorithm in combination with fuzzification techniques. The classification itself is achieved via pairwise preferences instead of voting.

BibTeX:

  @article{huehn2008,
    author = {Jens Christian Hühn and Eyke Hüllermeier},
    journal = {},
    title = {FR3: A Fuzzy Rule Learner for Inducing Reliable Classifiers},
    year = {2008}
 }
 

Valid options are:

 -d
  If set, the classifier will safe the binary models to the
  specified path after learning. When the first classification 
  is done, the models will be retrieved.
 -P <str>
  The path to which the models are saved.
  (default "./")
 -B
  If set, the classifier learns all n(n-1) models, otherwise it
  learns only one class per pair and thus n(n-1)/2 models
 -S <num>
  Random number seed.
  (default 1)
 -D
  If set, classifier is run in debug mode and
  may output additional info to the console
 -W
  Full name of base classifier.
  (default: weka.classifiers.rules.FRip)
 
 Options specific to classifier weka.classifiers.rules.FRip:
 
 -F <number of folds>
  Set number of folds for REP
  One fold is used as pruning set.
  (default 3)
 -N <min. weights>
  Set the minimal weights of instances
  within a split.
  (default 2.0)
 -O <number of runs>
  Set the number of runs of
  optimizations. (Default: 2)
 -D
  Set whether turn on the
  debug mode (Default: false)
 -S <seed>
  The seed of randomization
  (Default: 1)
 -E
  Whether NOT check the error rate>=0.5
  in stopping criteria  (default: check)
Date created: 08/07/2008

Version:
$Revision: 1.0 $
Author:
Jens Christian Hühn (huehn@gmx.net)
See Also:
Serialized Form

Field Summary
private  double[] aprioriClassDistribution
          An array which stores the class distribution of the training data
protected  weka.core.Attribute m_ClassAttribute
          Internal copy of the class attribute for output purposes
protected  weka.filters.Filter[] m_ClassFilters
          The filters used to transform the class.
 weka.classifiers.Classifier[] m_Classifiers
          The classifiers.
private  java.lang.String m_filenamePattern
          The filename which is used for pairwise models which are written to disk.
private  boolean m_filesWereLoaded
          A flag which shows that the saved models may have already been loaded to the RAM
protected  boolean m_learnBothModelsForEachPairOfClasses
          Switch which determines whether all n(n-1) models are learned or only n(n-1)/2 models.
private  java.lang.String m_modelSafePath
          The path to which the binary models are written
private  java.util.Random m_Random
          The random variable generator
private  boolean m_safeModelToDiskAfterLearning
          A switch which determines whether the binary models should be cached to the harddrive (to free RAM for other classifiers temporarily)
protected  weka.core.Instances m_TwoClassDataset
          A transformed dataset header used by the 1-against-1 method
private static long serialVersionUID
          for serialization
 
Fields inherited from class weka.classifiers.RandomizableSingleClassifierEnhancer
m_Seed
 
Fields inherited from class weka.classifiers.SingleClassifierEnhancer
m_Classifier
 
Fields inherited from class weka.classifiers.Classifier
m_Debug
 
Constructor Summary
FR3()
          Constructor.
 
Method Summary
 void buildClassifier(weka.core.Instances instances)
          Builds the classifiers.
 double classifyInstance(weka.core.Instance inst)
          Classifies an instance.
protected  java.lang.String defaultClassifierString()
          String describing default classifier.
 double[] distributionForInstance(weka.core.Instance inst)
          Predicts the class memberships for a given instance.
 weka.core.Capabilities getCapabilities()
          Returns default capabilities of the classifier.
 boolean getLearnBothModelsForEachPairOfClasses()
          Gets whether all n(n-1) models (true) or only the n(n-1)/2 models, which is one model per pair.
 java.lang.String getModelSafePath()
          Get the path to which the models are stored between learning and classification
 java.lang.String[] getOptions()
          Gets the current settings of the Classifier.
 java.lang.String getRevision()
          Returns the revision string.
 boolean getSafeModelToDiskAfterLearning()
          Gets whether the pairwise models should be safed to the harddrive after learning and be loaded upon classification
 weka.core.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.
 java.lang.String globalInfo()
          Returns a string describing classifier
 java.lang.String learnBothModelsForEachPairOfClassesTipText()
           
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options
private  weka.classifiers.Classifier loadModel(java.lang.String fileName)
          A function which loads a saved model from disk to memory.
static void main(java.lang.String[] argv)
          Main method for testing this class.
 java.lang.String modelSafePathTipText()
           
 double[][][] relationsForInstance(weka.core.Instance inst)
          Retrieves the preference, conflict and ignorance matrices for a single instance
 java.lang.String safeModelToDiskAfterLearningTipText()
           
 void saveModel(weka.classifiers.Classifier c, java.lang.String fileName)
          A function which saves a given model to disk
 void setLearnBothModelsForEachPairOfClasses(boolean b)
          Sets whether all n(n-1) models (true) or only the n(n-1)/2 models, which is one model per pair.
 void setModelSafePath(java.lang.String p)
          Set the path to which the models are stored between learning and classification
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 void setSafeModelToDiskAfterLearning(boolean b)
          Sets whether the pairwise models should be safed to the harddrive after learning and be loaded upon classification
 java.lang.String toString()
          Prints the classifiers.
 
Methods inherited from class weka.classifiers.RandomizableSingleClassifierEnhancer
getSeed, seedTipText, setSeed
 
Methods inherited from class weka.classifiers.SingleClassifierEnhancer
classifierTipText, getClassifier, getClassifierSpec, setClassifier
 
Methods inherited from class weka.classifiers.Classifier
debugTipText, forName, getDebug, makeCopies, makeCopy, runClassifier, setDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
for serialization

See Also:
Constant Field Values

m_Classifiers

public weka.classifiers.Classifier[] m_Classifiers
The classifiers.


m_ClassFilters

protected weka.filters.Filter[] m_ClassFilters
The filters used to transform the class.


m_ClassAttribute

protected weka.core.Attribute m_ClassAttribute
Internal copy of the class attribute for output purposes


m_TwoClassDataset

protected weka.core.Instances m_TwoClassDataset
A transformed dataset header used by the 1-against-1 method


m_learnBothModelsForEachPairOfClasses

protected boolean m_learnBothModelsForEachPairOfClasses
Switch which determines whether all n(n-1) models are learned or only n(n-1)/2 models.


aprioriClassDistribution

private double[] aprioriClassDistribution
An array which stores the class distribution of the training data


m_safeModelToDiskAfterLearning

private boolean m_safeModelToDiskAfterLearning
A switch which determines whether the binary models should be cached to the harddrive (to free RAM for other classifiers temporarily)


m_modelSafePath

private java.lang.String m_modelSafePath
The path to which the binary models are written


m_filesWereLoaded

private boolean m_filesWereLoaded
A flag which shows that the saved models may have already been loaded to the RAM


m_filenamePattern

private java.lang.String m_filenamePattern
The filename which is used for pairwise models which are written to disk.


m_Random

private java.util.Random m_Random
The random variable generator

Constructor Detail

FR3

public FR3()
Constructor.

Method Detail

defaultClassifierString

protected java.lang.String defaultClassifierString()
String describing default classifier.

Overrides:
defaultClassifierString in class weka.classifiers.SingleClassifierEnhancer
Returns:
the default classifier classname

getCapabilities

public weka.core.Capabilities getCapabilities()
Returns default capabilities of the classifier.

Specified by:
getCapabilities in interface weka.core.CapabilitiesHandler
Overrides:
getCapabilities in class weka.classifiers.SingleClassifierEnhancer
Returns:
the capabilities of this classifier
See Also:
Capabilities

getTechnicalInformation

public weka.core.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 weka.core.TechnicalInformationHandler
Returns:
the technical information about this class

buildClassifier

public void buildClassifier(weka.core.Instances instances)
                     throws java.lang.Exception
Builds the classifiers.

Specified by:
buildClassifier in class weka.classifiers.Classifier
Parameters:
instances - the training data.
Throws:
java.lang.Exception - if a classifier can't be built

distributionForInstance

public double[] distributionForInstance(weka.core.Instance inst)
                                 throws java.lang.Exception
Description copied from class: weka.classifiers.Classifier
Predicts the class memberships for a given instance. If an instance is unclassified, the returned array elements must be all zero. If the class is numeric, the array must consist of only one element, which contains the predicted value. Note that a classifier MUST implement either this or classifyInstance().

Overrides:
distributionForInstance in class weka.classifiers.Classifier
Parameters:
inst - the instance to be classified
Returns:
an array containing the estimated membership probabilities of the test instance in each class or the numeric prediction
Throws:
java.lang.Exception - if distribution could not be computed successfully

classifyInstance

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

Overrides:
classifyInstance in class weka.classifiers.Classifier
Parameters:
inst - the instance to classify
Returns:
the classification
Throws:
java.lang.Exception - if instance can't be classified successfully

relationsForInstance

public double[][][] relationsForInstance(weka.core.Instance inst)
                                  throws java.lang.Exception
Retrieves the preference, conflict and ignorance matrices for a single instance

Specified by:
relationsForInstance in interface PreferenceStructureHandler
Parameters:
inst - The instance for which the PCI-matrices shall be created
Returns:
[0][][] preference matrix, [1][][] conflict matrix, [2][][] ignorance matrix
Throws:
java.lang.Exception

toString

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

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the classifier

listOptions

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

Specified by:
listOptions in interface weka.core.OptionHandler
Overrides:
listOptions in class weka.classifiers.RandomizableSingleClassifierEnhancer
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:

 -d
  If set, the classifier will safe the binary models to the
  specified path after learning. When the first classification 
  is done, the models will be retrieved.
 -P <str>
  The path to which the models are saved.
  (default "./")
 -B
  If set, the classifier learns all n(n-1) models, otherwise it
  learns only one class per pair and thus n(n-1)/2 models
 -S <num>
  Random number seed.
  (default 1)
 -D
  If set, classifier is run in debug mode and
  may output additional info to the console
 -W
  Full name of base classifier.
  (default: weka.classifiers.rules.FRip)
 
 Options specific to classifier weka.classifiers.rules.FRip:
 
 -F <number of folds>
  Set number of folds for REP
  One fold is used as pruning set.
  (default 3)
 -N <min. weights>
  Set the minimal weights of instances
  within a split.
  (default 2.0)
 -O <number of runs>
  Set the number of runs of
  optimizations. (Default: 2)
 -D
  Set whether turn on the
  debug mode (Default: false)
 -S <seed>
  The seed of randomization
  (Default: 1)
 -E
  Whether NOT check the error rate>=0.5
  in stopping criteria  (default: check)

Specified by:
setOptions in interface weka.core.OptionHandler
Overrides:
setOptions in class weka.classifiers.RandomizableSingleClassifierEnhancer
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 weka.core.OptionHandler
Overrides:
getOptions in class weka.classifiers.RandomizableSingleClassifierEnhancer
Returns:
an array of strings suitable for passing to setOptions

safeModelToDiskAfterLearningTipText

public java.lang.String safeModelToDiskAfterLearningTipText()

setSafeModelToDiskAfterLearning

public void setSafeModelToDiskAfterLearning(boolean b)
Sets whether the pairwise models should be safed to the harddrive after learning and be loaded upon classification

Parameters:
b - true if the models shall be saved to disk

getSafeModelToDiskAfterLearning

public boolean getSafeModelToDiskAfterLearning()
Gets whether the pairwise models should be safed to the harddrive after learning and be loaded upon classification

Returns:
true if the models shall be saved to disk

learnBothModelsForEachPairOfClassesTipText

public java.lang.String learnBothModelsForEachPairOfClassesTipText()

getLearnBothModelsForEachPairOfClasses

public boolean getLearnBothModelsForEachPairOfClasses()
Gets whether all n(n-1) models (true) or only the n(n-1)/2 models, which is one model per pair.

Returns:
true for two models per pair, false for only one model for each pair

setLearnBothModelsForEachPairOfClasses

public void setLearnBothModelsForEachPairOfClasses(boolean b)
Sets whether all n(n-1) models (true) or only the n(n-1)/2 models, which is one model per pair.

Parameters:
b - true for two models per pair, false for only one model for each pair

modelSafePathTipText

public java.lang.String modelSafePathTipText()

setModelSafePath

public void setModelSafePath(java.lang.String p)
Set the path to which the models are stored between learning and classification

Parameters:
p - the path to which the models are strored

getModelSafePath

public java.lang.String getModelSafePath()
Get the path to which the models are stored between learning and classification

Returns:
the path to which the models are strored

globalInfo

public java.lang.String globalInfo()
Returns a string describing classifier

Returns:
a description suitable for displaying in the explorer/experimenter gui

loadModel

private weka.classifiers.Classifier loadModel(java.lang.String fileName)
                                       throws java.io.FileNotFoundException,
                                              java.io.IOException,
                                              java.lang.ClassNotFoundException
A function which loads a saved model from disk to memory. After loading the model, the file will be deleted.

Parameters:
fileName - The filename for the file in which the classifier is stored
Returns:
The loaded classifier
Throws:
java.io.FileNotFoundException
java.io.IOException
java.lang.ClassNotFoundException

saveModel

public void saveModel(weka.classifiers.Classifier c,
                      java.lang.String fileName)
               throws java.io.FileNotFoundException,
                      java.io.IOException
A function which saves a given model to disk

Parameters:
c - The classifier which shall be saved
fileName - The filename which describes the file in which the classifier is saved
Throws:
java.io.FileNotFoundException
java.io.IOException

main

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

Parameters:
argv - the options
Throws:
java.lang.Exception

getRevision

public java.lang.String getRevision()
Description copied from interface: weka.core.RevisionHandler
Returns the revision string.

Specified by:
getRevision in interface weka.core.RevisionHandler
Returns:
the revision