Is there any way to extract a trained model with train data from the results of fit_resample()?

fit_resample() can be used to check how much the performance changes when the data changes, so it is used to determine the performance when the data is not overfit.

fit_resample(wfl, vfold)%>%
  collect_metrics()

If I want to use it for predict(), I need to extract it from fit_resample() by extract_workflow(), then last_fit() and then extract_workflow().
With the above operations, a trained model has been obtained.

I could only get an empty workflow out of fit_resample().
Is it possible to retrieve a model that has already been trained in train from fit_resample(), as in last_fit()?

P.S.
I was reading the "stacks" package github code, and it seems that the trained model was created using [["train"]] from the fit_member() object, so I'm thinking that if the same operation is happening in fit_resample(), it could be retrieved.

thank you

There are as many models as there are resamples. You can get them using the extract() option of control_resamples(). There is a similar example here

1 Like

stacks uses the results of training with resample, but I think it gives us the final model trained with train.

Can't I get the model trained in train out of fit_resample() instead of the model trained in sample?

No. It only builds models from the resampled versions of the data.

For example, if you are using 10-fold cross-validation, 10 different models are created from 10 different versions of the training set. This function does not fit the 11th model to the entire training set. fit() does that.

I think the confusion is related to stacking. It might help to look a this presentation especially the parts around slide number 7.

1 Like

@Max

This function does not fit the 11th model to the entire training set. fit() does that.

Thank you very much.

I would have been happy if the results of fit(data=train) could be extracted from fit_resample() using extra_workflow(), but your answer shows that this is not possible.

I will continue to support tidymodels.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.