8000 FIX: Fix for binary classifier prediction shape in partial dependence function by stephenpardy · Pull Request #30287 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content
Dismiss alert

FIX: Fix for binary classifier prediction shape in partial dependence function #30287

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Fixes an issue where the partial dependence function accidentally tries to select
positive class from binary predictions when they have already been selected.
By :user:`Stephen Pardy <stephenpardy>`
14 changes: 6 additions & 8 deletions sklearn/inspection/tests/test_partial_dependence.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,15 +739,13 @@ def test_partial_dependence_pipeline():


@pytest.mark.parametrize(
"features, grid_resolution, n_vals_expected",
"grid_resolution",
[
(["a"], 10, 10),
(["a"], 2, 2),
10,
2,
],
)
def test_partial_dependence_binary_model_grid_resolution(
features, grid_resolution, n_vals_expected
):
def test_partial_dependence_binary_model_grid_resolution(grid_resolution):
pd = pytest.importorskip("pandas")
model = DummyClassifier()

Expand All @@ -763,11 +761,11 @@ def test_partial_dependence_binary_model_grid_resolution(
part_dep = partial_dependence(
model,
X,
features=features,
features=["a"],
grid_resolution=grid_resolution,
kind="average",
)
assert part_dep["average"].size == n_vals_expected
assert part_dep["average"].size == grid_resolution


@pytest.mark.parametrize(
Expand Down
0