Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a253639
centered pdp and ice plots
JoElfner Aug 31, 2020
6794530
tests corrected
JoElfner Aug 31, 2020
78fdb34
tests corrected again
JoElfner Aug 31, 2020
afa854e
Apply suggestions from code review
JoElfner Sep 2, 2020
915b5ac
function doc and whatsnew
JoElfner Sep 2, 2020
2028068
retract whatsnew and redo it
JoElfner Sep 3, 2020
d2c9458
Merge branch 'master' of https://github.com/JoElfner/scikit-learn int…
JoElfner Sep 3, 2020
3568521
testing for first y-val to be zero when centering
JoElfner Sep 3, 2020
9111514
test updated
JoElfner Sep 3, 2020
db08c81
redo of whatsnew
JoElfner Sep 4, 2020
8b06311
doc and examples updated
JoElfner Sep 4, 2020
97295c3
Update doc/modules/partial_dependence.rst
JoElfner Sep 9, 2020
d9d2a23
Merge remote-tracking branch 'origin/main' into pr/JoElfner/18310
glemaitre Jul 12, 2021
ded2726
TST additional test for limits and centered
glemaitre Jul 12, 2021
cb094ed
Merge remote-tracking branch 'origin/main' into pr/JoElfner/18310
glemaitre Jul 12, 2021
fb7ef3a
Revert examples
glemaitre Jul 12, 2021
a245b63
EXA add option centering
glemaitre Jul 12, 2021
cdb1d06
DOC improve referencing
glemaitre Jul 12, 2021
e358f35
TST fix test
glemaitre Jul 12, 2021
0269678
DOC fix docstring
glemaitre Jul 12, 2021
a35cfa2
DOC add information about deprecation removal
glemaitre Jul 13, 2021
dcf5c4b
Apply suggestions from code review
glemaitre Aug 31, 2021
df2eb83
merge origin/main
glemaitre Aug 31, 2021
a538c37
iter
glemaitre Aug 31, 2021
e1783aa
Merge remote-tracking branch 'origin/main' into pr/JoElfner/18310
glemaitre Apr 6, 2022
6e5a2bb
iter
glemaitre Apr 6, 2022
169c482
iter
glemaitre Apr 6, 2022
be7fa1f
iter
glemaitre Apr 6, 2022
8862056
update doc
glemaitre Apr 7, 2022
2eafb44
iter
glemaitre Apr 7, 2022
a1c9d6d
Apply suggestions from code review
glemaitre Apr 7, 2022
e2c91a6
add version removal pdp_lim
glemaitre Apr 7, 2022
6a7aecf
iter
glemaitre Apr 7, 2022
48d83e8
Update sklearn/inspection/_plot/partial_dependence.py
glemaitre Apr 7, 2022
916e675
iter
glemaitre Apr 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 32 additions & 16 deletions doc/modules/partial_dependence.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Partial dependence plots (PDP) and individual conditional expectation (ICE)
plots can be used to visualize and analyze interaction between the target
response [1]_ and a set of input features of interest.

Both PDPs and ICEs assume that the input features of interest are independent
from the complement features, and this assumption is often violated in practice.
Thus, in the case of correlated features, we will create absurd data points to
compute the PDP/ICE.
Both PDPs [H2009]_ and ICEs [G2015]_ assume that the input features of interest
are independent from the complement features, and this assumption is often
violated in practice. Thus, in the case of correlated features, we will
create absurd data points to compute the PDP/ICE [M2019]_.

Partial dependence plots
========================
Expand Down Expand Up @@ -164,6 +164,18 @@ PDPs. They can be plotted together with
... kind='both')
<...>

If there are too many lines in an ICE plot, it can be difficult to see
differences between individual samples and interpret the model. Centering the
ICE at the first value on the x-axis, produces centered Individual Conditional
Expectation (cICE) plots [G2015]_. This puts emphasis on the divergence of
individual conditional expectations from the mean line, thus making it easier
to explore heterogeneous relationships. cICE plots can be plotted by setting
`centered=True`:

>>> PartialDependenceDisplay.from_estimator(clf, X, features,
... kind='both', centered=True)
<...>

Mathematical Definition
=======================

Expand Down Expand Up @@ -255,15 +267,19 @@ estimators that support it, and 'brute' is used for the rest.

.. topic:: References

T. Hastie, R. Tibshirani and J. Friedman, `The Elements of
Statistical Learning <https://web.stanford.edu/~hastie/ElemStatLearn//>`_,
Second Edition, Section 10.13.2, Springer, 2009.

C. Molnar, `Interpretable Machine Learning
<https://christophm.github.io/interpretable-ml-book/>`_, Section 5.1, 2019.

A. Goldstein, A. Kapelner, J. Bleich, and E. Pitkin, :arxiv:`Peeking Inside the
Black Box: Visualizing Statistical Learning With Plots of Individual
Conditional Expectation <1309.6392>`,
Journal of Computational and Graphical Statistics, 24(1): 44-65, Springer,
2015.
.. [H2009] T. Hastie, R. Tibshirani and J. Friedman,
`The Elements of Statistical Learning
<https://web.stanford.edu/~hastie/ElemStatLearn//>`_,
Second Edition, Section 10.13.2, Springer, 2009.

.. [M2019] C. Molnar,
`Interpretable Machine Learning
<https://christophm.github.io/interpretable-ml-book/>`_,
Section 5.1, 2019.

.. [G2015] :arxiv:`A. Goldstein, A. Kapelner, J. Bleich, and E. Pitkin,
"Peeking Inside the Black Box: Visualizing Statistical
Learning With Plots of Individual Conditional Expectation"
Journal of Computational and Graphical Statistics,
24(1): 44-65, Springer, 2015.
<1309.6392>`
11 changes: 9 additions & 2 deletions doc/whats_new/v1.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -572,12 +572,19 @@ Changelog
:pr:`16061` by `Thomas Fan`_.

- |Enhancement| In
:meth:`~sklearn.inspection.PartialDependenceDisplay.from_estimator` and
:meth:`~sklearn.inspection.PartialDependenceDisplay.from_predictions`, allow
:meth:`inspection.PartialDependenceDisplay.from_estimator`, allow
`kind` to accept a list of strings to specify which type of
plot to draw for each feature interaction.
:pr:`19438` by :user:`Guillaume Lemaitre <glemaitre>`.

- |Enhancement| :meth:`inspection.PartialDependenceDisplay.from_estimator`,
:meth:`inspection.PartialDependenceDisplay.plot`, and
:func:`inspection.plot_partial_dependence` now support plotting centered
Individual Conditional Expectation (cICE) and centered PDP curves controlled
by setting the parameter `centered`.
:pr:`18310` by :user:`Johannes Elfner <JoElfner>` and
:user:`Guillaume Lemaitre <glemaitre>`.

:mod:`sklearn.isotonic`
.......................

Expand Down
18 changes: 13 additions & 5 deletions examples/inspection/plot_partial_dependence.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@

from sklearn.inspection import PartialDependenceDisplay

common_params = {"subsample": 50, "n_jobs": 2, "grid_resolution": 20, "random_state": 0}
common_params = {
"subsample": 50,
"n_jobs": 2,
"grid_resolution": 20,
"centered": True,
"random_state": 0,
}

print("Computing partial dependence plots...")
tic = time()
Expand Down Expand Up @@ -188,10 +194,12 @@
# rooms per household.
#
# The ICE curves (light blue lines) complement the analysis: we can see that
# there are some exceptions, where the house price remain constant with median
# income and average occupants. On the other hand, while the house age (top
# right) does not have a strong influence on the median house price on average,
# there seems to be a number of exceptions where the house price increase when
# there are some exceptions (which are better highlighted with the option
# `centered=True`), where the house price remains constant with respect to
# median income and average occupants variations.
# On the other hand, while the house age (top right) does not have a strong
# influence on the median house price on average, there seems to be a number
# of exceptions where the house price increases when
# between the ages 15-25. Similar exceptions can be observed for the average
# number of rooms (bottom left). Therefore, ICE plots show some individual
# effect which are attenuated by taking the averages.
Expand Down
Loading