lux.metrics.stability
- lux.metrics.stability(rules_and_instances, dataset, features, categorical_indicator)
Calculate stability metrics for a set of rules and instances.
- Parameters:
rules_and_instances (pandas.DataFrame) – pandas.DataFrame A DataFrame containing rules and instances. It should include at least the following columns: - ‘true_class’: The true class label for each instance. - ‘explain_instance’: The explanation instance corresponding to each rule.
dataset (pandas.DataFrame) – pandas.DataFrame The dataset on which the rules are applied. It should be a pandas DataFrame.
features (list) – list A list of feature names in the dataset.
categorical_indicator (list) – list A list indicating whether each feature is categorical or not. Each element of the list corresponds to a feature in features, with True indicating the feature is categorical and False indicating it is not.
- Returns:
tuple of floats A tuple containing the following stability metrics: - Mean stability of rules for each true class label. - Mean standard deviation of stability for each true class label. - Mean feature Jaccard similarity coefficient between rules. - Standard deviation of feature Jaccard similarity coefficient between rules.
- Return type:
- Notes:
Stability is calculated based on the Jaccard similarity coefficient between rules applied to similar instances.
Feature Jaccard similarity coefficient measures the similarity of features between rules.
Large stability and low variance are desired for stable explanations.