Skip to content

Threshold

Threshold

Bases: Activation

Activation method that activates the rules whose activation degrees satisfy the comparison operator and the threshold, and deactivates the rest.

related

Attributes

comparator instance-attribute

comparator = comparator

threshold instance-attribute

threshold = threshold

Classes

Comparator

Bases: Enum

Six comparison operators between the activation degree \(a\) and the threshold \(\theta\).

Attributes
EqualTo class-attribute instance-attribute
EqualTo = '=='
GreaterThan class-attribute instance-attribute
GreaterThan = '>'
GreaterThanOrEqualTo class-attribute instance-attribute
GreaterThanOrEqualTo = '>='
LessThan class-attribute instance-attribute
LessThan = '<'
LessThanOrEqualTo class-attribute instance-attribute
LessThanOrEqualTo = '<='
NotEqualTo class-attribute instance-attribute
NotEqualTo = '!='
__operator__ class-attribute instance-attribute
__operator__: dict[str, Callable[[Scalar, Scalar], bool | Array[bool_]]] = {
    LessThan: lt,
    LessThanOrEqualTo: le,
    EqualTo: eq,
    NotEqualTo: ne,
    GreaterThanOrEqualTo: ge,
    GreaterThan: gt,
}
operator property
operator: Callable[[Scalar, Scalar], bool | Array[bool_]]

Return the function reference for the operator.

Returns:

Type Description
Callable[[Scalar, Scalar], bool | Array[bool_]]

function reference for the operator.

Functions
__repr__
__repr__() -> str

Return the code to construct the comparator in Python.

Returns:

Type Description
str

code to construct the comparator in Python.

Functions

__init__

__init__(comparator: Comparator | str = Comparator.GreaterThan, threshold: float = 0.0) -> None

Constructor.

Parameters:

Name Type Description Default
comparator Comparator | str

comparison operator

GreaterThan
threshold float

value for activation degrees.

0.0

activate

activate(rule_block: RuleBlock) -> None

Activates the rules whose activation degrees satisfy the comparator and threshold, and deactivate the rest.

Parameters:

Name Type Description Default
rule_block RuleBlock

rule block to activate.

required

configure

configure(parameters: str) -> None

Configure the activation method with the parameters.

Parameters:

Name Type Description Default
parameters str

comparator and threshold (eg, > 0.5).

required

parameters

parameters() -> str

Return the comparator and threshold.

Returns:

Type Description
str

comparator and threshold.