Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial dependence plots #721

Merged
merged 119 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
4bf4e78
Partial API & docs
RobertSamoilescu Jul 6, 2022
7458993
included sanity checks, grid construction for both numerical and cate…
RobertSamoilescu Jul 11, 2022
82af3b1
Finalized explain and build_explanation. Included one feature numeric…
RobertSamoilescu Jul 12, 2022
3ebffe2
included kwargs for all kinds of plots
RobertSamoilescu Jul 12, 2022
372f824
Implemented plotting functionality for every feature types and combin…
RobertSamoilescu Jul 13, 2022
1eea980
Fixed share y axis
RobertSamoilescu Jul 13, 2022
14a4330
Minor plot fixes.
RobertSamoilescu Jul 15, 2022
3341e7b
Minor refactoring. Docstring for PartialDependece class
RobertSamoilescu Jul 15, 2022
7bbe01c
Docstring for plotting function. Minor grammar corrections.
RobertSamoilescu Jul 15, 2022
a1e84c5
Included test for sanity check. To be cleaned and optimized.
RobertSamoilescu Jul 15, 2022
418467f
Partial cleaning of the tests.
RobertSamoilescu Jul 15, 2022
7ac5e94
Finalized params sanity checks tests.
RobertSamoilescu Jul 18, 2022
5eb7d83
Included test for number of features.
RobertSamoilescu Jul 18, 2022
c410b5c
Test explanation shapes for numerical features.
RobertSamoilescu Jul 18, 2022
824ce7b
Included black-box wrapper for classification and regression & corres…
RobertSamoilescu Jul 18, 2022
adf50c7
Included a PD simple example.
RobertSamoilescu Jul 18, 2022
4a3289a
Included Adult example. Minor one way numerical plot fix for labels.
RobertSamoilescu Jul 19, 2022
658351e
Solved flak8 warnings
RobertSamoilescu Jul 19, 2022
233b6dc
Solved mypy errors.
RobertSamoilescu Jul 19, 2022
2a814ec
Improved docs for plots.
RobertSamoilescu Jul 19, 2022
5cf266d
Some comments and TODOs.
RobertSamoilescu Jul 19, 2022
d0255ab
included list of TODOs
RobertSamoilescu Jul 19, 2022
63a85d1
Consider by default all single features to compute the pd for.
RobertSamoilescu Jul 19, 2022
e24935d
Included custom grid_points.
RobertSamoilescu Jul 20, 2022
705435a
Updated categorical graph from barplot to lineplot.
RobertSamoilescu Jul 20, 2022
7bf1e50
Included two target outputs for binary classification when response_m…
RobertSamoilescu Jul 20, 2022
7723e2a
Solved flake8 warnings.
RobertSamoilescu Jul 20, 2022
f123d47
Solved mypy errors.
RobertSamoilescu Jul 20, 2022
5c2844f
isort and mypy
RobertSamoilescu Jul 21, 2022
3051dd6
Fixed fitted check for older versions of sklearn.
RobertSamoilescu Jul 21, 2022
347bdf5
Cleaned the docs for partial_dependence.py
RobertSamoilescu Jul 21, 2022
194bd7a
Tuple in numpy/list inconsistency
RobertSamoilescu Jul 21, 2022
f15d509
Reintroducing seaborn because of the heatmap
RobertSamoilescu Jul 21, 2022
d17184d
Introduced contour plots levels args.
RobertSamoilescu Jul 21, 2022
da7603a
minor changes to the docs
RobertSamoilescu Jul 21, 2022
b6b8745
Started pdp bike dataset example
RobertSamoilescu Jul 22, 2022
6abcbed
Included argument to display custom number of ice curves.
RobertSamoilescu Jul 22, 2022
6d3f896
Unfinished example PD bike dataset
RobertSamoilescu Jul 22, 2022
a5f6265
Finalized partial dependece bike example.
RobertSamoilescu Jul 25, 2022
29d3e13
Draft method description. Some variable renaming.
RobertSamoilescu Jul 25, 2022
f670f9e
Refactoring - explanation object.
RobertSamoilescu Jul 26, 2022
8640905
Updated docs entries.
RobertSamoilescu Jul 26, 2022
ecec1f4
Readme indentation
RobertSamoilescu Jul 26, 2022
5a48649
Merge remote-tracking branch 'upstream/master' into pdp
RobertSamoilescu Jul 26, 2022
3304293
setup.py minor correction
RobertSamoilescu Jul 26, 2022
6da29ce
Minor documentation corrections
RobertSamoilescu Jul 26, 2022
653c3f2
Removed initial pd exampled notebook
RobertSamoilescu Jul 26, 2022
67dce6f
Changed links to Introduction section
RobertSamoilescu Jul 26, 2022
4457f8a
Revert "Changed links to Introduction section"
RobertSamoilescu Jul 26, 2022
856c58b
Fix problem with equation in method docs
ascillitoe Jul 27, 2022
0511b94
Included test for pd computation against the sklearn implementation f…
RobertSamoilescu Aug 1, 2022
c717b2f
Addressed comments - part 1
RobertSamoilescu Aug 22, 2022
3681658
Addressed comments - part 2
RobertSamoilescu Aug 22, 2022
3ac73f6
Removed seed.
RobertSamoilescu Aug 22, 2022
c851f35
Included progress bar while explaining features
RobertSamoilescu Aug 22, 2022
ce94c35
A few changes to the pdp example notebook.
RobertSamoilescu Aug 22, 2022
185b535
Removed ipynb for examples.
RobertSamoilescu Aug 23, 2022
7402370
Addressed notebook comments.
RobertSamoilescu Aug 23, 2022
fd7e524
Addressed comments regarding the plots.
RobertSamoilescu Aug 23, 2022
8f59c7a
Removed meta from data field.
RobertSamoilescu Aug 23, 2022
3674b6d
Literal for some arguments
RobertSamoilescu Aug 23, 2022
1984d9f
Allow 2 way PDP for kind both. Improved method description. Cleaned e…
RobertSamoilescu Aug 23, 2022
e0115a5
Minor cleaning.
RobertSamoilescu Aug 23, 2022
3f10de9
Updated docs in the method description.
RobertSamoilescu Aug 23, 2022
33cb222
Corrections to the example text.
RobertSamoilescu Aug 23, 2022
d56485b
Minor punctuation correction in the method description.
RobertSamoilescu Aug 23, 2022
3d83197
Removed features_list from method notebook
RobertSamoilescu Aug 24, 2022
1b2b2c5
Merge remote-tracking branch 'upstream/master' into pdp
RobertSamoilescu Aug 24, 2022
6a56aed
Update link: latest with stable
RobertSamoilescu Aug 24, 2022
fcb4b05
Changed kernel env back to Python.
RobertSamoilescu Aug 24, 2022
6552f27
Minor docstrings correction.
RobertSamoilescu Aug 25, 2022
ae9e379
Fixed spelling error in example notebook.
RobertSamoilescu Aug 25, 2022
1610a50
Replaced centered with center. Improved docs for center flag.
RobertSamoilescu Aug 26, 2022
8301262
Removed seaborn from dependencies. Implemented on matplotlib heatmap.
RobertSamoilescu Aug 26, 2022
336cce0
Included clarification for the response_method.
RobertSamoilescu Aug 26, 2022
44c3688
Replaced sns heatmap plot with the matplotlib heatmap in method descr…
RobertSamoilescu Aug 26, 2022
18dfccc
Removed wget.
RobertSamoilescu Aug 27, 2022
2901f33
Fixed links. Moved model sanity check to constructor. Removed panadas…
RobertSamoilescu Aug 31, 2022
4b93136
Integrate sklearn pd functions. In progress...
RobertSamoilescu Aug 31, 2022
69ccaff
Removed sklearn private methods
RobertSamoilescu Aug 31, 2022
480ac12
Refactored blackbox case.
RobertSamoilescu Sep 1, 2022
52b142a
Updated method page.
RobertSamoilescu Sep 1, 2022
e7ccebf
Minor clarifications.
RobertSamoilescu Sep 1, 2022
cf1959a
Solved mypy issues.
RobertSamoilescu Sep 1, 2022
838dadf
Addressed minor comments.
RobertSamoilescu Sep 1, 2022
2fec6d3
Merge pull request #18 from RobertSamoilescu/pdp_v2
RobertSamoilescu Sep 1, 2022
ccad530
Minor correction for error messages and comments conventions.
RobertSamoilescu Sep 2, 2022
e0ca2cd
Fixed test from previous commit.
RobertSamoilescu Sep 2, 2022
1ad4a49
isort on utils/visualizations.py
RobertSamoilescu Sep 2, 2022
6c01dde
Fixed deciles computation.
RobertSamoilescu Sep 2, 2022
dcd413b
Fixed for binary classification.
RobertSamoilescu Sep 2, 2022
d7f0145
Add process pd and ice for plotting.
RobertSamoilescu Sep 2, 2022
bd9a494
Included warning for the length.
RobertSamoilescu Sep 2, 2022
b34366e
Removed auto options
RobertSamoilescu Sep 2, 2022
bd4960e
Removed auto. Fixed tests and docs.
RobertSamoilescu Sep 2, 2022
9cfbd39
Minor corrections.
RobertSamoilescu Sep 2, 2022
46c934c
Revert to deciles on full dataset
RobertSamoilescu Sep 2, 2022
7e96b7c
Changed a few error messages. Included one test for unknown kind.
RobertSamoilescu Sep 2, 2022
8ebb138
Improved error messages and included a warning for target_names
RobertSamoilescu Sep 2, 2022
b7751e1
Removed blank lines.
RobertSamoilescu Sep 2, 2022
8d967be
Fixed tests.
RobertSamoilescu Sep 2, 2022
e519d16
Split inital implementation into PartialDependence and TreePartialDep…
RobertSamoilescu Sep 3, 2022
3f6b98e
Fixed tests.
RobertSamoilescu Sep 3, 2022
9f10675
Isort and removed unnecessary fixture from conftest.py
RobertSamoilescu Sep 3, 2022
254c2a8
Updated PD example.
RobertSamoilescu Sep 3, 2022
75a0fab
Updated method description.
RobertSamoilescu Sep 3, 2022
c6ef875
Removed uncessary classes and imports.
RobertSamoilescu Sep 3, 2022
0a32f1c
Minor doc updates. Minor sanity checks refactoring.
RobertSamoilescu Sep 3, 2022
9373e6a
Improved docs for TreePartialDependence.
RobertSamoilescu Sep 4, 2022
c4e4aa7
Included ABC for the base class and removed for the derived one.
RobertSamoilescu Sep 5, 2022
a978b61
Fixed deciles display
RobertSamoilescu Sep 5, 2022
68e5694
Improved plots by adding pd limits
RobertSamoilescu Sep 5, 2022
c5388ac
Fixed min-max pd plots for share_y.
RobertSamoilescu Sep 5, 2022
f545ec7
Improved plots: zoom in for num and cat plots, add decile ticks for n…
RobertSamoilescu Sep 5, 2022
2064b1e
Solved minor display bug in num-cat for deciles.
RobertSamoilescu Sep 5, 2022
754cee0
Updated linear regression plots.
RobertSamoilescu Sep 5, 2022
b7bb87b
Minor docstrings correction: pairs of features -> tuples of features.
RobertSamoilescu Sep 6, 2022
115fc7d
Merge pull request #19 from RobertSamoilescu/pdp_v3
RobertSamoilescu Sep 7, 2022
79d2c43
Removed unnecessary argument in _compute_pd_limits and updated return…
RobertSamoilescu Sep 9, 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
4 changes: 2 additions & 2 deletions alibi/explainers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from alibi.explainers.anchors.anchor_image import AnchorImage
from alibi.explainers.cfrl_base import CounterfactualRL
from alibi.explainers.cfrl_tabular import CounterfactualRLTabular
from alibi.explainers.partial_dependence import PartialDependence, plot_pd
from alibi.explainers.partial_dependence import PartialDependence, TreePartialDependence, plot_pd
from alibi.explainers.similarity.grad import GradientSimilarity


Expand Down Expand Up @@ -50,7 +50,7 @@
"CounterfactualRLTabular",
"plot_ale",
"PartialDependence",
"PDEstimatorWrapper",
"TreePartialDependence",
"plot_pd",
"IntegratedGradients",
"KernelShap",
Expand Down
1,250 changes: 758 additions & 492 deletions alibi/explainers/partial_dependence.py

Large diffs are not rendered by default.

32 changes: 0 additions & 32 deletions alibi/explainers/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from sklearn.linear_model import LogisticRegression, LinearRegression
from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
from sklearn.svm import SVC

from alibi.explainers import ALE
from alibi.explainers import AnchorTabular
Expand Down Expand Up @@ -90,37 +89,6 @@ def movie_sentiment_data():
# ble to parametrize with module name and param dict to have only 1
# such fixture

@pytest.fixture(scope='module')
def svc_classifier(request):
"""
Trains a support vector classifier. Because it is scoped
at module level, the state of this fixture should not be
mutated during test - if you need to do so, please copy the
objects returned.
"""

is_preprocessor = False
preprocessor = None
# this fixture should be parametrised with a fixture that
# returns a dataset dictionary with specified attributes
# see test_anchor_tabular for a usage example
data = request.param

if data['preprocessor']:
is_preprocessor = True
preprocessor = data['preprocessor']

np.random.seed(0)
clf = SVC()

if is_preprocessor:
clf.fit(preprocessor.transform(data['X_train']), data['y_train'])
else:
clf.fit(data['X_train'], data['y_train'])

return clf, preprocessor


@pytest.fixture(scope='module')
def rf_classifier(request):
"""
Expand Down
Loading