Skip to content

Commit 1d13bd8

Browse files
Showcase at_step in example
1 parent c74ccbe commit 1d13bd8

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

examples/use_cases/plot_feature_importance.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -991,11 +991,17 @@ def add_y_true_pred(model_report, split):
991991
ridge_report.feature_importance.permutation(seed=0)
992992

993993
# %%
994-
# The permutation importance is often calculated several times, each time
995-
# with different permutations of the feature.
996-
# Hence, we can have measure its variance (or standard deviation).
997-
# Now, we plot the permutation feature importance on the train and test sets using boxplots:
994+
# By default, this computes the importance of the initial features; however, in some cases it make sense to compute the importance of the internal pipeline features, e.g. just before the actual prediction step:
995+
996+
# %%
997+
ridge_report.feature_importance.permutation(seed=0, at_step=-1)
998998

999+
# %%
1000+
# Note that the permutation importance involves permuting values of a feature at random, hence it is best to calculate it several times, each time with different permutations of the feature, and to aggregate the results.
1001+
# For this reason, if `seed` is not passed, skore does not cache the permutation importance.
1002+
1003+
# %%
1004+
# Now, we plot the permutation feature importance on the train and test sets using boxplots:
9991005

10001006
# %%
10011007

sphinx/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
sphinx_gallery_conf = {
9393
"examples_dirs": "../examples", # path to example scripts
9494
"gallery_dirs": "auto_examples", # path to gallery generated output
95-
"filename_pattern": "plot_", # pattern to select examples; change this to only build some of the examples
95+
"filename_pattern": "plot_feature", # pattern to select examples; change this to only build some of the examples
9696
"subsection_order": ExplicitOrder(subsections_order), # sorting gallery subsections
9797
# see https://sphinx-gallery.github.io/stable/configuration.html#sub-gallery-order
9898
"within_subsection_order": "ExampleTitleSortKey", # See https://sphinx-gallery.github.io/stable/configuration.html#sorting-gallery-examples for alternatives

0 commit comments

Comments
 (0)