首页 > 解决方案 > 安装更新版本的 xgboost

问题描述

我目前从 cran 安装了 xgboost 包,最新版本是 0.9。

在 Github 上,最新版本是 1.1

试过:

devtools::install_github("dmlc/xgboost")
Downloading GitHub repo dmlc/xgboost@master
Error: Failed to install 'xgboost' from GitHub:
  Does not appear to be an R package (no DESCRIPTION)

然后我发现这个讨论与其他人努力安装 xgboost。在该页面上是对位于https://github.com/dmlc/xgboost/archive/master.zip的 zip 文件的引用

因此,我尝试下载 zip 文件,然后手动上传到我的主目录(在浏览器中托管 rstudio)。但是,rstudio 会在上传 zip 文件时自动解压缩,所以我无法devtools::install_local()

devtools::install_local("~/xgboost-master/")
Error: Failed to install 'unknown package' from local:
  cannot open the connection
In addition: Warning messages:
1: In read.dcf(path) :
  cannot open compressed file '/home/rstudio-doug/xgboost-master/DESCRIPTION', probable reason 'No such file or directory'
2: In read.dcf(path) :
  cannot open compressed file '/home/rstudio-doug/xgboost-master/DESCRIPTION', probable reason 'No such file or directory'

那里有一个名为 xgboost-master 的目录。

然后我尝试使用 zipfile 从 url 安装:

devtools::install_url("https://github.com/dmlc/xgboost/archive/master.zip")
Downloading package from url: https://github.com/dmlc/xgboost/archive/master.zip
Error: Failed to install 'unknown package' from URL:
  Does not appear to be an R package (no DESCRIPTION)

类似的消息。

我也试过吃豆子:

pacman::p_install_gh("dmlc/xgboost")
Downloading GitHub repo dmlc/xgboost@master
Installation failed: NULL : Failed to install 'xgboost' from GitHub:
  Does not appear to be an R package (no DESCRIPTION)

The following packages were not able to be installed:
xgboost
Warning message:
In pacman::p_install_gh("dmlc/xgboost") :
  The following may have incorrect capitalization specification:

xgboost

如何安装 xgboost 1.1?

sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Amazon Linux 2

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] curl_4.3            httr_1.4.1          devtools_2.3.0.9000 usethis_1.6.1      

loaded via a namespace (and not attached):
 [1] Metrics_0.1.4       xfun_0.15           remotes_2.1.1       noctua_1.6.0.9000  
 [5] lattice_0.20-38     vctrs_0.3.1         testthat_2.3.2      htmltools_0.5.0    
 [9] yaml_2.2.1          utf8_1.1.4          rlang_0.4.6         pkgbuild_1.0.8.9000
[13] pillar_1.4.4        glue_1.4.1          withr_2.2.0         DBI_1.1.0          
[17] sessioninfo_1.1.1   paws_0.1.7          evaluate_0.14       memoise_1.1.0      
[21] knitr_1.29          callr_3.4.3         ps_1.3.3            fansi_0.4.1        
[25] Rcpp_1.0.4.6        readr_1.3.1         BiocManager_1.30.10 backports_1.1.8    
[29] desc_1.2.0          pkgload_1.1.0       fs_1.4.2            MLmetrics_1.1.1    
[33] hms_0.5.3           packrat_0.5.0       digest_0.6.25       stringi_1.4.6      
[37] processx_3.4.3      grid_3.6.0          rprojroot_1.3-2     cli_2.0.2          
[41] tools_3.6.0         magrittr_1.5        tibble_3.0.1        pacman_0.5.1       
[45] crayon_1.3.4        pkgconfig_2.0.3     zeallot_0.1.0       ellipsis_0.3.1     
[49] Matrix_1.2-18       data.table_1.12.8   prettyunits_1.1.1   assertthat_0.2.1   
[53] rmarkdown_2.1       rstudioapi_0.11     R6_2.4.1            compiler_3.6.0    

标签: rdevtools

解决方案


xgboost 的 github 存储库将 R 包代码保存在子目录中,而不是像大多数 R 包那样位于主目录中。你会看到DESCRIPTION里面有。尝试

devtools::install_github("dmlc/xgboost", subdir="R-package")

推荐阅读