tabby

CRAN status Downloads R-CMD-check Codecov test coverage

tabby provides parsnip interfaces for tabular deep learning models. Within tidymodels, they follow the same fit() and predict() flow as any other model. This means you can do things like tune and resample them right alongside the rest of your workflow. tabby supplies only the interface, and the fitting happens in engine packages you install separately, namely brulee and tabpfn. All supported models run on Torch.

Two of the supported models ask a little more of your setup. TabPFN and Chronos-2 are pretrained, so they download their weights the first time you use them, and TabPFN also needs a Python environment, created via reticulate. Being pretrained, they also have few or no hyperparameters to tune, whereas the other supported models carry the usual knobs to optimize.

Supported models

Model Function Mode Engine Python
TabPFN tabular_pfn() classification, regression tabpfn ✔
TabPFN tabular_pfn() classification, regression brulee
TabICL tabular_icl() classification, regression brulee
ResNet tabular_resnet() classification, regression brulee
SAINT tabular_saint() classification, regression brulee
AutoInt tabular_auto_int() classification, regression brulee
Regularization Learning Network tabular_rln() regression brulee
Chronos-2 (forecasting) tabular_chronos() quantile regression, regression brulee

Installation

You can install the released version of tabby from CRAN via:

install.packages("tabby")

You can install the development version of tabby from GitHub with:

pak::pak("tidymodels/tabby")

Example

Create a model specification the same way you would for any parsnip model. Here is a ResNet for classification:

library(tabby)
#> Loading required package: parsnip

resnet_spec <-
  tabular_resnet(
    mode = "classification",
    hidden_units = 32L,
    epochs = 100L,
    penalty = 0.01
  )

resnet_spec
#> tabular resnet Model Specification (classification)
#> 
#> Main Arguments:
#>   hidden_units = 32
#>   penalty = 0.01
#>   epochs = 100
#> 
#> Computational engine: brulee

Fit and predict as usual:

resnet_fit <- fit(resnet_spec, class ~ ., data = train_data)
predict(resnet_fit, new_data = test_data)

Mark any argument with tune() to optimize it with the tune package.

Tuning grids for layered networks

Some models take per-layer parameters, such as a vector of hidden units with one entry per layer. tabby provides helpers to build space-filling grids over these list-valued parameters:

rn_spec <-
  tabular_resnet(
    hidden_units = tune(),
    bottleneck_units = tune(),
    penalty = tune()
  )

rn_grid <- neural_net_grid_space_filling(rn_spec)
rn_grid |> expand_list_parameters()
#> # A tibble: 10 × 7
#>          penalty hidden_units_1 hidden_units_2 hidden_units_3 bottleneck_units_1
#>            <dbl>          <int>          <int>          <int>              <int>
#>  1 0.00599                    2             50             28                 18
#>  2 0.0000359                  7             18             34                 23
#>  3 0.00000278                12              2             44                 39
#>  4 0.0000000001              18             28             18                  2
#>  5 0.00000000129             23             34              2                 44
#>  6 0.0774                    28              7             12                 34
#>  7 0.000000215               34             39             39                 50
#>  8 0.000464                  39             12              7                  7
#>  9 1                         44             44             23                 28
#> 10 0.0000000167              50             23             50                 12
#> # ℹ 2 more variables: bottleneck_units_2 <int>, bottleneck_units_3 <int>

Code of Conduct

Please note that the tabby project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

mirror server hosted at Truenetwork, Russian Federation.