Repository navigation
Conversation
fit accepted a frame or array with zero columns and reported itself as fitted. Its ColumnTransformer had no output layout (output_indices_), so transform(return_array=False) and get_feature_lineage() then failed with an AttributeError from scikit-learn internals. fit now raises EmptyDataError for input without columns, parallel to the existing check for input without rows, and the preprocessor stays unfitted. Fixes #165
This was referenced Nov 29, 2026
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 #165.
Preprocessor.fitaccepted input without columns and reportedFITTED.transform(return_array=False)andget_feature_lineage()then failed withAttributeError: 'ColumnTransformer' object has no attribute 'output_indices_'.Root cause
Only input without rows was rejected, in
detect_column_types. AColumnTransformerwithout transformers fits but never setsoutput_indices_, which the block output and the lineage read.Fix
Preprocessor.fit(pretab/preprocessor.py) raisesEmptyDataErrorright after convertingXto a frame when it has no columns. The message mirrors the zero-row one:Preprocessor needs at least one feature, but X has 0 columns (shape (5, 0)).The check runs before any fitted attribute is set, so the preprocessor staysUNFITTED.I put the check in
fit, not indetect_column_types, so this branch does not overlap the edits that #154 and #156 make inpretab/compose/feature_detection.py.Behaviour changes
fiton input without columns raisesEmptyDataError(aPretabDataErrorandValueError) instead of producing an unusable fitted object.Preprocessor(CrossFittedTransformer,RepresentationSearchCV, scikit-learn pipelines) surface the same error.Documentation
Preprocessor.fitdocstring (Raises):EmptyDataErroralso covers input without columns.docs/representations/choosing_a_method.md(edge cases): new "Input without columns at fit" entry next to the zero-row one.Tests
In
tests/regression/test_edge_cases.py:test_fit_on_input_without_columns_raises_typed_error(DataFrame, ndarray, list of empty rows): typed error,UNFITTEDstate, nocolumn_transformer_. Fails onmain, passes here.test_fit_on_input_without_columns_is_a_value_error: scikit-learn's empty-data convention. Fails onmain, passes here.Reproduction
The script from #165 on this branch:
Checks
just test: 4680 passed, 59 skipped, 7 xfailed; coverage 95.71% (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).EmptyDataErrorfrompretab.exceptions; no import direction changes.Merge notes
main. Git merges this branch cleanly with the other open per-issue branches (fix(binning): reject edges the soft encoding cannot use #150 to fix(cross-fitting): cross-fit estimators that cannot name their output #164).