Skip to content

Conversation

@Fdvanleeuwen
Copy link

The CP_MDA-exact algorithm [1] allows users to obtain conformalised uncertainty estimates for TabPFNRegressor. This allows users to have correct uncertainty estimates based on the missing masks, as described in [2]. There are two functions:

CP_MDA_TabPFNRegressor: for fitting TabPFNRegressor and obtaining the correction terms for each mask.
CP_MDA_TabPFNRegressor_newdata: for applying the fitted model (and correction terms) to new test cases.

[1] Margaux Zaffran, Aymeric Dieuleveut, Julie Josse, and Yaniv Romano. Conformal prediction with missing
values. In International Conference on Machine Learning, pages 40578–40604. PMLR, 2023.
[2] van Leeuwen, F. D. Conformal Prediction for Tabular Prior-Data Fitted Networks with Missing data. In EurIPS 2025 Workshop: AI for Tabular Data.

Introduces the CP_missing_data extension for TabPFNRegressor, providing conformal prediction intervals in the presence of missing data. Includes implementation, example usage, and tests for calibration and prediction with missing data patterns.
Less features to reduce the number of masks for the example
@Fdvanleeuwen Fdvanleeuwen requested a review from a team as a code owner January 2, 2026 10:43
@Fdvanleeuwen Fdvanleeuwen requested review from adrian-prior and removed request for a team January 2, 2026 10:43
@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@CLAassistant
Copy link

CLAassistant commented Jan 2, 2026

CLA assistant check
All committers have signed the CLA.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Fdvanleeuwen, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates the CP_MDA-exact algorithm into the tabpfn_extensions library, enabling TabPFNRegressor to generate accurate and calibrated uncertainty estimates even in the presence of missing data. The solution provides a robust framework for handling various missing data patterns by calculating specific correction terms, thereby improving the reliability of predictions for tabular data.

Highlights

  • New Algorithm for Missing Data: Introduces the CP_MDA-exact algorithm to provide conformalized uncertainty estimates for TabPFNRegressor when data is missing.
  • Two-Step Process: Implements two core functions: CP_MDA_TabPFNRegressor for model fitting and correction term calculation, and CP_MDA_TabPFNRegressor_newdata for applying these corrections to new datasets.
  • Research-Backed: The algorithm is based on recent research, specifically referencing papers by Zaffran et al. (2023) and van Leeuwen (EurIPS 2025).

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the CP_MDA-exact algorithm for handling missing data with TabPFN, which is a valuable addition. The implementation is well-structured into two classes for training and prediction. I've found a critical issue in the data selection logic that could lead to incorrect calibration, which needs to be addressed. Additionally, I've provided feedback on improving docstrings, code style consistency, and the flexibility of the implementation. The tests are a good start, but one of them could be made more robust. The example script is clear and helpful.

def run_TABPFN(self):
"""Fit the TabPFN model."""
# fit model
m_fit = TabPFNRegressor()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The TabPFNRegressor is instantiated with its default parameters, which limits flexibility. Consider allowing users to pass custom arguments to TabPFNRegressor through the CP_MDA_TabPFNRegressor constructor.

You could modify the __init__ method to accept **tabpfn_kwargs and store them:

def __init__(self, X_train, Y_train, quantiles, val_size, seed, **tabpfn_kwargs):
    # ...
    self.tabpfn_kwargs = tabpfn_kwargs

Then, you can use these arguments when creating the instance here.

Suggested change
m_fit = TabPFNRegressor()
m_fit = TabPFNRegressor(**getattr(self, 'tabpfn_kwargs', {}))

Fdvanleeuwen and others added 10 commits January 2, 2026 12:23
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Make seed optional and update name change of internal function in pipeline.
@adrian-prior adrian-prior requested review from bejaeger and removed request for adrian-prior January 7, 2026 10:29
Copy link
Contributor

@bejaeger bejaeger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Fdvanleeuwen ,
thank you so much for this contribution. It looks great all in all. There are a few stylistic things I commented on that would be great if you could change them. The CI also shows some errors. If you could fix these I can have a closer look at the method.
Thanks again!

from tabpfn import TabPFNRegressor
except ImportError:
# Fall back to TabPFN client
from tabpfn_client import TabPFNRegressor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use from tabpfn_extensions.utils import TabPFNClassifier, TabPFNRegressor instead :)

from tabpfn import TabPFNRegressor
except ImportError:
# Fall back to TabPFN client
from tabpfn_client import TabPFNRegressor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: from tabpfn_extensions.utils import TabPFNClassifier, TabPFNRegressor

Parameters:
X_train : matrix-like of shape (n_samples, n_predictors)

Y_train : array-like of continuous outcome with shape (n_samples,)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's stick to the convention of parsing the data during the fit() call. Only configuration should go here.

"""Split data into training and validation sets."""
# create df with missing data indicator
missing_bool_df = self.X.isnull().astype(int)
self.X_train, self.X_val, Y_train_arr, Y_val_arr, self.Mask_train, self.Mask_val = train_test_split(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our convention is to use y for the target variable (lowercase).
Please also make Mask_train/val lowercase -> mask_train/val to stick to python conventions

self.split_data()
self.run_TABPFN()
self.mask_preprocess()
mask_unique, model = self.create_calibration_sets()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be easier to follow the code if you return the variables needed in the next steps rather than making them an instance variable. Would be a nice change.


TabPFN: Fitted TabPFNRegressor model.

X_new : matrix-like of shape (n_samples, n_predictors)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, let's parse X_new that during fit()

"""Convenience method to run the entire pipeline"""
self.obtain_preds()
self.match_mask()
CP_results = self.perform_correction()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar here, could we return and parse the arguments needed?


"""

def __init__(self, X_train, Y_train, quantiles, val_size, seed=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add type hints here and in all other functions.

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.

3 participants