Exporting parsnip model fit to pmml

I've searched far and wide but just not finding information. Is there a way to fit a model with the tidymodels set of packages (recipe, tune, rsample, tune...), fit the best model, and then export that model to a pmml format. I tinkered with the pmml package without any luck.

set.seed(123)

library(parsnip)
library(recipes)
#> Loading required package: dplyr
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
#> 
#> Attaching package: 'recipes'
#> The following object is masked from 'package:stats':
#> 
#>     step
library(workflows)
library(modeldata)

data("Sacramento")

base_wf <- workflow() %>%
  add_formula(price ~ type + sqft + beds + baths)

lm_spec <- linear_reg() %>%
  set_engine("lm")

lm_fit <- base_wf %>%
  add_model(lm_spec) %>%
  fit(Sacramento)

library(pmml)
#> Loading required package: XML

lm_fit %>% extract_fit_parsnip() %>% pmml()
#> Error in UseMethod("pmml"): no applicable method for 'pmml' applied to an object of class "c('_lm', 'model_fit')"

Created on 2024-05-06 with reprex v2.1.0

tidymodels itself does not contain anything to convert models to PMML. That would be something to look for in a conversion package like pmml. pmml itself does not list parsnip models as supported but maybe the maintainer is open to a feature request?

Thanks - thinking of a different direction and using tidypredict but that seems not to incorporate recipes if you have that in your workflow.

Hello @StatSteph :wave:

I'm currently working on making {recipes} and thus {workflows} work with {tidypredict}. I don't have anything public yet. This action item does in fact have a timeline as I will be talking about it at Posit Conf :smiley:

Oooh yay! I will be there - just registered last week.