mlrl.common.cython.rule_model module

@author Michael Rapp (michael.rapp.ml@gmail.com)

class mlrl.common.cython.rule_model.CompleteHead

Bases: object

A head of a rule that predicts for all available labels.

scores
class mlrl.common.cython.rule_model.ConjunctiveBody

Bases: object

A 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: object

A body of a rule that does not contain any conditions.

class mlrl.common.cython.rule_model.PartialHead

Bases: object

A head of a rule that predicts for a subset of the available labels.

indices
scores
class mlrl.common.cython.rule_model.RuleList

Bases: RuleModel

A 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: object

A 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

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.RuleModelVisitor

Bases: object

Defines 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.

abstract visit_complete_head(head: CompleteHead)

Must be implemented by subclasses in order to visit the heads of rules that predict for all available labels.

Parameters:

head – A CompleteHead to be visited

abstract 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

abstract 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

abstract visit_partial_head(head: PartialHead)

Must be implemented by subclasses in order to visit the heads of rules that predict for a subset of the available labels.

Parameters:

head – A PartialHead to be visited