Skip to content

Raise NotFittedError from TabFMRegressor.predict before fit#46

Merged
weihaokong merged 1 commit into
google-research:mainfrom
fus3r:fix-regressor-notfitted
Jul 4, 2026
Merged

Raise NotFittedError from TabFMRegressor.predict before fit#46
weihaokong merged 1 commit into
google-research:mainfrom
fus3r:fix-regressor-notfitted

Conversation

@fus3r

@fus3r fus3r commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Calling predict on an unfitted TabFMRegressor raises AttributeError: 'TabFMRegressor' object has no attribute 'X_encoder_' instead of sklearn's standard NotFittedError. The classifier already calls check_is_fitted in _predict_proba_internal; the regressor's _predict_internal was missing it. This adds the same check plus a test covering both estimators.

Repro on main:

from unittest import mock
from tabfm.src.classifier_and_regressor import TabFMRegressor

TabFMRegressor(model=mock.Mock()).predict([[0.0, 1.0]])

Testing: pytest tabfm/src/classifier_and_regressor_test.py tabfm/src/classifier_and_regressor_pytorch_test.py passes (39 tests).

TabFMRegressor.predict on an unfitted estimator raised AttributeError
('X_encoder_') instead of sklearn's NotFittedError. Add the
check_is_fitted call in _predict_internal that TabFMClassifier already
has in _predict_proba_internal.
@weihaokong
weihaokong merged commit 90ce4e5 into google-research:main Jul 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants