Repository navigation
Conversation
fit_transform read the all-data fit's get_feature_names_out() only to learn the expected fold width and DataFrame columns, so a Pipeline or ColumnTransformer with a FunctionTransformer step, or any transformer without the method, raised AttributeError although fit().transform() worked. When the wrapped estimator cannot provide names, the first fold's width and columns are now the reference, and every later fold is still checked against them. Fixes #163
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #163.
CrossFittedTransformer.fit_transformraisedAttributeErrorfor a wrapped estimator that cannot name its output columns, such as aPipelineorColumnTransformerwith aFunctionTransformerstep, althoughfit().transform()worked.Root cause
fit_transform(pretab/core/supervised.py) began withnames = list(self.estimator_.get_feature_names_out()). The names were used only to know the expected fold width and to compare DataFrame fold columns, but the call had no fallback.Fix
_all_data_feature_names()returns the all-data fit's names, orNonewhenget_feature_names_outraisesAttributeError. This is how scikit-learn'sPipelineandColumnTransformersignal a step without names.Behaviour changes
fit_transformraisedAttributeError.get_feature_names_out()on the wrapper still delegates to the wrapped estimator, so it still raises for such an estimator, as scikit-learn does.Documentation
CrossFittedTransformer.fit_transformdocstring (Raises): the first fold is the reference when the wrapped transformer provides noget_feature_names_out.docs/core_concepts/target_awareness.mdanddocs/api/search_and_cross_fitting.rst(fold contract): the same fallback.Tests
In
tests/core/test_cross_fitted.py:test_fit_transform_works_without_output_feature_names:Pipeline(FunctionTransformer(np.log1p), PLETransformer)matches a manual out-of-fold computation with the same splitter. Fails onmain, passes here.test_column_transformer_without_output_feature_names_is_cross_fitted: a mixedColumnTransformer. Fails onmain, passes here.test_fold_width_is_still_checked_without_output_feature_names: a transformer without names whose width depends on its training rows still raises the fixed-widthIncompatibleParamsError. Fails onmain(withAttributeError), passes here.Reproduction
The script from #163 on this branch:
Checks
just test: 4679 passed, 59 skipped, 7 xfailed; coverage 95.69% (gate 90%).scripts/quickstart.pypasses.just docs: strict build succeeds.just check: all pre-commit and pre-push hooks pass (file hygiene, ruff format, ruff lint, prettier, pyright with 0 errors).pretab.core.supervised; no import direction changes.Merge notes
main.tests/core/test_cross_fitted.py(a different test,test_fit_transform_keeps_strings_left_unchanged). Git merges the two branches cleanly, and cleanly with the other open per-issue branches.