Closed vidarsumo closed 8 months ago
hi there -- thanks for trying this out and glad to see someone interested!
I did some testing on my end and it's sometimes tedious to know what var type the python lib wants compared to R workflows (at least for me).
I tried out your code and think a small adjustment will make it work. Changing the future exogenous from c() to list() removes the error for me. I also tried to break/test month as different types as I just wanted to see for myself.
horizon <- length(test_df$ds)
input_size <- as.integer(2*horizon)
levels <- c(70, 95)
# model parameterization
models <- c(
NHITS(input_size = input_size,
h = horizon,
max_steps = 10,
# changing c() to list() here works
futr_exog_list = list("month")
)
)
# stage models
nf_set <- neural_model_setup(models = models, frequency = "M")
# fit models
# fitting with month as numeric or factor worked here once "month" was passed as list()
nf_fit <- neural_model_fit(model_setup = nf_set, df = train_df |> mutate(month = as.factor(month)))
next, I don't think my lazy wrapping of the underlying reticulate objects will work for the predictions. Since you have to pass the future xregs as futr_df, I did not account for that in the nixtla_fcns.R script that gets sourced.
The code ran for me like so:
# make predictions
# note, the fcns for the readme tutorial masks some underlying reticulate stuff
# futr_df needs passed to $predict
# underlying forecasting fcn did not include future exogenous vars
# neural_model_predict <- function(model_setup = neural_model_setup, model_fit = neural_model_fit){
# model_setup$predict(model_fit)
# }
# nf_preds <- neural_model_predict(model_setup = nf_set, model_fit = nf_fit)
# underlying reticulate method:
nf_preds <- nf_set$predict(nf_fit, futr_df = test_df |> mutate(month = as.factor(month)))
let me know how that works & glad to help out!
This worked but I'm having trouble with multiple unique_id.
Will create a another example and post here.
Thank you so much for the help.
Thank you for this helpful tutorial on how to use neuralforecast in R.
I wanted to try it out with xreg (futr_exog_list) but I'm running into an error.
Any idea how to (if possible) to include external features when using NHITS in R?