Rule

niaarmts.rule.add_attribute(attributes, feature_name, feature_type, border1, border2, category)

Add a new attribute to the rule being constructed.

Parameters:
  • attributes (list) – The list of attributes constructed so far.

  • feature_name (str) – The name of the feature to add.

  • feature_type (str) – The type of the feature (Numerical, Categorical, etc.).

  • border1 (float) – Lower bound for numerical features (or 1.0 for categorical).

  • border2 (float) – Upper bound for numerical features (or 1.0 for categorical).

  • category (str) – The selected category for categorical features (or “EMPTY” for numerical).

Returns:

The updated list of attributes.

Return type:

list

niaarmts.rule.build_rule(solution, features, is_time_series=False)

Build association rules based on a given solution and feature metadata.

Parameters:
  • solution (list[float]) – The solution array containing encoded thresholds, permutations and feature values.

  • features (dict) – A dictionary where keys are feature names, and values contain metadata about the feature.

  • is_time_series (bool) – Whether the dataset contains time series data.

Returns:

A list of rules constructed from the solution and features.

Return type:

list

niaarmts.rule.calculate_border(feature_meta, value)

Calculate the border (threshold) value for a numerical or time series feature.

Parameters:
  • feature_meta (dict) – Metadata for the feature (including min/max values).

  • value (float) – The value to map to the feature’s range.

Returns:

The calculated border value.

Return type:

float

niaarmts.rule.calculate_selected_category(value, num_categories)

Calculate the index of the selected category based on the solution vector value.

Parameters:
  • value (float) – The encoded value representing a category.

  • num_categories (int) – The number of categories for the feature.

Returns:

The index of the selected category.

Return type:

int

niaarmts.rule.feature_position(features, feature_name)

Find the position of a feature in the solution vector based on its type. :param features: The dictionary containing metadata about the features. :type features: dict :param feature_name: The name of the feature to find the position for. :type feature_name: str

Returns:

The position of the feature in the solution vector.

Return type:

int