com.rapidminer.operator.learner.rules
Class ConjunctiveRuleModel

java.lang.Object
  extended by com.rapidminer.operator.AbstractIOObject
      extended by com.rapidminer.operator.ResultObjectAdapter
          extended by com.rapidminer.operator.AbstractModel
              extended by com.rapidminer.operator.learner.PredictionModel
                  extended by com.rapidminer.operator.learner.SimplePredictionModel
                      extended by com.rapidminer.operator.learner.rules.ConjunctiveRuleModel
All Implemented Interfaces:
IOObject, Model, ResultObject, Saveable, Readable, Reportable, LoggingHandler, java.io.Serializable

public class ConjunctiveRuleModel
extends SimplePredictionModel

Each object of this class represents a conjunctive rule with boolean target and nominal attributes. It cannot be changed after construction. This simplifies applications that maintain counts separately. Each attribute may be tested at most once. For two rules it can be tested whether one subsumes the other. A method for refinement allows to create each rule just once. This model may be used to query for the prediction of a single example, as well as to predict complete ExampleSets.

Author:
Martin Scholz Exp $
See Also:
Serialized Form

Constructor Summary
ConjunctiveRuleModel(ConjunctiveRuleModel ruleToExtend, Attribute attribute, double testValue)
          Constructor to create an empty rule that makes a default prediction
ConjunctiveRuleModel(ConjunctiveRuleModel ruleToClone, int predictedLabel)
          Constructor to clone a rule, but to change the head (prediction)
ConjunctiveRuleModel(ExampleSet exampleSet, int predictedLabel)
          Constructor to create an empty rule that makes a default prediction
ConjunctiveRuleModel(ExampleSet exampleSet, int predictedLabel, int positives, int negatives)
          Constructor to create an empty rule that makes a default prediction
 
Method Summary
 boolean equals(java.lang.Object object)
          Two rules are equal, if they are both permutations of the same set of literals and predict the same label.
 java.util.Collection<ConjunctiveRuleModel> getAllRefinedRules(ExampleSet exampleSet)
          A refinement method that - when applied sytematically during learning - generates all rules for nominal attributes and a boolean target exactly once.
 Attribute getAttributeOfLiteral(int literalNumber)
           
 int getConclusion()
           
protected  int getFirstUnusedAttribute(ExampleSet exampleSet, Attribute[] allAttributes)
          Helper method of getAllRefinedRules.
 int getPositionOfAttributeInRule(Attribute attribute)
           
 int getRuleLength()
           
 double getTestedValueAtLiteral(int literalNumber)
           
 int hashCode()
           
 boolean isRefinementOf(ConjunctiveRuleModel model)
           
 double predict(Example example)
          Applies the model to a single example and returns the predicted class value.
 java.lang.String toString()
           
 
Methods inherited from class com.rapidminer.operator.learner.SimplePredictionModel
performPrediction
 
Methods inherited from class com.rapidminer.operator.learner.PredictionModel
apply, checkCompatibility, copyPredictedLabel, createPredictedLabel, getLabel, removePredictedLabel, removePredictedLabel
 
Methods inherited from class com.rapidminer.operator.AbstractModel
getExtension, getFileDescription, getName, getResultIcon, getTrainingHeader, isUpdatable, setParameter, updateModel
 
Methods inherited from class com.rapidminer.operator.ResultObjectAdapter
addAction, getActions, getVisualizationComponent, isSavable, log, logError, logNote, logWarning, save, toHTML, toResultString
 
Methods inherited from class com.rapidminer.operator.AbstractIOObject
copy, getLog, getSource, initWriting, read, setLoggingHandler, setSource, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.rapidminer.operator.ResultObject
getActions, getVisualizationComponent, toResultString
 
Methods inherited from interface com.rapidminer.operator.IOObject
copy, getLog, getSource, setLoggingHandler, setSource, write
 
Methods inherited from interface com.rapidminer.operator.Saveable
isSavable, save
 

Constructor Detail

ConjunctiveRuleModel

public ConjunctiveRuleModel(ExampleSet exampleSet,
                            int predictedLabel)
Constructor to create an empty rule that makes a default prediction

Parameters:
exampleSet - the example set used for training
predictedLabel - specifies the head of the rule, i.e. which label to predict

ConjunctiveRuleModel

public ConjunctiveRuleModel(ExampleSet exampleSet,
                            int predictedLabel,
                            int positives,
                            int negatives)
Constructor to create an empty rule that makes a default prediction

Parameters:
exampleSet - the example set used for training
predictedLabel - specifies the head of the rule, i.e. which label to predict

ConjunctiveRuleModel

public ConjunctiveRuleModel(ConjunctiveRuleModel ruleToClone,
                            int predictedLabel)
Constructor to clone a rule, but to change the head (prediction)


ConjunctiveRuleModel

public ConjunctiveRuleModel(ConjunctiveRuleModel ruleToExtend,
                            Attribute attribute,
                            double testValue)
                     throws OperatorException
Constructor to create an empty rule that makes a default prediction

Throws:
OperatorException
Method Detail

toString

public java.lang.String toString()
Specified by:
toString in interface Readable
Overrides:
toString in class PredictionModel
Returns:
a String representation of this rule model.

predict

public double predict(Example example)
               throws OperatorException
Description copied from class: SimplePredictionModel
Applies the model to a single example and returns the predicted class value.

Specified by:
predict in class SimplePredictionModel
Throws:
OperatorException

getRuleLength

public int getRuleLength()
Returns:
the number of literals

getConclusion

public int getConclusion()
Returns:
the label this rule predicts

getAttributeOfLiteral

public Attribute getAttributeOfLiteral(int literalNumber)
Parameters:
literalNumber - the number of the literal in the rule
Returns:
the attribute tested in the specified literal

getTestedValueAtLiteral

public double getTestedValueAtLiteral(int literalNumber)
Parameters:
literalNumber - the number of the literal in the rule
Returns:
the value an attribute needs to have in order to pass the test of the specified literal

getPositionOfAttributeInRule

public int getPositionOfAttributeInRule(Attribute attribute)
Parameters:
attribute - to look for in the conjunctive rule
Returns:
the position (which is unique) of the attribute in the (ordered) conjunctive rule, or -1, if the attribute has not been found

isRefinementOf

public boolean isRefinementOf(ConjunctiveRuleModel model)
Parameters:
model - another ConjuctiveRuleModel
Returns:
true, if this rule is a refinement of the specified rule, or if both rules are equal. A rule refines another one, if it conatains all of its lietrals and predicts the same label.

equals

public boolean equals(java.lang.Object object)
Two rules are equal, if they are both permutations of the same set of literals and predict the same label.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getFirstUnusedAttribute

protected int getFirstUnusedAttribute(ExampleSet exampleSet,
                                      Attribute[] allAttributes)
Helper method of getAllRefinedRules. Iterates through the Attributes of an ExampleSet and compares them to those part of the rule.

Parameters:
exampleSet -
Returns:
the index of the first attribute of the exampleSet that is not used in the rule, and for which no later Attribute is found in the rule, either.

getAllRefinedRules

public java.util.Collection<ConjunctiveRuleModel> getAllRefinedRules(ExampleSet exampleSet)
                                                              throws OperatorException
A refinement method that - when applied sytematically during learning - generates all rules for nominal attributes and a boolean target exactly once. The top-down refinement is compatible with pruning, as long as scores decrerase monotonically in support in the typical sense known from subgroup discovery. Attributes are added in the same order in which they occur in the provided exampleSet.

Parameters:
exampleSet - used to identify attributes and their values for refinement
Returns:
all refined ConjunctiveRuleModel objects
Throws:
OperatorException


Copyright © 2001-2009 by Rapid-I