Closed
Description
Reported by @arnau126 at #12443 (comment):
This change breaks
transform
in_legacy_mode
. It raisesNotFittedError
when it's actually fitted. This is becausecheck_is_fitted
checkscategories_
when_legacy_transform
doesn't use it at all.In
_legacy_mode
we should check_feature_indices_
,_n_values_
and_active_features_
instead.I propose:
def transform(self, X): if self._legacy_mode: check_is_fitted(self, ('_feature_indices_', '_n_values_', '_active_features_')) return _transform_selected(X, self._legacy_transform, self.dtype, self._categorical_features, copy=True) else: check_is_fitted(self, 'categories_') return self._transform_new(X)
I'm surprised we don't already have tests for this case. @arnau126, please submit a minimal verifiable example, or just a test case by which we can confirm the error and your fix. Or submit a pull request with your fix and a test.