mlrl.common.cython.rule_induction module¶
@author: Michael Rapp (michael.rapp.ml@gmail.com)
- class mlrl.common.cython.rule_induction.BeamSearchTopDownRuleInductionConfig¶
Bases:
object
Allows to configure an algorithm for the induction of individual rules that uses a top-down beam search.
- are_features_resampled() bool ¶
Returns whether a new sample of the available features is created for each rule that is refined during the beam search or not.
- Returns:
True, if a new sample is created for each rule, false otherwise
- are_predictions_recalculated() bool ¶
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
- get_beam_width() int ¶
Returns the width that is used by the beam search.
- Returns:
The width that is used by the beam search
- get_max_conditions() int ¶
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
- get_max_head_refinements() int ¶
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
- get_min_coverage() int ¶
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
- get_min_support() float ¶
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
- set_beam_width(beam_width: int) BeamSearchTopDownRuleInductionConfig ¶
Sets the width that should be used by the beam search.
- Parameters:
beam_width – The width that should be used by the beam search. Must be at least 2
- Returns:
A BeamSearchTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules
- set_max_conditions(max_conditions: int) BeamSearchTopDownRuleInductionConfig ¶
Sets the maximum number of conditions to be included in a rule’s body.
- Parameters:
max_conditions – The maximum number of conditions to be included in a rule’s body. Must be at least 2 or 0, if the number of conditions should not be restricted
- Returns:
A BeamSearchTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules
- set_max_head_refinements(max_head_refinements: int) BeamSearchTopDownRuleInductionConfig ¶
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:
max_head_refinements – 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 BeamSearchTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules
- set_min_coverage(min_coverage: int) BeamSearchTopDownRuleInductionConfig ¶
Sets the minimum number of training examples that must be covered by a rule.
- Parameters:
min_coverage – The minimum number of training examples that must be covered by a rule. Must be at least 1
- Returns:
A BeamSearchTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules
- set_min_support(min_support: float) BeamSearchTopDownRuleInductionConfig ¶
Sets the minimum support, i.e., the minimum fraction of the training examples that must be covered by a rule.
- Parameters:
min_support – The minimum support. Must be in [0, 1] or 0, if the support of rules should not be restricted
- Returns:
A BeamSearchTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules
- set_recalculate_predictions(recalculate_predictions: bool) BeamSearchTopDownRuleInductionConfig ¶
Sets whether the predictions of rules should be recalculated on all training examples, if some of the examples have zero weights, or not.
- Parameters:
recalculate_predictions – True, if the predictions of rules should be recalculated on all training examples, False otherwise
- Returns:
A BeamSearchTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules
- set_resample_features(resample_features: bool) BeamSearchTopDownRuleInductionConfig ¶
Sets whether a new sample of the available features should be created for each rule that is refined during the beam search or not.
- Parameters:
resample_features – True, if a new sample should be created for each rule, false otherwise
- Returns:
A BeamSearchTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules
- class mlrl.common.cython.rule_induction.GreedyTopDownRuleInductionConfig¶
Bases:
object
Allows to configure an algorithm for the induction of individual rules that uses a greedy top-down search.
- are_predictions_recalculated() bool ¶
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
- get_max_conditions() int ¶
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
- get_max_head_refinements() int ¶
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
- get_min_coverage() int ¶
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
- get_min_support() float ¶
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
- set_max_conditions(max_conditions: int) GreedyTopDownRuleInductionConfig ¶
Sets the maximum number of conditions to be included in a rule’s body.
- Parameters:
max_conditions – 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 GreedyTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules
- set_max_head_refinements(max_head_refinements: int) GreedyTopDownRuleInductionConfig ¶
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:
max_head_refinements – 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 GreedyTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules
- set_min_coverage(min_coverage: int) GreedyTopDownRuleInductionConfig ¶
Sets the minimum number of training examples that must be covered by a rule.
- Parameters:
min_coverage – The minimum number of training examples that must be covered by a rule. Must be at least 1
- Returns:
A GreedyTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules
- set_min_support(min_support: float) GreedyTopDownRuleInductionConfig ¶
Sets the minimum support, i.e., the minimum fraction of the training examples that must be covered by a rule.
- Parameters:
min_support – The minimum support. Must be in [0, 1] or 0, if the support of rules should not be restricted
- Returns:
A GreedyTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules
- set_recalculate_predictions(recalculate_predictions: bool) GreedyTopDownRuleInductionConfig ¶
Sets whether the predictions of rules should be recalculated on all training examples, if some of the examples have zero weights, or not.
- Parameters:
recalculate_predictions – True, if the predictions of rules should be recalculated on all training examples, False otherwise
- Returns:
A GreedyTopDownRuleInductionConfig that allows further configuration of the algorithm for the induction of individual rules