You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When registering a custom model which also returns a modified glmnet class object, it took me a while to notice that parsnip also exports the S3 Method predict._elnet. Since _elnet is the first listed class object in the list of class attributes, the method predict._elnet exported by parsnip seems to take priority over parsnip's own predict.model_fit, therefore never actually calling my registered predict module, but parsnips glmnet routine. I know that this must be some super rare edge case, but it just took me an hour to figure this out and it seems like a developer pitfall to be aware of.
class(my_model)
[1] "_elnet" "model_fit"
The text was updated successfully, but these errors were encountered:
Hi @EmilHvitfeldt
The glmnet object is returned by the fit-module of my custom parsnip model (which does some tricks with input scaling before passing the data down to glmnet). So after fitting the model, I called predict on it, expecting parsnip to call my registered predict module (which again does some rescaling). However, parsnip's predict._elnet took priority instead. Sure, there are some simple work arounds for that, like wrapping the glmnet object in a list, so that the parsnip model would not have the _elnet class. It was just unexpected, that parsnip disregarded the registered fit module in that specific case.
The problem
When registering a custom model which also returns a modified glmnet class object, it took me a while to notice that parsnip also exports the S3 Method
predict._elnet
. Since_elnet
is the first listed class object in the list of class attributes, the methodpredict._elnet
exported by parsnip seems to take priority over parsnip's ownpredict.model_fit
, therefore never actually calling my registered predict module, but parsnipsglmnet
routine. I know that this must be some super rare edge case, but it just took me an hour to figure this out and it seems like a developer pitfall to be aware of.The text was updated successfully, but these errors were encountered: