Repository: scikit-learn/scikit-learn
Pull request: MAINT change default value for min/max of IterativeImputer
<!--
Thanks for contributing a pull request! Please ensure you have taken a look at
the contribution guidelines: https://github.com/scikit-learn/scikit-learn/blob/master/CONTRIBUTING.md#pull-request-checklist
-->

#### Reference Issues/PRs
<!--
Example: Fixes #1234. See also #3456.
Please use keywords (e.g., Fixes) to create link to the issues or pull requests
you resolved, so that they will automatically be closed when your pull request
is merged. See https://github.com/blog/1506-closing-issues-via-pull-requests
-->
Fixes #16490

#### What does this implement/fix? Explain your changes.
Changed the default value of max and min to `np.inf` and `-np.inf` respectively.

<!--
Please be aware that we are a loose team of volunteers so patience is
necessary; assistance handling other issues is very welcome. We value
all user contributions, no matter how minor they are. If we are slow to
review, either the pull request needs some benchmarking, tinkering,
convincing, etc. or more likely the reviewers are simply busy. In either
case, we ask for your understanding during the review process.
For more information, see our FAQ on this topic:
http://scikit-learn.org/dev/faq.html#why-is-my-pull-request-not-getting-any-attention.

Thanks for contributing!
-->


Problem statement:
Change default valuefor min/max in the experimental IterativeImputer
In the IterativeImputer, `min_value` and `max_value` are defaulted to `None`. Internally, if they are `None` min and max value will be affected to `-np.inf` and `np.inf`, respectively.

We should change this behaviour and make that the default of `min_value=-np.inf` and `max_value=np.inf` directly.

Hints from issue discussion:

Commit message: default value for min/max

Patch to review:
diff --git a/sklearn/impute/_iterative.py b/sklearn/impute/_iterative.py
index fb3d4470c8e6e..ff88968e20bab 100644
--- a/sklearn/impute/_iterative.py
+++ b/sklearn/impute/_iterative.py
@@ -111,12 +111,12 @@ class IterativeImputer(_BaseImputer):
         many features with no missing values at both ``fit`` and ``transform``
         time to save compute.
 
-    min_value : float, default=None
-        Minimum possible imputed value. Default of ``None`` will set minimum
+    min_value : float, default=-np.inf
+        Minimum possible imputed value. Default will set minimum
         to negative infinity.
 
-    max_value : float, default=None
-        Maximum possible imputed value. Default of ``None`` will set maximum
+    max_value : float, default=np.inf
+        Maximum possible imputed value. Default will set maximum
         to positive infinity.
 
     verbose : int, default=0
@@ -217,8 +217,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):
@@ -565,8 +565,8 @@ def fit_transform(self, X, y=None):
 
         self.imputation_sequence_ = []
 
-        self._min_value = -np.inf if self.min_value is None else self.min_value
-        self._max_value = np.inf if self.max_value is None else self.max_value
+        self._min_value = self.min_value
+        self._max_value = self.max_value
 
         self.initial_imputer_ = None
         super()._fit_indicator(X)


Code review comments:
diff_hunk: @@ -565,8 +565,8 @@ def fit_transform(self, X, y=None):
 
         self.imputation_sequence_ = []
 
-        self._min_value = -np.inf if self.min_value is None else self.min_value
-        self._max_value = np.inf if self.max_value is None else self.max_value
+        self._min_value = self.min_value
path: sklearn/impute/_iterative.py
text: @user1:
You should not do that. In a couple of lines below, you need to change the first occurrence of `self._min_value` to `self.min_value`.