tests/testthat/backwards-compat/generate-rf-v2-classification.R

# Script to regenerate rf-v2-classification.rds
# Uses CRAN tidypredict 1.0.1 which produced v2 format
# Note: This model will error when used with tidypredict_fit()
# because classification is not supported.

tmp_lib <- tempfile("lib")
dir.create(tmp_lib)
install.packages(
  "tidypredict",
  lib = tmp_lib,
  repos = "https://cloud.r-project.org"
)
library(tidypredict, lib.loc = tmp_lib)

library(randomForest)
set.seed(123)
model <- randomForest(
  Species ~ Sepal.Length + Sepal.Width,
  data = iris,
  ntree = 3
)

pm <- parse_model(model)
saveRDS(pm, "tests/testthat/backwards-compat/rf-v2-classification.rds")

Try the tidypredict package in your browser

Any scripts or data that you put into this service are public.

tidypredict documentation built on Aug. 24, 2026, 9:10 a.m.