The goal of tabfm is to run TabFM, a tabular foundation model.
You can install the development version of tabfm like so:
pak::pak('frankiethull/tabfm')library(tabfm)
library(rsample)
corn_data <- maize::corn_data
corn_splits <- initial_validation_split(corn_data)
train <- training(corn_splits)
validate <- validation(corn_splits)
test <- testing(corn_splits)fit_cls <- tabfm_fit(
train |> dplyr::select(-type),
train$type
)
class_preds <- tabfm_predict(fit_cls, test |> dplyr::select(-type))
class_preds |> head()
#> [1] "Sweet" "Sweet" "Sweet" "Sweet" "Sweet" "Sweet"class_probs <- tabfm_predict(
fit_cls,
test |> dplyr::select(-type),
type = "proba"
)
class_probs |> head()
#> [,1] [,2] [,3]
#> [1,] 4.717414e-05 0.1708070785 0.8291458
#> [2,] 1.179814e-06 0.0043090940 0.9956897
#> [3,] 1.176569e-06 0.0070481412 0.9929507
#> [4,] 2.135778e-05 0.2080314010 0.7919472
#> [5,] 5.090896e-05 0.3103068769 0.6896423
#> [6,] 1.493892e-05 0.0004187601 0.9995663