impurity_decrease#

EstimatorReport.inspection.impurity_decrease()[source]#

Retrieve the Mean Decrease in Impurity (MDI) of a tree-based model.

This method is available for estimators that expose a feature_importances_ attribute. See for example sklearn.ensemble.GradientBoostingClassifier.feature_importances_.

In particular, note that the MDI is computed at fit time, i.e. using the training data.

Returns:
ImpurityDecreaseDisplay

The feature importance display containing the mean decrease in impurity.

Examples

>>> from sklearn.datasets import make_classification
>>> from sklearn.ensemble import RandomForestClassifier
>>> from skore import evaluate
>>> X, y = make_classification(n_features=5, random_state=42)
>>> forest = RandomForestClassifier(n_estimators=5, random_state=0)
>>> report = evaluate(forest, X, y, splitter=0.2)
>>> display = report.inspection.impurity_decrease()
>>> display.frame()
      feature  importance
0  Feature #0     0.10...
1  Feature #1     0.32...
2  Feature #2     0.08...
3  Feature #3     0.48...
4  Feature #4     0.00...