com.rapidminer.operator.learner.rules
Class BestRuleInduction

java.lang.Object
  extended by com.rapidminer.tools.AbstractObservable<Operator>
      extended by com.rapidminer.operator.Operator
          extended by com.rapidminer.operator.learner.AbstractLearner
              extended by com.rapidminer.operator.learner.rules.BestRuleInduction
All Implemented Interfaces:
ConfigurationListener, PreviewListener, ResourceConsumer, CapabilityProvider, Learner, ParameterHandler, LoggingHandler, Observable<Operator>

public class BestRuleInduction
extends AbstractLearner

This operator returns the best rule regarding WRAcc using exhaustive search. Features like the incorporation of other metrics and the search for more than a single rule are prepared. The search strategy is BFS, with save pruning whenever applicable. This operator can easily be extended to support other search strategies.

Author:
Martin Scholz

Nested Class Summary
static class BestRuleInduction.RuleWithScoreUpperBound
          Helper class containing a rule and an upper bound for the score.
 
Field Summary
protected  ConjunctiveRuleModel bestRule
           
 
Fields inherited from interface com.rapidminer.operator.learner.CapabilityProvider
PROPERTY_RAPIDMINER_GENERAL_CAPABILITIES_WARN
 
Constructor Summary
BestRuleInduction(OperatorDescription description)
           
 
Method Summary
protected  boolean communicateToHighscore(ConjunctiveRuleModel rule, double[] counts)
          Adds a rule to the set of best rules if its score is high enough.
protected  ConjunctiveRuleModel getBestRule()
           
protected  double[] getCounts(ConjunctiveRuleModel rule, ExampleSet exampleSet)
           
 java.lang.Class<? extends PredictionModel> getModelClass()
          This method might be overridden from subclasses in order to specify exactly which model class they use.
protected  double getOptimisticScore(double[] counts)
          Computes the best possible score that might be achieved by refining the rule.
 java.util.List<ParameterType> getParameterTypes()
          Adds the parameters "number of iterations" and "model file".
protected  double getPruningScore()
           
protected  double getScore(double[] counts, boolean predictPositives)
          Computes the WRAcc or BINOMIAL TEST FUNCTION based on p, n, and the global values P and N stored in this object.
protected  void initHighscore()
           
 boolean isRefinementOfPrunedRule(ConjunctiveRuleModel rule)
           
 Model learn(ExampleSet exampleSet)
          Trains a model.
 boolean supportsCapability(OperatorCapability lc)
          Checks for Learner capabilities.
 
Methods inherited from class com.rapidminer.operator.learner.AbstractLearner
canCalculateWeights, canEstimatePerformance, doWork, doWork, getEstimatedPerformance, getExampleSetInputPort, getOptimizationPerformance, getWeightCalculationError, getWeights, getWeights, onlyWarnForNonSufficientCapabilities, shouldAutoConnect, shouldCalculateWeights, shouldDeliverOptimizationPerformance, shouldEstimatePerformance
 
Methods inherited from class com.rapidminer.operator.Operator
acceptsInput, addError, addError, addValue, addWarning, apply, apply, assumePreconditionsSatisfied, checkAll, checkAllExcludingMetaData, checkDeprecations, checkForStop, checkIO, checkProperties, clear, clearErrorList, cloneOperator, collectErrors, createExperimentTree, createExperimentTree, createFromXML, createFromXML, createFromXML, createMarkedExperimentTree, createMarkedProcessTree, createProcessTree, createProcessTree, disconnectPorts, execute, fireUpdate, freeMemory, getAddOnlyAdditionalOutput, getApplyCount, getCompatibilityLevel, getDeliveredOutputClasses, getDeprecationInfo, getDesiredInputClasses, getDOMRepresentation, getEncoding, getErrorList, getExecutionUnit, getExperiment, getIncompatibleVersionChanges, getInput, getInput, getInput, getInputClasses, getInputDescription, getInputPorts, getIODescription, getLog, getLogger, getName, getNumberOfBreakpoints, getOperatorClassName, getOperatorDescription, getOutputClasses, getOutputPorts, getParameter, getParameterAsBoolean, getParameterAsChar, getParameterAsColor, getParameterAsDouble, getParameterAsFile, getParameterAsFile, getParameterAsInputStream, getParameterAsInt, getParameterAsMatrix, getParameterAsRepositoryLocation, getParameterAsString, getParameterHandler, getParameterList, getParameters, getParameterTupel, getParameterType, getParent, getPortOwner, getProcess, getResourceConsumptionEstimator, getRoot, getStartTime, getTransformer, getUserDescription, getValue, getValues, getXML, getXML, getXML, hasBreakpoint, hasBreakpoint, hasInput, inApplyLoop, isDebugMode, isDirty, isEnabled, isExpanded, isParallel, isParameterSet, isRunning, log, log, logError, logNote, logWarning, lookupOperator, makeDirty, makeDirtyOnUpdate, notifyRenaming, performAdditionalChecks, preAutoWire, processFinished, processStarts, producesOutput, propagateDirtyness, register, registerOperator, remove, removeAndKeepConnections, rename, resume, setBreakpoint, setCompatibilityLevel, setEnabled, setEnclosingProcess, setExpanded, setInput, setListParameter, setPairParameter, setParameter, setParameters, setUserDescription, shouldAutoConnect, shouldStopStandaloneExecution, toString, transformMetaData, unregisterOperator, updateExecutionOrder, walk, writeXML, writeXML
 
Methods inherited from class com.rapidminer.tools.AbstractObservable
addObserver, addObserverAsFirst, fireUpdate, removeObserver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.rapidminer.operator.learner.Learner
getName
 

Field Detail

bestRule

protected ConjunctiveRuleModel bestRule
Constructor Detail

BestRuleInduction

public BestRuleInduction(OperatorDescription description)
Method Detail

supportsCapability

public boolean supportsCapability(OperatorCapability lc)
Description copied from interface: CapabilityProvider
Checks for Learner capabilities. Should return true if the given capability is supported.


initHighscore

protected void initHighscore()

communicateToHighscore

protected boolean communicateToHighscore(ConjunctiveRuleModel rule,
                                         double[] counts)
                                  throws UndefinedParameterError
Adds a rule to the set of best rules if its score is high enough. Currently just a single rule is stored. Additionally it is checked whether the rule is bad enough to be pruned.

Returns:
true iff the rule can be pruned
Throws:
UndefinedParameterError

getBestRule

protected ConjunctiveRuleModel getBestRule()
Returns:
the best rule found

getPruningScore

protected double getPruningScore()
Returns:
the lowest score of the stored best rules for pruning

learn

public Model learn(ExampleSet exampleSet)
            throws OperatorException
Description copied from interface: Learner
Trains a model. This method should be called by apply() and is implemented by subclasses.

Throws:
OperatorException

isRefinementOfPrunedRule

public boolean isRefinementOfPrunedRule(ConjunctiveRuleModel rule)
Parameters:
rule - a ConjuctiveRuleModel for which it is checked whether a more general rule has already been pruned.
Returns:
true, if this rule is a refinement of a pruned rule. The rules are compared using the method ConjunctiveRuleModel.isRefinementOf(ConjunctiveRuleModel model)

getScore

protected double getScore(double[] counts,
                          boolean predictPositives)
                   throws UndefinedParameterError
Computes the WRAcc or BINOMIAL TEST FUNCTION based on p, n, and the global values P and N stored in this object. First two entries of counts are p and n, optionally estimates for p and n can be supplied as further parameters.

Throws:
UndefinedParameterError

getOptimisticScore

protected double getOptimisticScore(double[] counts)
                             throws UndefinedParameterError
Computes the best possible score that might be achieved by refining the rule. During learning the conclusion is normalized to "positive", so the better of the estimates of the better conclusion is returned.

Throws:
UndefinedParameterError

getCounts

protected double[] getCounts(ConjunctiveRuleModel rule,
                             ExampleSet exampleSet)
                      throws OperatorException
Parameters:
rule - the rule to evaluate
exampleSet - the exampleSet to get the counts for
Returns:
a double[2] object, first parameter is p, second is n. If rule discovery relative to a predicted label is activated, then a double[4] is returned, which contains the estimated positives and negatives in the covered part as fields 3 and 4.
Throws:
OperatorException

getModelClass

public java.lang.Class<? extends PredictionModel> getModelClass()
Description copied from class: AbstractLearner
This method might be overridden from subclasses in order to specify exactly which model class they use. This is to ensure the proper postprocessing of some models like KernelModels (SupportVectorCounter) or TreeModels (Rule generation)

Overrides:
getModelClass in class AbstractLearner

getParameterTypes

public java.util.List<ParameterType> getParameterTypes()
Adds the parameters "number of iterations" and "model file".

Specified by:
getParameterTypes in interface ParameterHandler
Overrides:
getParameterTypes in class Operator


Copyright © 2001-2009 by Rapid-I