Skip to content

Commit

Permalink
MAINT change default value for min/max of IterativeImputer (scikit-le…
Browse files Browse the repository at this point in the history
  • Loading branch information
DarshanGowda0 authored and viclafargue committed Jun 26, 2020
1 parent 634541e commit be21886
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
9 changes: 9 additions & 0 deletions doc/whats_new/v0.24.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ Changelog
:mod:`sklearn.module`
.....................

:mod:`sklearn.impute`
.....................

- |Fix| replace the default values in :class:`impute.IterativeImputer`
of `min_value` and `max_value` parameters to `-np.inf` and `np.inf`,
respectively instead of `None`. However, the behaviour of the class does not
change since `None` was defaulting to these values already.
:pr:`16493` by :user:`Darshan N <DarshanGowda0>`.

:mod:`sklearn.model_selection`
..............................

Expand Down
16 changes: 8 additions & 8 deletions sklearn/impute/_iterative.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ class IterativeImputer(_BaseImputer):
many features with no missing values at both ``fit`` and ``transform``
time to save compute.
min_value : float or array-like of shape (n_features,), default=None.
min_value : float or array-like of shape (n_features,), default=-np.inf
Minimum possible imputed value. Broadcast to shape (n_features,) if
scalar. If array-like, expects shape (n_features,), one min value for
each feature. `None` (default) is converted to -np.inf.
each feature. The default is `-np.inf`.
max_value : float or array-like of shape (n_features,), default=None.
max_value : float or array-like of shape (n_features,), default=np.inf
Maximum possible imputed value. Broadcast to shape (n_features,) if
scalar. If array-like, expects shape (n_features,), one max value for
each feature. `None` (default) is converted to np.inf.
each feature. The default is `np.inf`.
verbose : int, default=0
Verbosity flag, controls the debug messages that are issued
Expand Down Expand Up @@ -218,8 +218,8 @@ def __init__(self,
initial_strategy="mean",
imputation_order='ascending',
skip_complete=False,
min_value=None,
max_value=None,
min_value=-np.inf,
max_value=np.inf,
verbose=0,
random_state=None,
add_indicator=False):
Expand Down Expand Up @@ -602,9 +602,9 @@ def fit_transform(self, X, y=None):
self.n_iter_ = 0
return super()._concatenate_indicator(Xt, X_indicator)

self._min_value = IterativeImputer._validate_limit(
self._min_value = self._validate_limit(
self.min_value, "min", X.shape[1])
self._max_value = IterativeImputer._validate_limit(
self._max_value = self._validate_limit(
self.max_value, "max", X.shape[1])

if not np.all(np.greater(self._max_value, self._min_value)):
Expand Down

0 comments on commit be21886

Please sign in to comment.