Hardhat vs Parsnip to create new models

I've came across an excellent video tutorial from @Max on building modeling packages using hardhat. However, the tidymodels page has an article on how to build a parsnip model with step-by-step instructions on how to do that.

Which is the recommended way to build a new estimating function (fit) that can be easily incorporated into my tidymodelsframework?

references:
tidymodels - How to build a parsnip model

To incorporate a new model into the tidymodels framework you broadly speaking need two things:

  • something to estimate the model and calculate predictions -- that's what we refer to as the modeling package
  • something to connect that modeling package to the tidymodels framework -- that's what we refer to as the parsnip model

So if you are starting from scratch, you'd use hardhat to make your modeling package. (That works independently of tidymodels.) Then you'd build a parsnip model as described in the article you linked. The modeling package acts as the "engine" here.

If you want to see an example, our brulee package was made using hardhat.

If you give it a try, let is know if you have any issues or questions.

@Max , @hannah , thanks a lot for the feedback.
I've worked as suggested. It all worked fine for fiting the model but I could not manage to get it to predict.
It complains there is no predict for class _my_class (note the underscore added). But it works fine if I use predict(model_fit$fit) where model_fit$fit is of class my_class or it works if I use predict.model_fit.

I have debugged it and predict works fine while debuggin the code.

I suspect it has to do with the S3 dispatch not finding exactly where to find the correct method. I will try taking a closer look at brulee as suggested, but meanwhile I've opened an issue at parsnip with a reproducible example. ( Potential error on S3 dispatch)

Thanks!

Thanks for the reprex! I'll reply on the github issue.

This topic was automatically closed 21 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.