在另一台计算机上加载 XGBoost 模型时出现问题

数据挖掘 机器学习 r xgboost
2022-02-27 09:30:09

我正在做一个项目,我们正在使用 XGBoost 进行预测。我的同事向我发送了模型文件,但是当我在计算机上加载时,它没有按预期运行。

当我将模型中的一个变量从 0 更改为 1 时,它并没有改变结果(在 200 条不同的行中),所以我开始调查。我们比较了很多不同的结果,结果都是不同的。

我运行xgb_tree它显示max_depth为 0,但它应该是 4。当我运行xgb_tree$results时它显示max_depth = 4.

我们还尝试了很多不同的保存方法(.rda、.rds、.model),但都没有奏效。

欢迎任何建议,谢谢。


编辑:发布 sessionInfo()

他的:

R version 3.2.5 (2016-04-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] plyr_1.8.4            car_2.1-4             acepack_1.4.1         Ckmeans.1d.dp_3.4.6-4
 [5] Hmisc_4.0-0           Formula_1.2-1         survival_2.40-1       memisc_0.99.7-1      
 [9] MASS_7.3-45           Information_0.0.9     minerva_1.4.5         randomForest_4.6-12  
[13] pROC_1.8              xgboost_0.4-4         caret_6.0-73          lattice_0.20-33      
[17] ggplot2_2.2.0         miscTools_0.6-22      reshape_0.8.6         data.table_1.9.8     
[21] dplyr_0.5.0           e1071_1.6-7           lubridate_1.6.0       psych_1.6.9          
[25] readr_1.0.0           stringr_1.1.0         stringi_1.1.2        

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.8         class_7.3-14        assertthat_0.1      digest_0.6.10      
 [5] foreach_1.4.3       R6_2.2.0            MatrixModels_0.4-1  stats4_3.2.5       
 [9] lazyeval_0.2.0      minqa_1.2.4         SparseM_1.74        nloptr_1.0.4       
[13] rpart_4.1-10        Matrix_1.2-4        labeling_0.3        splines_3.2.5      
[17] lme4_1.1-12         foreign_0.8-66      munsell_0.4.3       compiler_3.2.5     
[21] mnormt_1.5-5        mgcv_1.8-12         htmltools_0.3.5     nnet_7.3-12        
[25] tibble_1.2          gridExtra_2.2.1     htmlTable_1.7       codetools_0.2-14   
[29] ModelMetrics_1.1.0  grid_3.2.5          nlme_3.1-125        gtable_0.2.0       
[33] DBI_0.5-1           magrittr_1.5        scales_0.4.1        reshape2_1.4.2     
[37] doParallel_1.0.10   latticeExtra_0.6-28 RColorBrewer_1.1-2  iterators_1.0.8    
[41] tools_3.2.5         parallel_3.2.5      pbkrtest_0.4-6      colorspace_1.3-1   
[45] cluster_2.0.3       knitr_1.15.1        quantreg_5.29

矿:

R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252    LC_MONETARY=Portuguese_Brazil.1252
[4] LC_NUMERIC=C                       LC_TIME=Portuguese_Brazil.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] caret_6.0-73         ggplot2_2.1.0        lattice_0.20-33      plyr_1.8.4           xgboost_0.4-4       
[6] shinydashboard_0.5.3 shiny_0.14.2        

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.8        nloptr_1.0.4       iterators_1.0.8    tools_3.3.1        digest_0.6.10      lme4_1.1-12       
 [7] jsonlite_1.1       nlme_3.1-128       gtable_0.2.0       mgcv_1.8-12        Matrix_1.2-6       foreach_1.4.3     
[13] parallel_3.3.1     SparseM_1.72       stringr_1.1.0      MatrixModels_0.4-1 stats4_3.3.1       grid_3.3.1        
[19] nnet_7.3-12        data.table_1.9.6   R6_2.1.3           minqa_1.2.4        reshape2_1.4.2     car_2.1-3         
[25] magrittr_1.5       scales_0.4.0       codetools_0.2-14   ModelMetrics_1.1.0 htmltools_0.3.5    MASS_7.3-45       
[31] splines_3.3.1      rsconnect_0.4.3    pbkrtest_0.4-6     mime_0.5           xtable_1.8-2       colorspace_1.2-6  
[37] httpuv_1.3.3       quantreg_5.29      stringi_1.1.1      munsell_0.4.3      chron_2.3-47      
1个回答

错误是由于 R 版本造成的。我的同事运行的是 3.2.5,而我运行的是 3.3.1,感谢Stereo ,我可以注意到这一点并在相同的版本上进行测试。