Repository navigation
Give each regression member its own target pipeline [RES-2639] #1198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+478
−63
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
79b0b6b
Give each regression member its own target pipeline [RES-2639]
bejaeger 629083b
fix: validate regression fit state and require target frames
bejaeger 99d2660
docs: document fitted regressor incompatibility without version checks
bejaeger 5588851
test: pass regression target frames in custom loop coverage
bejaeger f48014d
test: preserve double precision in target frame assertion
bejaeger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Previously saved fitted regressors (`.tabpfn_fit` archives and pickled estimators) are incompatible with the updated target preprocessing and must be refitted. Custom fine-tuning loops must pass `y_train_mean` and `y_train_std` to `fit_from_preprocessed`. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Regression ensembles now normalize targets using each member’s training rows; without subsampling, only floating-point differences are expected. |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # Copyright (c) Prior Labs GmbH 2026. | ||
|
|
||
| """Invertible regression target pipelines. | ||
|
|
||
| Each member maps raw targets to model inputs and inversely maps borders to raw | ||
| units. The estimator maps those borders into a shared standardized space for | ||
| aggregation, avoiding float32 precision loss for targets with large offsets. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import TYPE_CHECKING | ||
|
|
||
| import numpy as np | ||
| from sklearn.base import BaseEstimator, TransformerMixin | ||
| from sklearn.pipeline import Pipeline | ||
|
|
||
| if TYPE_CHECKING: | ||
| from sklearn.base import TransformerMixin as Transformer | ||
|
|
||
| STANDARDIZE_STEP = "standardize_target" | ||
| TARGET_TRANSFORM_STEP = "target_transform" | ||
|
|
||
|
|
||
| class StandardizeTarget(TransformerMixin, BaseEstimator): | ||
| """Standardize using fitted ``mean_`` and ``std_`` (population std + epsilon). | ||
|
|
||
| Keep NumPy arithmetic rather than StandardScaler to preserve exact model | ||
| inputs when the member sees the full training target. | ||
| """ | ||
|
|
||
| EPSILON = 1e-20 | ||
| """Prevent division by zero for constant targets.""" | ||
|
|
||
| def fit(self, X: np.ndarray, y: np.ndarray | None = None) -> StandardizeTarget: | ||
| """Learn the mean and standard deviation of the target ``X``.""" | ||
| del y | ||
| self.mean_ = float(np.mean(X)) | ||
| self.std_ = float(np.std(X)) + self.EPSILON | ||
| return self | ||
|
|
||
| def transform(self, X: np.ndarray) -> np.ndarray: | ||
| """Return the standardized target.""" | ||
| return (np.asarray(X) - self.mean_) / self.std_ | ||
|
|
||
| def inverse_transform(self, X: np.ndarray) -> np.ndarray: | ||
| """Return ``X`` in the original units of the target.""" | ||
| return np.asarray(X) * self.std_ + self.mean_ | ||
|
|
||
|
|
||
| def make_target_transform(transform: Transformer | Pipeline | None) -> Pipeline: | ||
| """Standardize raw targets, then apply the optional preset. | ||
|
|
||
| The inverse returns values in the target's original units. | ||
| """ | ||
| if transform is None: | ||
| return Pipeline(steps=[(STANDARDIZE_STEP, StandardizeTarget())]) | ||
| return Pipeline( | ||
| steps=[ | ||
| # The preset reshapes the standardized target. | ||
| (STANDARDIZE_STEP, StandardizeTarget()), | ||
| (TARGET_TRANSFORM_STEP, transform), | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| __all__ = [ | ||
| "STANDARDIZE_STEP", | ||
| "TARGET_TRANSFORM_STEP", | ||
| "StandardizeTarget", | ||
| "make_target_transform", | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.