Saltar al contenido principal

RegressionPermutationFeatureImportance

GlobalExplainer
DashAI.back.explainability.explainers.RegressionPermutationFeatureImportance

Global permutation feature importance for regression models.

Measures the importance of each feature by randomly shuffling its values across the test set and recording the resulting decrease in a regression scoring metric (R2, negative MSE or negative MAE). Repeating the permutation n_repeats times yields a mean importance and standard deviation per feature. The method is model agnostic and computed on held out data.

References

  • [1] Breiman, L. (2001). "Random Forests." Machine Learning, 45(1), 5-32.
  • [2] Fisher, A. et al. (2019). "All Models are Wrong, but Many are Useful." JMLR, 20(177), 1-81. https://arxiv.org/abs/1801.01489

Parameters

scoring : string, default=r2
Regression metric used to evaluate how the model's performance changes when a particular feature is shuffled.
n_repeats : integer, default=10
Number of times to permute a feature.
random_state : integer, default=0
Seed for the random number generator to control permutations of each feature.
max_samples_fraction : number, default=1.0
Fraction of samples to draw from the test set to calculate feature importance at each repetition.

Methods

explain(self, dataset)

Defined on RegressionPermutationFeatureImportance

Compute permutation feature importance on the test split.

Parameters

dataset : Tuple[DatasetDict, DatasetDict]
A (x, y) pair where each element has at least a "test" split.

Returns

dict
Dictionary with keys "features", "importances_mean" and "importances_std".

plot(self, explanation: dict) -> List[DashAI.back.core.artifacts.Artifact]

Defined on RegressionPermutationFeatureImportance

Create a bar chart of feature importances.

Parameters

explanation : dict
Output of :meth:explain.

Returns

List[Artifact]
A list with a single plotly artifact holding the importance bar chart.

get_schema(cls) -> dict

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

validate_and_transform(self, raw_data: dict) -> dict

Defined on ConfigObject

It takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.

Parameters

raw_data : dict
A dictionary with the data provided by the user to initialize the model.

Returns

dict
A validated dictionary with the necessary objects.

Compatible with