weka.classifiers.rules
Class Prism

java.lang.Object
  extended byweka.classifiers.Classifier
      extended byweka.classifiers.rules.Prism
All Implemented Interfaces:
java.lang.Cloneable, OptionHandler, java.io.Serializable

public class Prism
extends Classifier

Class for building and using a PRISM rule set for classifcation. Can only deal with nominal attributes. Can't deal with missing values. Doesn't do any pruning. For more information, see

J. Cendrowska (1987). PRISM: An algorithm for inducing modular rules. International Journal of Man-Machine Studies. Vol.27, No.4, pp.349-370.

Version:
$Revision: 1.16 $
Author:
Ian H. Witten (ihw@cs.waikato.ac.nz)
See Also:
Serialized Form

Nested Class Summary
private  class Prism.PrismRule
          Class for storing a PRISM ruleset, i.e. a list of rules
private  class Prism.Test
          Class for storing a list of attribute-value tests
 
Field Summary
private  Prism.PrismRule m_rules
          The first rule in the list of rules
 
Fields inherited from class weka.classifiers.Classifier
m_Debug
 
Constructor Summary
Prism()
           
 
Method Summary
private  Prism.PrismRule addRule(Prism.PrismRule lastRule, Prism.PrismRule newRule)
          Add a rule to the ruleset.
private  Prism.Test addTest(Prism.PrismRule rule, Prism.Test lastTest, Prism.Test newTest)
          Add a test to this rule.
 void buildClassifier(Instances data)
          Generates the classifier.
 double classifyInstance(Instance inst)
          Classifies a given instance.
private static boolean contains(Instances E, int C)
          Does E contain any examples in the class C?
 java.lang.String globalInfo()
          Returns a string describing classifier
private static boolean isMentionedIn(Attribute attr, Prism.Test t)
          Is this attribute mentioned in the rule?
static void main(java.lang.String[] args)
          Main method for testing this class
 java.lang.String toString()
          Prints a description of the classifier.
 
Methods inherited from class weka.classifiers.Classifier
debugTipText, distributionForInstance, forName, getDebug, getOptions, listOptions, makeCopies, setDebug, setOptions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_rules

private Prism.PrismRule m_rules
The first rule in the list of rules

Constructor Detail

Prism

public Prism()
Method Detail

globalInfo

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

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

classifyInstance

public double classifyInstance(Instance inst)
Classifies a given instance.

Overrides:
classifyInstance in class Classifier
Parameters:
inst - the instance to be classified
Returns:
the classification

buildClassifier

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

Specified by:
buildClassifier in class Classifier
Parameters:
data - the data to be used
Throws:
java.lang.Exception - if the classifier can't built successfully

addRule

private Prism.PrismRule addRule(Prism.PrismRule lastRule,
                                Prism.PrismRule newRule)
Add a rule to the ruleset.

Parameters:
lastRule - the last rule in the rule set
newRule - the rule to be added
Returns:
the new last rule in the rule set

addTest

private Prism.Test addTest(Prism.PrismRule rule,
                           Prism.Test lastTest,
                           Prism.Test newTest)
Add a test to this rule.

Parameters:
rule - the rule to which test is to be added
lastTest - the rule's last test
newTest - the test to be added
Returns:
the new last test of the rule

contains

private static boolean contains(Instances E,
                                int C)
                         throws java.lang.Exception
Does E contain any examples in the class C?

Parameters:
E - the instances to be checked
C - the class
Returns:
true if there are any instances of class C
Throws:
java.lang.Exception

isMentionedIn

private static boolean isMentionedIn(Attribute attr,
                                     Prism.Test t)
Is this attribute mentioned in the rule?

Parameters:
attr - the attribute to be checked for
t - test contained by rule

toString

public java.lang.String toString()
Prints a description of the classifier.

Returns:
a description of the classifier as a string

main

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