'.model invalid formula in data_grid() function in R

I am trying to use the data_grid function in R and auto-fill some values with the 'standard' values. I created my model using a LASSO logit model which I've fit and finalized with the best fit as follows:

model_final <-
  finalize_workflow(workflow,
                    select_best(tuning_fit,
                                metric = "roc_auc")) %>%
  fit(data3)

When I try to put .model=model_final in my data_grid function, I get an error for invalid formula. I've also tried to put .model=model_final$fit, but this has the same error.

I've also tried the following line of code and then putting the new bit, model_fit, in the place of model_final from the above attempts in both ways. I still fail with the same error.

model_fit<-model_final%>%
extract_fit_parsnip(model_final)

I'm new to R so any help and explanations on why this is happening would be much appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source