安装更新版本的 xgboost

Install more recent version of xgboost

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

On Github, the latest version is 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)

然后我找到了this discussion with someone else struggling to install xgboost. On that page is a reference to the zip file at https://github.com/dmlc/xgboost/archive/master.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 的目录。

然后我尝试使用压缩文件从 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:

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    

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

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

这在 Windows 下有效。 您可以从 Github xcboost root directory.
下载完整的 xgboost 包 您将获得一个 Zip 文件,其中包含一个 R-Package 目录。
将此目录解压缩到一个临时文件夹,例如。 ~/Temp/R-Package并再次制作一个 Zip 文件:R-Package.Zip

运行 :

install.packages("~/Temp/R-package.zip", repos = NULL, type = "win.binary")
packageVersion('xgboost')
[1] ‘1.0.0.2’

CRAN 版本看起来是最新的(https://cran.r-project.org/web/packages/xgboost/index.html 显示 v1.1.1.1)。卸载 xgboost 并使用 install.packages("xgboost") 安装应该提供版本 1.1.1.1.

另一种选择是来自 github (https://xgboost.readthedocs.io/en/latest/build.html#installing-the-development-version) 的开发版本:

git clone --recursive https://github.com/dmlc/xgboost
cd xgboost
git submodule init
git submodule update
mkdir build
cd build
cmake .. -DR_LIB=ON
make -j$(nproc)
make install

我也在尝试安装 xgboost R 包,但它在 RHEL 7 上失败并出现以下错误。

R 版本 3.6.3

Error: package or namespace load failed for ‘xgboost’ in library.dynam(lib, package, package.lib):
 shared object ‘xgboost.so’ not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/root/R/x86_64-pc-linux-gnu-library/3.6/xgboost’

The downloaded source packages are in
        ‘/tmp/RtmpyH6aZ3/downloaded_packages’
Warning message:
In install.packages("xgboost") :
  installation of package ‘xgboost’ had non-zero exit status