modeva.TestSuite.explain_pfi#

TestSuite.explain_pfi(dataset: str = 'test', sample_size: int = 5000, n_repeats: int = 10, random_state: int = 0)#

Calculate Permutation Feature Importance (PFI) for model features.

PFI measures feature importance by calculating the increase in model prediction error after permuting each feature’s values. A feature is considered important if permuting its values increases model error, indicating the model relied on that feature for prediction.

Parameters:
  • dataset ({"main", "train", "test"}, default="test") – Dataset to use for calculating the explanation results.

  • sample_size (int, default=5000) – Maximum number of random samples to use for calculation. If the dataset is larger, a random subset of this size will be used to improve computation speed. Set to None to use the entire dataset.

  • n_repeats (int, default=10) – Number of times to repeat the permutation process. Higher values give more reliable importance estimates but increase computation time.

  • random_state (int, default=0) – Random seed for reproducibility of permutations and sampling.

Returns:

A result object containing:

  • key: “explain_pfi”

  • data: Name of the dataset used

  • model: Name of the model used

  • inputs: Input parameters used for the analysis

  • value: Dictionary containing:

    • ”Name”: List of feature names

    • ”Importance”: List of corresponding feature importance values

  • table: DataFrame of feature importance results

  • options: Dictionary of visualizations configuration for a horizontal bar plot where x-axis is permutation feature importance, and y-axis is the feature name. Run results.plot() to show this plot.

Return type:

ValidationResult

Examples

Global Explainability

Global Explainability