holisticai.explainability.metrics.fluctuation_ratio#

holisticai.explainability.metrics.fluctuation_ratio(partial_dependencies: PartialDependence, importances: Importances | None = None, top_n=-1, label=0, weighted=False, aggregated=True)[source]#

Calculate the fluctuation ratio for features based on partial dependencies.

Parameters

partial_dependenciesPartialDependence

An object containing partial dependence values for features.

importancesOptional[Importances], default=None

A dictionary or similar structure containing feature importances. Required if weighted is True.

top_nint, default=-1

The number of top features to consider. If -1, all features are considered.

labelint, default=0

The label for which the partial dependencies are calculated.

weightedbool, default=False

If True, the fluctuation ratios are weighted by feature importances.

aggregatedbool, default=True

If True, return the aggregated fluctuation ratio. If False, return a DataFrame with individual fluctuation ratios.

Returns

float or pd.DataFrame

The aggregated fluctuation ratio if aggregated is True. Otherwise, a DataFrame with individual fluctuation ratios.