iguanas.rules
.ConvertProcessedConditionsToGeneral¶
- class iguanas.rules.ConvertProcessedConditionsToGeneral(imputed_values=None, ohe_categories=None)[source]¶
Converts the conditions of rules that utilise either imputed or OHE features into conditions that account for this for unprocessed data. This allows the rules to be applied to unprocessed data.
- Parameters
- imputed_valuesDict[str, Union[str, float]], optional
The value used to impute nulls (values) for each feature in the original, unprocessed dataset (keys). Providing this information converts conditions that include null values into two separate conditions - one for the numeric condition, one for the null condition. Defaults to None.
- ohe_categoriesDict[str, str], optional
The category (values) linked to each OHE column (keys). If the OHE column represents when null values are present, include this feature in the imputed_values parameter. Providing this information converts conditions that include OHE features into the general format - e.g. if a rule condition is X[‘ip_country_US’]==True, the converted condition will be X[‘ip_country’]==’US’. Defaults to None.
- Attributes
- rulesRules
Class containing the rule stored in the standard Iguanas string format. See the rules module for more information.
- convert(rule_strings: Dict[str, str], X=None) Dict[str, str] [source]¶
Converts the conditions of rules that utilise either imputed or OHE features into conditions that account for this for unprocessed data. This allows the rules to be applied to unprocessed data.
- Parameters
- rule_stringsDict[str, str]
Set of rules defined using the standard Iguanas string format (values) and their names (keys).
- XPandasDataFrameType, optional
The dataset containing the imputed variables. Required when imputed numeric variables are present in rules. Defaults to None.
- Returns
- Dict[str, str]
Set of generalised rules defined using the standard Iguanas string format.