The following objects are masked from 'package:base':
as.factor, as.ordered
# metricsreg_metrics<-metric_set(mae, rsq)# import datadata(hotel_rates)set.seed(295)hotel_rates<-hotel_rates|>sample_n(5000)|>arrange(arrival_date)|>select(-arrival_date)|>mutate( company =factor(as.character(company)), country =factor(as.character(country)), agent =factor(as.character(agent)))# split into training/test setsset.seed(421)hotel_split<-initial_split(hotel_rates, strata =avg_price_per_room)hotel_train<-training(hotel_split)hotel_test<-testing(hotel_split)# 10-fold CVset.seed(531)hotel_rs<-vfold_cv(hotel_train, strata =avg_price_per_room)# feature engineering recipehash_rec<-recipe(avg_price_per_room~., data =hotel_train)|>step_YeoJohnson(lead_time)|># Defaults to 32 signed indicator columnsstep_dummy_hash(agent)|>step_dummy_hash(company)|># Regular indicators for the othersstep_dummy(all_nominal_predictors())|>step_zv(all_predictors())
set.seed(9)ctrl<-control_grid(save_pred =TRUE, verbose =FALSE)lgbm_res<-lgbm_wflow|>tune_grid( resamples =hotel_rs, grid =25,# The options below are not required by default param_info =lgbm_param, control =ctrl, metrics =reg_metrics)