mlrl.common.cython.rule_model module¶
@author Michael Rapp (michael.rapp.ml@gmail.com)
- class mlrl.common.cython.rule_model.Body¶
Bases:
objectAn abstract base class for all bodies of a rule.
- class mlrl.common.cython.rule_model.Comparator(*values)¶
Bases:
StrEnumThe comparison operators that can be used by a condition of a rule.
- EQ = '=='¶
- GR = '>'¶
- LEQ = '<='¶
- NEQ = '!='¶
- class mlrl.common.cython.rule_model.CompleteHead¶
Bases:
HeadA head of a rule that predicts numerical scores for all available outputs.
- scores¶
- class mlrl.common.cython.rule_model.Condition(feature_index: int, comparator: Comparator, threshold: Number)¶
Bases:
objectA single condition contained in the body of a rule.
- Attributes:
feature_index: The index of the feature, the condition corresponds to comparator: The comparison operator that is used by the condition threshold: The threshold that is used by the condition
- comparator: Comparator¶
- class mlrl.common.cython.rule_model.ConjunctiveBody¶
Bases:
BodyA body of a rule that is given as a conjunction of several conditions.
- nominal_eq_indices¶
- nominal_eq_thresholds¶
- nominal_neq_indices¶
- nominal_neq_thresholds¶
- numerical_gr_indices¶
- numerical_gr_thresholds¶
- numerical_leq_indices¶
- numerical_leq_thresholds¶
- ordinal_gr_indices¶
- ordinal_gr_thresholds¶
- ordinal_leq_indices¶
- ordinal_leq_thresholds¶
- class mlrl.common.cython.rule_model.EmptyBody¶
Bases:
BodyA body of a rule that does not contain any conditions.
- class mlrl.common.cython.rule_model.Head¶
Bases:
objectAn abstract base class for all heads of a rule.
- class mlrl.common.cython.rule_model.PartialHead¶
Bases:
HeadA head of a rule that predicts numerical scores for a subset of the available outputs.
- indices¶
- scores¶
- class mlrl.common.cython.rule_model.Prediction(output_index: int, value: Number)¶
Bases:
objectA scalar value predicted by a rule for a specific output.
- Attributes:
output_index: The index of the output, the prediction corresponds to value: The predicted value
- class mlrl.common.cython.rule_model.Rule¶
Bases:
objectA single rule, consisting of a body and a head.
- body¶
- head¶
- class mlrl.common.cython.rule_model.RuleList¶
Bases:
RuleModelA rule-based model that stores several rules in an ordered list.
- contains_default_rule() bool¶
Returns whether the model contains a default rule or not.
- Returns:
True, if the model contains a default rule, False otherwise
- is_default_rule_taking_precedence() bool¶
Returns whether the default rule takes precedence over the remaining rules or not.
- Returns:
True, if the default rule takes precedence over the remaining rules, False otherwise
- visit(visitor: RuleModelVisitor)¶
Visits the bodies and heads of all rules that are contained in this model, including the default rule, if available.
- Parameters:
visitor – The RuleModelVisitor that should be used to access the bodies and heads
- visit_used(visitor: RuleModelVisitor)¶
Visits the bodies and heads of all used rules that are contained in this model, including the default rule, if available.
- Parameters:
visitor – The RuleModelVisitor that should be used to access the bodies and heads
- class mlrl.common.cython.rule_model.RuleModel¶
Bases:
objectA rule-based model.
- get_num_rules() int¶
Returns the total number of rules in the model, including the default rule, if available.
:return The total number of rules in the model
- get_num_used_rules() int¶
Returns the number of used rules in the model, including the default rule, if available.
:return The number of used rules in the model
- set_num_used_rules(num_used_rules: int)¶
Sets the number of used rules in the model, including the default rule, if available.
- Parameters:
num_used_rules – The number of used rules to be set
- abstractmethod visit(visitor: RuleModelVisitor)¶
Visits the bodies and heads of all rules that are contained in this model, including the default rule, if available.
- Parameters:
visitor – The RuleModelVisitor that should be used to access the bodies and heads
- abstractmethod visit_used(visitor: RuleModelVisitor)¶
Visits the bodies and heads of all used rules that are contained in this model, including the default rule, if available.
- Parameters:
visitor – The RuleModelVisitor that should be used to access the bodies and heads
- class mlrl.common.cython.rule_model.RuleModelVisitor¶
Bases:
objectDefines the methods that must be implemented by a visitor that accesses the bodies and heads of the rules in a rule-based model according to the visitor pattern.
- abstractmethod visit_complete_head(head: CompleteHead)¶
Must be implemented by subclasses in order to visit the heads of rules that predict numerical scores for all available outputs.
- Parameters:
head – A CompleteHead to be visited
- abstractmethod visit_conjunctive_body(body: ConjunctiveBody)¶
Must be implemented by subclasses in order to visit the bodies of rule that are given as a conjunction of several conditions.
- Parameters:
body – A ConjunctiveBody to be visited
- abstractmethod visit_empty_body(body: EmptyBody)¶
Must be implemented by subclasses in order to visit bodies of rules that do not contain any conditions.
- Parameters:
body – An EmptyBody to be visited
- abstractmethod visit_partial_head(head: PartialHead)¶
Must be implemented by subclasses in order to visit the heads of rules that predict numerical scores for a subset of the available outputs.
- Parameters:
head – A PartialHead to be visited