Skip to main content
What is RF-PFN Extension?
  • Uses scikit-learn tree splits, but fits TabPFN models at each node or leaf.
  • Optionally prunes or refits nodes using validation-based performance checks.
  • Works with the typical parameters for tree-based methods.

Getting Started

To install the extension, include the rf_pfn extra:
pip install "tabpfn-extensions[rf_pfn]"
Once installed, you can easily combine TabPFN with decision trees or random forests:

Random Forest

Train a Random Forest where each tree uses TabPFN models at its leaves for adaptive predictions via RandomForestTabPFNRegressor and RandomForestTabPFNClassifier.
from tabpfn import TabPFNRegressor
from tabpfn_extensions.rf_pfn import RandomForestTabPFNRegressor

reg = TabPFNRegressor()

# Simply wrap the base TabPFN estimator with the RF extension
rf_reg = RandomForestTabPFNRegressor(tabpfn=reg)

rf_reg.fit(X_train, y_train)
y_hat = rf_reg.predict(X_test)

Decision Trees

Train standalone Decision Trees that delegate predictions at each leaf (or node) to TabPFN with DecisionTreeTabPFNRegressor and DecisionTreeTabPFNClassifier.
from tabpfn import TabPFNRegressor
from tabpfn_extensions.rf_pfn import DecisionTreeTabPFNRegressor

reg = TabPFNRegressor()

# Simply wrap the base TabPFN estimator with the RF extension
dt_reg = DecisionTreeTabPFNRegressor(tabpfn=reg)

dt_reg.fit(X_train, y_train)
y_hat = dt_reg.predict(X_test)

Core Parameters

The following table lists the core parameters. For more details see the rf_pfn extension on GitHub.

Random Forest

ParamMeaning (per code)Default
tabpfnRequired TabPFN model-
max_depthTree depth (per base DT)cls: 5, reg: 5
bootstrapBootstrap samples when fitting treesTrue
rf_average_logitsClassifier: average logits across treescls: True, reg: False
dt_average_logitsClassifier: average logits within treesTrue
max_predict_timeStop averaging once time exceeded (seconds)cls: 60, reg: -1
min_samples_splitSplit threshold per DTcls: 1000, reg: 300
min_samples_leafMin samples per leaf5
max_featuresFeatures considered at split"sqrt"
fit_nodesFit TabPFN at internal nodesTrue

Decision Trees

ParamMeaning (per code)Default
tabpfnRequired TabPFN model-
max_depthMax depthNone (unlimited)
min_samples_splitSplit threshold per DT1000
min_samples_leafMin samples per leaf1
max_featuresFeatures considered at splitNone (all features)
fit_nodesFit TabPFN at internal nodesTrue