File rule_induction_top_down_greedy.hpp

class IGreedyTopDownRuleInductionConfig
#include <rule_induction_top_down_greedy.hpp>

Defines an interface for all classes that allow to configure an algorithm for the induction of individual rules that uses a greedy top-down search.

Subclassed by GreedyTopDownRuleInductionConfig

Public Functions

inline virtual ~IGreedyTopDownRuleInductionConfig()
virtual uint32 getMinCoverage() const = 0

Returns the minimum number of training examples that must be covered by a rule.

Returns:

The minimum number of training examples that must be covered by a rule

virtual IGreedyTopDownRuleInductionConfig &setMinCoverage(uint32 minCoverage) = 0

Sets the minimum number of training examples that must be covered by a rule.

Parameters:

minCoverage – The minimum number of training examples that must be covered by a rule. Must be at least 1

Returns:

A reference to an object of type IGreedyTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules

virtual float32 getMinSupport() const = 0

Returns the minimum support, i.e., the minimum fraction of the training examples that must be covered by a rule.

Returns:

The minimum support or 0, if the support of rules is not restricted

virtual IGreedyTopDownRuleInductionConfig &setMinSupport(float32 minSupport) = 0

Sets the minimum support, i.e., the minimum fraction of the training examples that must be covered by a rule.

Parameters:

minSupport – The minimum support. Must be in [0, 1] or 0, if the support of rules should not be restricted

Returns:

A reference to an object of type IGreedyTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules

virtual uint32 getMaxConditions() const = 0

Returns the maximum number of conditions to be included in a rule’s body.

Returns:

The maximum number of conditions to be included in a rule’s body or 0, if the number of conditions is not restricted

virtual IGreedyTopDownRuleInductionConfig &setMaxConditions(uint32 maxConditions) = 0

Sets the maximum number of conditions to be included in a rule’s body.

Parameters:

maxConditions – The maximum number of conditions to be included in a rule’s body. Must be at least 1 or 0, if the number of conditions should not be restricted

Returns:

A reference to an object of type IGreedyTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules

virtual uint32 getMaxHeadRefinements() const = 0

Returns the maximum number of times, the head of a rule may be refinement after a new condition has been added to its body.

Returns:

The maximum number of times, the head of a rule may be refined or 0, if the number of refinements is not restricted

virtual IGreedyTopDownRuleInductionConfig &setMaxHeadRefinements(uint32 maxHeadRefinements) = 0

Sets the maximum number of times, the head of a rule may be refined after a new condition has been added to its body.

Parameters:

maxHeadRefinements – The maximum number of times, the head of a rule may be refined. Must be at least 1 or 0, if the number of refinements should not be restricted

Returns:

A reference to an object of type IGreedyTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules

virtual bool arePredictionsRecalculated() const = 0

Returns whether the predictions of rules are recalculated on all training examples, if some of the examples have zero weights, or not.

Returns:

True, if the predictions of rules are recalculated on all training examples, false otherwise

virtual IGreedyTopDownRuleInductionConfig &setRecalculatePredictions(bool recalculatePredictions) = 0

Sets whether the predictions of rules should be recalculated on all training examples, if some of the examples have zero weights, or not.

Parameters:

recalculatePredictions – True, if the predictions of rules should be recalculated on all training examples, false otherwise

Returns:

A reference to an object of type IGreedyTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules

class GreedyTopDownRuleInductionConfig : public IRuleInductionConfig, public IGreedyTopDownRuleInductionConfig
#include <rule_induction_top_down_greedy.hpp>

Allows to configure an algorithm for the induction of individual rules that uses a greedy top-down search.

Public Functions

GreedyTopDownRuleInductionConfig(RuleCompareFunction ruleCompareFunction, const std::unique_ptr<IMultiThreadingConfig> &multiThreadingConfigPtr)
Parameters:
  • ruleCompareFunction – An object of type RuleCompareFunction that defines the function that should be used for comparing the quality of different rules

  • multiThreadingConfigPtr – A reference to an unique pointer that stores the configuration of the multi-threading behavior that should be used for the parallel refinement of rules

virtual uint32 getMinCoverage() const override

Returns the minimum number of training examples that must be covered by a rule.

Returns:

The minimum number of training examples that must be covered by a rule

virtual IGreedyTopDownRuleInductionConfig &setMinCoverage(uint32 minCoverage) override

Sets the minimum number of training examples that must be covered by a rule.

Parameters:

minCoverage – The minimum number of training examples that must be covered by a rule. Must be at least 1

Returns:

A reference to an object of type IGreedyTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules

virtual float32 getMinSupport() const override

Returns the minimum support, i.e., the minimum fraction of the training examples that must be covered by a rule.

Returns:

The minimum support or 0, if the support of rules is not restricted

virtual IGreedyTopDownRuleInductionConfig &setMinSupport(float32 minSupport) override

Sets the minimum support, i.e., the minimum fraction of the training examples that must be covered by a rule.

Parameters:

minSupport – The minimum support. Must be in [0, 1] or 0, if the support of rules should not be restricted

Returns:

A reference to an object of type IGreedyTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules

virtual uint32 getMaxConditions() const override

Returns the maximum number of conditions to be included in a rule’s body.

Returns:

The maximum number of conditions to be included in a rule’s body or 0, if the number of conditions is not restricted

virtual IGreedyTopDownRuleInductionConfig &setMaxConditions(uint32 maxConditions) override

Sets the maximum number of conditions to be included in a rule’s body.

Parameters:

maxConditions – The maximum number of conditions to be included in a rule’s body. Must be at least 1 or 0, if the number of conditions should not be restricted

Returns:

A reference to an object of type IGreedyTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules

virtual uint32 getMaxHeadRefinements() const override

Returns the maximum number of times, the head of a rule may be refinement after a new condition has been added to its body.

Returns:

The maximum number of times, the head of a rule may be refined or 0, if the number of refinements is not restricted

virtual IGreedyTopDownRuleInductionConfig &setMaxHeadRefinements(uint32 maxHeadRefinements) override

Sets the maximum number of times, the head of a rule may be refined after a new condition has been added to its body.

Parameters:

maxHeadRefinements – The maximum number of times, the head of a rule may be refined. Must be at least 1 or 0, if the number of refinements should not be restricted

Returns:

A reference to an object of type IGreedyTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules

virtual bool arePredictionsRecalculated() const override

Returns whether the predictions of rules are recalculated on all training examples, if some of the examples have zero weights, or not.

Returns:

True, if the predictions of rules are recalculated on all training examples, false otherwise

virtual IGreedyTopDownRuleInductionConfig &setRecalculatePredictions(bool recalculatePredictions) override

Sets whether the predictions of rules should be recalculated on all training examples, if some of the examples have zero weights, or not.

Parameters:

recalculatePredictions – True, if the predictions of rules should be recalculated on all training examples, false otherwise

Returns:

A reference to an object of type IGreedyTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules

virtual std::unique_ptr<IRuleInductionFactory> createRuleInductionFactory(const IFeatureMatrix &featureMatrix, const ILabelMatrix &labelMatrix) const override

Creates and returns a new object of type IRuleInductionFactory according to the specified configuration.

Parameters:
  • featureMatrix – A reference to an object of type IFeatureMatrix that provides access to the feature values of the training examples

  • labelMatrix – A reference to an object of type ILabelMatrix that provides access to the labels of the training examples

Returns:

An unique pointer to an object of type IRuleInductionFactory that has been created

Private Members

const RuleCompareFunction ruleCompareFunction_
uint32 minCoverage_
float32 minSupport_
uint32 maxConditions_
uint32 maxHeadRefinements_
bool recalculatePredictions_
const std::unique_ptr<IMultiThreadingConfig> &multiThreadingConfigPtr_