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
I am having trouble using the tune::fit_resamples() function on a lmer model (from the multilevelmod package).
In particular, it looks like that when the predictions for the assessment set are calculated, the model doesn't properly account for all the possible combinations of grouping levels.
I have included a reprex in which I show that the results of a predict() call on a lmer object are different than the predictions obtained from a fit_resamples() call (using collect_predictions()).
library(tidyverse)
library(tidymodels)
library(multilevelmod)
data(mpg, package="ggplot2")
set.seed(123)
lmer_model= linear_reg() %>%
set_engine("lmer")
lmer_workflow= workflow() %>%
add_variables(outcomes=cty,
predictors= c(year, manufacturer, model)) %>%
add_model(lmer_model, formula=cty~year+ (1|manufacturer/model))
mpg_split=mpg %>% validation_split(prop=3/4)
analysis=mpg_split$splits[[1]] %>% analysis()
assessment=mpg_split$splits[[1]] %>% assessment()
# using predict() on the assessment dataset works as expectedpredicted_via_workflow=lmer_workflow %>%
fit(analysis) %>%
extract_fit_engine() %>%
predict(assessment) %>%
plot()
# the predictions from the fit_resamples() function do not vary per grouppredicted_via_tune=lmer_workflow %>%
fit_resamples(mpg_split, control= control_resamples(allow_par=FALSE,
save_pred=TRUE)) %>%
collect_predictions() %>%
pluck(".pred") %>%
plot()
In fact, I think that before fix #41 this same code would have thrown an error without predicting anything, while now the fitted workflow can be used to predict new values.
I am having trouble using the
tune::fit_resamples()
function on almer
model (from themultilevelmod
package).In particular, it looks like that when the predictions for the assessment set are calculated, the model doesn't properly account for all the possible combinations of grouping levels.
I have included a reprex in which I show that the results of a
predict()
call on almer
object are different than the predictions obtained from afit_resamples()
call (usingcollect_predictions()
).Created on 2022-06-20 by the reprex package (v2.0.1)
The text was updated successfully, but these errors were encountered: