Skip to content

Commit 6158b2c

Browse files
Fixing #872 (#892)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent e758def commit 6158b2c

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

changelog/892.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix `FinetunedTabPFNClassifier`/`FinetunedTabPFNRegressor` dropping pandas feature names from the final inference model. The raw training inputs are now retained so the fitted inference estimator records `feature_names_in_`, and calling `predict_proba`/`predict` with a DataFrame no longer triggers spurious sklearn feature-name warnings.

src/tabpfn/finetuning/finetuned_base.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -637,15 +637,18 @@ def _fit( # noqa: C901,PLR0912
637637
self.finetuned_estimator_ = self._create_estimator(finetuning_estimator_config)
638638
self._setup_estimator()
639639

640-
X, y, _, _ = ensure_compatible_fit_inputs_sklearn(
641-
X,
642-
y,
643-
estimator=self.finetuned_estimator_,
644-
ensure_y_numeric=self._model_type == "regressor",
640+
X_validated, y_validated, self.feature_names_in_, self.n_features_in_ = (
641+
ensure_compatible_fit_inputs_sklearn(
642+
X,
643+
y,
644+
estimator=self.finetuned_estimator_,
645+
ensure_y_numeric=self._model_type == "regressor",
646+
)
645647
)
646-
647648
self.X_ = X
648649
self.y_ = y
650+
X, y = X_validated, y_validated
651+
649652
if X_val is not None and y_val is not None:
650653
X_train, y_train = X, y
651654
X_val, y_val, _, _ = ensure_compatible_fit_inputs_sklearn(

0 commit comments

Comments
 (0)