mlrl.boosting.cython.head_type module

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

class mlrl.boosting.cython.head_type.DynamicPartialHeadConfig

Bases: object

Allows to configure partial rule heads that predict for a subset of the available labels that is determined dynamically. Only those labels for which the square of the predictive quality exceeds a certain threshold are included in a rule head.

get_exponent() float

Sets the exponent that is used to weigh the estimated predictive quality for individual labels.

Returns:

The exponent that is used to weight the estimated predictive quality for individual labels

get_threshold() float

Returns the threshold that affects for how many labels the rule heads predict.

Returns:

The threshold that affects for how many labels the rule heads predict

set_exponent(exponent: float) DynamicPartialHeadConfig

Sets the exponent that should be used to weigh the estimated predictive quality for individual labels.

Parameters:

exponent – An exponent that should be used to weigh the estimated predictive quality for individual labels. E.g., an exponent of 2 means that the estimated predictive quality q for a particular label is weighed as q^2. Must be at least 1

Returns:

A DynamicPartialHeadConfig that allows further configuration of the rule heads

set_threshold(threshold: float) DynamicPartialHeadConfig

Sets the threshold that affects for how many labels the rule heads should predict.

Parameters:

threshold – A threshold that affects for how many labels the rule heads should predict. A smaller threshold results in less labels being selected. A greater threshold results in more labels being selected. E.g., a threshold of 0.2 means that a rule will only predict for a label if the estimated predictive quality q for this particular label satisfies the inequality q^exponent > q_best^exponent * (1 - 0.2), where q_best is the best quality among all labels. Must be in (0, 1)

Returns:

A DynamicPartialHeadConfig that allows further configuration of the rule heads

class mlrl.boosting.cython.head_type.FixedPartialHeadConfig

Bases: object

Allows to configure partial rule heads that predict for a predefined number of labels.

get_label_ratio() float

Returns the percentage that specifies for how many labels the rule heads predict.

Returns:

The percentage that specifies for how many labels the rule heads predict or 0, if the percentage is calculated based on the average label cardinality

get_max_labels() int

Returns the maximum number of labels for which the rule heads predict.

Returns:

The maximum number of labels for which the rule heads predict

get_min_labels() int

Returns the minimum number of labels for which the rule heads predict.

Returns:

The minimum number of labels for which the rule heads predict

set_label_ratio(label_ratio: float) FixedPartialHeadConfig

Sets the percentage that specifies for how many labels the rule heads should predict.

Parameters:

label_ratio – A percentage that specifies for how many labels the rule heads should predict, e.g., if 100 labels are available, a percentage of 0.5 means that the rule heads predict for a subset of ceil(0.5 * 100) = 50 labels. Must be in (0, 1) or 0, if the percentage should be calculated based on the average label cardinality

Returns:

A FixedPartialHeadConfig that allows further configuration of the rule heads

set_max_labels(max_labels: int) FixedPartialHeadConfig

Sets the maximum number of labels for which the rule heads should predict.

Parameters:

max_labels – The maximum number of labels for which the rule heads should predict. Must be at least the minimum number of labels or 0, if the maximum number of labels should not be restricted

Returns:

A FixedPartialHeadConfig that allows further configuration of the rule heads

set_min_labels(min_labels: int) FixedPartialHeadConfig

Sets the minimum number of labels for which the rule heads should predict.

Parameters:

min_labels – The minimum number of labels for which the rule heads should predict. Must be at least 2

Returns:

A FixedPartialHeadConfig that allows further configuration of the rule heads