Light GBM 和随机森林模型堆叠。尝试使用不再存在的助推器

问题描述 投票:0回答:1

我正在尝试使用库(堆栈)通过 Light GBM 来建模堆栈随机森林。 我能够将 my_stack 放入 Predict() 中。我在哪里收到此错误:

Error in `purrr::map()`:
ℹ In index: 1.
ℹ With name: lightGBM_models_1_047.
Caused by error in `predictor$predict()`:
! Attempting to use a Booster which no longer exists. This can happen if you have called Booster$finalize() or if this Booster was saved with saveRDS(). To avoid this error in the future, use saveRDS.lgb.Booster() or Booster$save_model() to save lightgbm Boosters.

根据我的阅读,此错误通常来自于尝试保存 lightgbm 模型以供以后重用。我不确定为什么我能够在设置工作流程后运行 stack() ,甚至比较它们的预测,因为它返回它们拥有多少相同的预测并从数据堆栈中删除,但无法使用 stack_mod用于预测,因为 lightgbm 助推器消失了?去哪儿了?

`
> randforest_models <- rand_forest_wf %>%
+   tune_grid(resamples=folds,
+             grid=rand_forest_tuning_grid,
+             metrics=metric_set(roc_auc),
+             control = untunedModel)
ℹ The workflow being saved contains a recipe, which is 19.3 Mb in memory. If this ℹ was not
intentional, please set the control setting `save_workflow = FALSE`.
> lightGBM_models <- boost_workflow %>%
+   tune_grid(resamples=folds,
+             grid=boost_tuning_grid,
+             metrics=metric_set(gain_capture),
+             control = untunedModel)
ℹ The workflow being saved contains a recipe, which is 19.3 Mb in memory. If this ℹ was not
intentional, please set the control setting `save_workflow = FALSE`.
Warning messages:
1: In for (v in val) { :
  closing unused connection 12 (<-DESKTOP-3UVUISO:11780)
2: In for (v in val) { :
  closing unused connection 11 (<-DESKTOP-3UVUISO:11780)
3: In for (v in val) { :
  closing unused connection 10 (<-DESKTOP-3UVUISO:11780)
4: In for (v in val) { :
  closing unused connection 9 (<-DESKTOP-3UVUISO:11780)
5: In for (v in val) { :
  closing unused connection 8 (<-DESKTOP-3UVUISO:11780)
6: In for (v in val) { :
  closing unused connection 7 (<-DESKTOP-3UVUISO:11780)
7: In for (v in val) { :
  closing unused connection 6 (<-DESKTOP-3UVUISO:11780)
8: In for (v in val) { :
  closing unused connection 5 (<-DESKTOP-3UVUISO:11780)
9: In for (v in val) { :
  closing unused connection 4 (<-DESKTOP-3UVUISO:11780)
10: In for (v in val) { :
  closing unused connection 3 (<-DESKTOP-3UVUISO:11780)
> 
> 
> my_stack <- stacks() %>%
+   add_candidates(lightGBM_models) %>%
+   add_candidates(randforest_models)
Warning message:
Predictions from 34 candidates were identical to those from existing candidates and were removed from
the data stack. 
> 
> stack_mod <- my_stack %>%
+   blend_predictions() %>%
+   fit_members()

> car_predictions <- predict(stack_mod, new_data=test, type='prob') %>%
+   rename(IsBadBuy=.pred_1) %>%
+   mutate(RefId = test$RefId) %>%
+   select(RefId, IsBadBuy)
Error in `purrr::map()`:
ℹ In index: 1.
ℹ With name: lightGBM_models_1_047.
Caused by error in `predictor$predict()`:
! Attempting to use a Booster which no longer exists. This can happen if you have called Booster$finalize() or if this Booster was saved with saveRDS(). To avoid this error in the future, use saveRDS.lgb.Booster() or Booster$save_model() to save lightgbm Boosters.
Run `rlang::last_trace()` to see where the error occurred.`
r random-forest purrr prediction lightgbm
1个回答
0
投票

我认为问题出在存储模块上。我与 16 个内核中的 13 个并行运行该脚本。当我用更少的核心运行相同的脚本时,没有错误。

© www.soinside.com 2019 - 2024. All rights reserved.