problems with predict()

Trying parsnip::predict() gives me...

'predict' is not an exported object from 'namespace:parsnip'

Is this normal?

Yes, its normal. I see no problem here.

Unless there are other packages involved.

stats::predict() is forced to use pkg. forecast (3.)

[1] "package:stats"
Error in ets(object, lambda = lambda, biasadj = biasadj, allow.multiplicative.trend = allow.multiplicative.trend, :
y should be a univariate time series

  1. ├─base::do.call(theClassPred, list(catA, catB, modTrain, shortVersion = 1)) at R/adthocStrat/scoring.R:6680:12
  2. ├─global <fn>(<tibble[,206]>, <tibble[,83]>, <tibble[,8]>, shortVersion = 1)
  3. │ ├─stats::predict(stopping_fit) at R/adthocStrat/scoring.R:6393:16
  4. │ └─forecast:::predict.default(stopping_fit)
  5. │ ├─fabletools::forecast(object, ...)
  6. │ └─forecast:::forecast.default(object, ...)
  7. │ └─forecast:::forecast.ts(object, ...)
  8. │ ├─fabletools::forecast(...)
  9. │ └─forecast::ets(...)
  10. │ └─base::stop("y should be a univariate time series")

Sadly, we have zero context for what you are doing...
did you look at parsnip::predict because you had used parsnip to fit some kind of model ? and if so , what type ? or if you didn't use parsnip, what did you use ?

some code relating to how you fit the model object you wish to predict on would be good ... a reprex is the gold standard.

I use this example.... with my own data.

Yes I try to predict a fitted parsnip-model.

Update: Turns out, wrong input-format for stats::predict() leads to this missleading error message- because stats is 'guessing' to forecast an ets.

    model_spec <-
                    boost_tree() %>%
                    set_engine("xgboost") %>%
                    set_mode("classification")
                
                myModel<- workflow() %>%
                    add_model(model_spec) %>%
                    add_recipe(shelter_rec) %>%
                    parsnip::fit(df_train)

                # https://parsnip.tidymodels.org/reference/predict.model_fit.html
                testPred<-stats::predict(myModel,new_data=df_test)
                View(testPred)

before I used stopping_fit as input for stats::predict()...

stopping_fit <- early_stop_wf %>%
                    finalize_workflow(select_best(stopping_rs, "accuracy")) %>%
                    last_fit(shelter_split)

whereas stopping_fit could be no real fit ;-).

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.