You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Shape may mismatch in IterativeImputer if set min_value with array-like input and some features contain all missing values #29355
In all Imputers, features with all missing values will be droped if keep_empty_features is set to False.
However, in IterativeImputer, if we set min_value and max_value with array-like input, it might raise an error indicate that the shape mismatch.
We can manually reduce the elements in min_value and max_value after we check if there is any features with all missing values, I wonder if this can be done automatically.
/Users/xxf/code/scikit-learn/sklearn/impute/_base.py:597: UserWarning: Skipping features without any observed values: [2]. At least one non-missing value is needed for imputation with strategy='mean'.
warnings.warn(
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/xxf/code/scikit-learn/sklearn/utils/_set_output.py", line 313, in wrapped
data_to_wrap = f(self, X, *args, **kwargs)
File "/Users/xxf/code/scikit-learn/sklearn/base.py", line 1514, in wrapper
return fit_method(estimator, *args, **kwargs)
File "/Users/xxf/code/scikit-learn/sklearn/impute/_iterative.py", line 759, in fit_transform
self._min_value = self._validate_limit(self.min_value, "min", X.shape[1])
File "/Users/xxf/code/scikit-learn/sklearn/impute/_iterative.py", line 682, in _validate_limit
raise ValueError(
ValueError: 'min_value' should be of shape (2,) when an array-like is provided. Got (3,), instead.
I guess it seems feasible, but you would need to have a closer look at the code and try to do it! Setting the label "help wanted" on this. Also "Easy" although this is a bit of a guess. Withouth having a closer look it may well be more complicated than it looks ...
Maybe the dropping the features happens first and min_features happens afterwards and it should be the other way around, or you could track the number of features after and before dropping. Maybe it is more complicated than this 😉.
Activity
lesteve commentedon Jul 5, 2024
Thanks for your issue and the reproducer.
I guess it seems feasible, but you would need to have a closer look at the code and try to do it! Setting the label "help wanted" on this. Also "Easy" although this is a bit of a guess. Withouth having a closer look it may well be more complicated than it looks ...
Maybe the dropping the features happens first and
min_featureshappens afterwards and it should be the other way around, or you could track the number of features after and before dropping. Maybe it is more complicated than this 😉.gunsodo commentedon Jul 6, 2024
@lesteve Would love to take this issue.