Repository navigation
fix(classifier, regressor): build the feature schema from the column count - #1349
Open
aniruddhaadak80 wants to merge 3 commits into
Open
aniruddhaadak80 wants to merge 3 commits into
aniruddhaadak80 wants to merge 3 commits into
Conversation
…count X_preprocessed is the collated batch of shape (n_datasets, n_train_rows, n_columns), so the column count is the last dimension. Both estimators passed the row count, which built a schema of the wrong width and dropped every categorical column whose index was >= the number of training rows.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8d03324. Configure here.
Contributor
Author
|
Thanks - both points taken. Fixed in d0c85c0.
|
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.

Issue
Fixes #1344
Motivation and Context
it_from_preprocessed builds the categorical feature schema from the row count:
python feature_schema = convert_batch_of_cat_ix_to_schema( batch_of_cat_indices=cat_ix, num_features=X_preprocessed[0].shape[1], )X_preprocessed[0] is the collated batch of shape (n_datasets, n_train_rows, n_columns) - _collate_list_field (inetuning/data_util.py) stacks the 2-D (rows, cols) tensors. shape[1] is therefore
_train_rows, while the column count is shape[-1].
convert_batch_of_cat_ix_to_schema (utils.py) builds
ange(num_features) Features and marks index i categorical iff i in cat_indices. With the wrong width, a categorical column at an index >= n_train_rows is absent from the schema, so indices_for(FeatureModality.CATEGORICAL) silently omits it and the model is told the column is numerical.
This affected both estimators: TabPFNClassifier.fit_from_preprocessed and TabPFNRegressor.fit_from_preprocessed.
On the observable impact, stated honestly: this is currently latent rather than numerically visible. Every architecture opens its orward with del categorical_inds, so the argument is ignored on today's models and the two public prediction paths do not disagree on probabilities. What is wrong today is the metadata handed to the model, and that is exactly what an architecture honouring categorical_inds would depend on. A secondary cost is allocation:
um_features = n_train_rows allocates one Feature per training row per estimator per dataset, so fine-tuning a 50k-row chunk built 50k dataclasses where ~10 were needed.
Public API Changes
No signature changes. The categorical metadata the batched engine passes to the model becomes correct.
How Has This Been Tested?
New tests in ests/test_classifier_interface.py and ests/test_regressor_interface.py:
Both fail on the unfixed source and pass with the fix:
`
with the two source lines reverted
E AssertionError: assert 5 == 8
E AssertionError: assert [[[]]] == [[[226]]]
2 failed, 181 deselected
`
With the fix:
$ python -m pytest tests/test_classifier_interface.py tests/test_regressor_interface.py \ -k "feature_schema_spans_the_columns or high_categorical_columns" -q 4 passed, 365 deselected in 32.47suff check and
uff format --check are clean on both changed files. Several pre-existing tests in these two files fail on this machine with TabPFNLicenseError (no TABPFN_TOKEN, no cached checkpoint); the identical failures occur on the base commit, so they are environmental and unrelated.
Checklist