8000 Revert "CLN: remove duplicate validation of X in Encoders transform (… · xhluca/scikit-learn@ba22d84 · GitHub
[go: up one dir, main page]

Skip to content

Commit ba22d84

Browse files
author
Xing
committed
Revert "CLN: remove duplicate validation of X in Encoders transform (scikit-learn#13347)"
This reverts commit d450524.
1 parent ed7f031 commit ba22d84

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

sklearn/preprocessing/_encoders.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -675,10 +675,15 @@ def _legacy_transform(self, X):
675675

676676
def _transform_new(self, X):
677677
"""New implementation assuming categorical input"""
678-
# validation of X happens in _check_X called by _transform
679-
X_int, X_mask = self._transform(X, handle_unknown=self.handle_unknown)
678+
X_temp = check_array(X, dtype=None)
679+
if not hasattr(X, 'dtype') and np.issubdtype(X_temp.dtype, np.str_):
680+
X = check_array(X, dtype=np.object)
681+
else:
682+
X = X_temp
680683

681-
n_samples, n_features = X_int.shape
684+
n_samples, n_features = X.shape
685+
686+
X_int, X_mask = self._transform(X, handle_unknown=self.handle_unknown)
682687

683688
if self.drop is not None:
684689
to_drop = self.drop_idx_.reshape(1, -1)

0 commit comments

Comments
 (0)
0