https://github.com/ielbadisy/tfmr
R package for tabular foundation models: TabPFN, TabICL, and TabFM.
https://github.com/ielbadisy/tfmr
machine-learning r reticulate tabfm tabicl tabpfn tabular-data
Last synced: 19 days ago
JSON representation
R package for tabular foundation models: TabPFN, TabICL, and TabFM.
- Host: GitHub
- URL: https://github.com/ielbadisy/tfmr
- Owner: ielbadisy
- License: apache-2.0
- Created: 2026-06-10T10:19:31.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-07-03T09:08:25.000Z (21 days ago)
- Last Synced: 2026-07-03T10:29:28.215Z (21 days ago)
- Topics: machine-learning, r, reticulate, tabfm, tabicl, tabpfn, tabular-data
- Language: R
- Homepage: https://ielbadisy.github.io/tfmr/
- Size: 1.59 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE.md
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# tfmr
[](https://CRAN.R-project.org/package=tfmr)
[](https://github.com/ielbadisy/tfmr/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/ielbadisy/tfmr?branch=main)
tfmr is an R package for tabular foundation models. It provides a consistent S3 API for:
- `tab_pfn()`
- `tab_icl()`
- `tab_fm()`
These models cover classification and regression on tabular data with mixed column types. See:
- [_Transformers Can Do Bayesian Inference_](https://arxiv.org/abs/2112.10510) (arXiv, 2021)
- [_TabPFN: A Transformer That Solves Small Tabular Classification Problems in a Second_](https://arxiv.org/abs/2207.01848) (arXiv, 2022)
- [_Accurate predictions on small data with a tabular foundation model_](https://scholar.google.com/scholar?hl=en&as_sdt=0%2C7&q=%22Accurate+predictions+on+small+data+with+a+tabular+foundation+model%22) (Nature, 2025)
The R interface is implemented through `reticulate` and follows standard S3 methods.
## Installation
You can download the package from CRAN via:
```{r}
#| eval: false
install.packages("tfmr")
```
or you can install the development version of tfmr like so:
```{r}
#| eval: false
require(pak)
pak(c("ielbadisy/tfmr"), ask = FALSE)
```
You’ll need a Python virtual environment to access the underlying Python libraries. After installing the R package, tfmr will install the required Python bits when you first fit a model:
```
> library(tfmr)
>
> predictors <- mtcars[, -1]
> outcome <- mtcars[, 1]
>
> # TabPFN example
> mod <- tab_pfn(predictors, outcome)
Downloading uv...Done!
Downloading cpython-3.12.12 (download) (15.9MiB)
Downloading cpython-3.12.12 (download)
Downloading setuptools (1.1MiB)
Downloading scikit-learn (8.2MiB)
Downloading numpy (4.9MiB)
Downloading llvmlite
Downloading torch
Installed 58 packages in 350ms
> mod
TabPFN Regression Model
Training set
i 32 data points
i 10 predictors
```
## Examples
After loading the package:
```{r}
#| label: tab-start-up
library(tfmr)
```
### TabPFN
Fit a regression model via the standard x/y interface.
```{r}
#| label: mtcars
set.seed(364)
reg_mod <- tab_pfn(mtcars[1:25, -1], mtcars$mpg[1:25])
reg_mod
```
There are also formula and recipes interfaces.
Prediction follows the usual S3 `predict()` method:
```{r}
#| label: mtcars-pred
predict(reg_mod, mtcars[26:32, -1])
```
`tfmr` uses a consistent prediction convention: a data frame is always returned with standard column names.
For a classification model, the outcome should always be a factor vector. For example, using these data from the `modeldata` package:
```{r}
#| label: cls
#| results: none
library(modeldata)
two_cls_train <- parabolic[1:400, ]
grid <- expand.grid(X1 = seq(-5.1, 5.0, length.out = 25),
X2 = seq(-5.5, 4.0, length.out = 25))
set.seed(3824)
cls_mod <- tab_pfn(class ~ ., data = two_cls_train)
predict(cls_mod, grid)
```
### Model Summary
| Model | Function | Backend |
| --- | --- | --- |
| TabPFN | `tab_pfn()` | PriorLabs Python package |
| TabICL | `tab_icl()` | `tabicl` Python package |
| TabFM | `tab_fm()` | Google Research `tabfm` Python package |
### TabICL
`tab_icl()` uses the `tabicl` Python backend.
```{r}
#| eval: false
icl_mod <- tab_icl(mpg ~ wt + hp, data = mtcars)
predict(icl_mod, mtcars[1:3, -1])
```
### TabFM
`tab_fm()` uses the Google Research TabFM backend.
```{r}
#| eval: false
fm_mod <- tab_fm(mpg ~ wt + hp, data = mtcars)
predict(fm_mod, mtcars[1:3, -1])
```
## License
[PriorLabs](https://priorlabs.ai/) created the TabPFN model. Starting with version 2.5, using TabPFN requires accepting the model license and setting a token. Each model version (v2.5, v2.6, etc.) has its own license that must be accepted individually.
To get access, visit [https://ux.priorlabs.ai](https://ux.priorlabs.ai), go to the **Licenses** tab, and accept the license for each model version you intend to use. Then set the `TABPFN_TOKEN` environment variable with the token from your account. Users who already have `TABPFN_TOKEN` set can use TabPFN v2 without any additional steps.
Also, the model is most effective when a GPU is available. This is a practical constraint for some workloads but is less relevant for the R interface itself.
## Code of Conduct
Please note that the tfmr project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.