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, start=None, end=None, transactions=None)
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.
start (datetime) – Start timestamp for filtering time series data.
end (datetime) – End timestamp for filtering time series data.
transactions (pd.DataFrame) – Transaction data for calculating time-based feature bounds.
- Returns:
A list of rules constructed from the solution and features.
- Return type:
list
- niaarmts.rule.calculate_border(feature_min, feature_max, value)
Calculate the border (threshold) value for a numerical or time series feature.
- Parameters:
feature_min (float) – Minimum value of the feature.
feature_max (float) – Maximum value of the feature.
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.
- Parameters:
features (dict) – The dictionary containing metadata about the features.
feature_name (str) – The name of the feature to find the position for.
- Returns:
The position of the feature in the solution vector.
- Return type:
int