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
According to the parsnip tutorial, pkg is not required to use a local function for fitting:
func is the package and name of the function that will be called. If you are using a locally defined function, only fun is required.
However, if I try to register a model with a local fit function, I receive an error in call2, that namespace ns should be a string.
I am quite new to tidymodels, am I missing something?
Reproducible example
library(tidymodels)
set_new_model("my_model")
set_model_mode(model="my_model", mode="regression")
set_model_engine(
"my_model",
mode="regression",
eng="my_engine"
)
my_model<-function(mode="regression") {
# Check for correct modeif (mode!="regression") {
rlang::abort("`mode` should be 'regression'.")
}
# Save some empty slots for future parts of the specification
new_model_spec(
"my_model",
args=list(),
eng_args=NULL,
mode=mode,
method=NULL,
engine=NULL
)
}
my_model_fun<-function(...) {
print(list(...))
}
set_fit(
model="my_model",
eng="my_engine",
mode="regression",
value=list(
interface="matrix",
# should not be changeable by the userprotect= c("formula", "data"),
func= c(fun="my_model_fun"),
defaults=list()
)
)
my_model() %>%
translate("my_engine")
#> my model Model Specification (regression)#> #> Computational engine: my_engine #> #> Model fit template:#> Error in `call2()` at parsnip/R/misc.R:245:3:#> ! `ns` must be a string
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.
The problem
According to the parsnip tutorial, pkg is not required to use a local function for fitting:
However, if I try to register a model with a local fit function, I receive an error in call2, that namespace
ns
should be a string.I am quite new to tidymodels, am I missing something?
Reproducible example
Created on 2025-01-16 with reprex v2.1.1
Session info
The text was updated successfully, but these errors were encountered: