Created
February 21, 2022 13:56
-
-
Save MJacobs1985/61091921b996e261e30aeb000e4f58fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| registerDoParallel(cores=8) | |
| set.seed(123) | |
| Eggs2<-day%>% | |
| filter(location_identification==1)%>% | |
| mutate(egg_count = zoo::na.aggregate(egg_count), | |
| feed_provided = zoo::na.aggregate(feed_provided), | |
| water_provided = zoo::na.aggregate(water_provided), | |
| animals_actual = zoo::na.aggregate(animals_actual), | |
| t_min_out = zoo::na.aggregate(t_min_out), | |
| t_max_out = zoo::na.aggregate(t_min_out), | |
| t_act_out = zoo::na.aggregate(t_min_out), | |
| rh_act_in = zoo::na.spline(rh_act_in))%>% | |
| dplyr::select(egg_count, | |
| date_interval, | |
| water_provided, | |
| feed_provided, | |
| animals_actual, | |
| t_min_out, | |
| t_max_out, | |
| t_act_out, | |
| rh_act_in) | |
| myTimeControl <- trainControl(method = "timeslice", | |
| initialWindow = 50, | |
| horizon = 7, | |
| fixedWindow = FALSE, | |
| allowParallel = TRUE) | |
| model_names <- c("glmnet", "lm", | |
| "earth", "gam", "rpart", | |
| "ctree", "gbm", "rf") | |
| fits<-map(model_names, | |
| ~ train( | |
| egg_count ~ . - 1, | |
| data = Eggs2, | |
| method = .x, | |
| trControl = myTimeControl, | |
| na.action=na.omit | |
| ))%>% | |
| set_names(model_names) | |
| resamps <- resamples(fits) | |
| ss <- summary(resamps) | |
| ss[[3]]$RMSE | |
| trellis.par.set(caretTheme()) | |
| dotplot(resamps, metric = "RMSE") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment