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

[MRG] Fix FutureWarning in plot_partial_dependence_visualization_api.py #16256

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions sklearn/inspection/_partial_dependence.py
Expand Up @@ -25,7 +25,7 @@
from ..utils import _determine_key_type
from ..utils import _get_column_indices
from ..utils.validation import check_is_fitted
from ..tree._tree import DTYPE
from ..tree import DecisionTreeRegressor
from ..exceptions import NotFittedError
from ..ensemble._gb import BaseGradientBoosting
from sklearn.ensemble._hist_gradient_boosting.gradient_boosting import (
Expand Down Expand Up @@ -590,9 +590,11 @@ def plot_partial_dependence(estimator, X, features, feature_names=None,
from matplotlib import transforms # noqa
from matplotlib.ticker import MaxNLocator # noqa
from matplotlib.ticker import ScalarFormatter # noqa

# set target_idx for multi-class estimators
if hasattr(estimator, 'classes_') and np.size(estimator.classes_) > 2:
# TODO: Remove isinstance check in 0.24
ksslng marked this conversation as resolved.
Show resolved Hide resolved
if (not isinstance(estimator, DecisionTreeRegressor) and
hasattr(estimator, 'classes_') and
np.size(estimator.classes_) > 2):
if target is None:
raise ValueError('target must be specified for multi-class')
target_idx = np.searchsorted(estimator.classes_, target)
Expand Down