diff --git a/R-package/R/xgb.plot.shap.R b/R-package/R/xgb.plot.shap.R index 6031b69a7..3d1b1adad 100644 --- a/R-package/R/xgb.plot.shap.R +++ b/R-package/R/xgb.plot.shap.R @@ -93,9 +93,12 @@ #' objective = "multi:softprob", num_class = nclass, verbose = 0) #' trees0 <- seq(from=0, by=nclass, length.out=nrounds) #' col <- rgb(0, 0, 1, 0.5) -#' xgb.plot.shap(x, model = mbst, trees = trees0, target_class = 0, top_n = 4, n_col = 2, col = col, pch = 16, pch_NA = 17) -#' xgb.plot.shap(x, model = mbst, trees = trees0 + 1, target_class = 1, top_n = 4, n_col = 2, col = col, pch = 16, pch_NA = 17) -#' xgb.plot.shap(x, model = mbst, trees = trees0 + 2, target_class = 2, top_n = 4, n_col = 2, col = col, pch = 16, pch_NA = 17) +#' xgb.plot.shap(x, model = mbst, trees = trees0, target_class = 0, top_n = 4, +#' n_col = 2, col = col, pch = 16, pch_NA = 17) +#' xgb.plot.shap(x, model = mbst, trees = trees0 + 1, target_class = 1, top_n = 4, +#' n_col = 2, col = col, pch = 16, pch_NA = 17) +#' xgb.plot.shap(x, model = mbst, trees = trees0 + 2, target_class = 2, top_n = 4, +#' n_col = 2, col = col, pch = 16, pch_NA = 17) #' #' @rdname xgb.plot.shap #' @export diff --git a/R-package/man/xgb.plot.shap.Rd b/R-package/man/xgb.plot.shap.Rd index 9dcf7fce8..4cc2f52bc 100644 --- a/R-package/man/xgb.plot.shap.Rd +++ b/R-package/man/xgb.plot.shap.Rd @@ -123,9 +123,12 @@ mbst <- xgboost(data = x, label = as.numeric(iris$Species) - 1, nrounds = nround objective = "multi:softprob", num_class = nclass, verbose = 0) trees0 <- seq(from=0, by=nclass, length.out=nrounds) col <- rgb(0, 0, 1, 0.5) -xgb.plot.shap(x, model = mbst, trees = trees0, target_class = 0, top_n = 4, n_col = 2, col = col, pch = 16, pch_NA = 17) -xgb.plot.shap(x, model = mbst, trees = trees0 + 1, target_class = 1, top_n = 4, n_col = 2, col = col, pch = 16, pch_NA = 17) -xgb.plot.shap(x, model = mbst, trees = trees0 + 2, target_class = 2, top_n = 4, n_col = 2, col = col, pch = 16, pch_NA = 17) +xgb.plot.shap(x, model = mbst, trees = trees0, target_class = 0, top_n = 4, + n_col = 2, col = col, pch = 16, pch_NA = 17) +xgb.plot.shap(x, model = mbst, trees = trees0 + 1, target_class = 1, top_n = 4, + n_col = 2, col = col, pch = 16, pch_NA = 17) +xgb.plot.shap(x, model = mbst, trees = trees0 + 2, target_class = 2, top_n = 4, + n_col = 2, col = col, pch = 16, pch_NA = 17) } \references{ diff --git a/appveyor.yml b/appveyor.yml index 94972d005..285de3ec4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,6 @@ environment: + R_ARCH: x64 + USE_RTOOLS: true matrix: - target: msvc ver: 2013 @@ -15,6 +17,15 @@ environment: - target: mingw generator: "Unix Makefiles" - target: jvm + - target: rmsvc + ver: 2015 + generator: "Visual Studio 14 2015 Win64" + configuration: Release + - target: rmingw + generator: "Unix Makefiles" + +#matrix: +# fast_finish: true platform: - x64 @@ -34,6 +45,16 @@ install: - if /i "%target%" == "mingw" set DO_PYTHON=on - if /i "%target%_%ver%_%configuration%" == "msvc_2015_Release" set DO_PYTHON=on - if /i "%DO_PYTHON%" == "on" conda install -y numpy scipy pandas matplotlib nose scikit-learn graphviz python-graphviz + # R: based on https://github.com/krlmlr/r-appveyor + - ps: | + if($env:target -eq 'rmingw' -or $env:target -eq 'rmsvc') { + #$ErrorActionPreference = "Stop" + Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "$Env:TEMP\appveyor-tool.ps1" + Import-Module "$Env:TEMP\appveyor-tool.ps1" + Bootstrap + $DEPS = "c('data.table','magrittr','stringi','ggplot2','DiagrammeR','Ckmeans.1d.dp','vcd','testthat','igraph','knitr','rmarkdown')" + cmd /c "R.exe -q -e ""install.packages($DEPS, repos='$CRAN', type='win.binary')"" 2>&1" + } build_script: - cd %APPVEYOR_BUILD_FOLDER% @@ -49,12 +70,55 @@ build_script: cmake .. -G"%generator%" && make -j2 ) + # Python package - if /i "%DO_PYTHON%" == "on" ( cd %APPVEYOR_BUILD_FOLDER%\python-package && python setup.py install ) + # R package: make + mingw standard CRAN packaging (only x64 for now) + - if /i "%target%" == "rmingw" ( + make Rbuild && + ls -l && + R.exe CMD INSTALL --no-multiarch xgboost*.tar.gz + ) + # R package: cmake + VC2015 + - if /i "%target%" == "rmsvc" ( + mkdir build_rmsvc%ver% && + cd build_rmsvc%ver% && + cmake .. -G"%generator%" -DCMAKE_CONFIGURATION_TYPES="Release" -DR_LIB=ON && + cmake --build . --target install --config Release + ) - if /i "%target%" == "jvm" cd jvm-packages && mvn test -pl :xgboost4j test_script: - cd %APPVEYOR_BUILD_FOLDER% - if /i "%DO_PYTHON%" == "on" python -m nose tests/python + # mingw R package: run the R check (which includes unit tests), and also keep the built binary package + - if /i "%target%" == "rmingw" ( + set _R_CHECK_CRAN_INCOMING_=FALSE&& + R.exe CMD check xgboost*.tar.gz --no-manual --no-build-vignettes --as-cran --install-args=--build --no-multiarch + ) + # MSVC R package: run only the unit tests + # TODO: create a binary msvc-built package to keep as an artifact + - if /i "%target%" == "rmsvc" ( + cd build_rmsvc%ver%\R-package && + R.exe -q -e "library(testthat); setwd('tests'); source('testthat.R')" + ) + +on_failure: + # keep the whole output of R check + - if /i "%target%" == "rmingw" ( + 7z a failure.zip *.Rcheck\* && + appveyor PushArtifact failure.zip + ) + +artifacts: + # log from R check + - path: '*.Rcheck\**\*.log' + name: Logs + # source R-package + - path: '\xgboost_*.tar.gz' + name: Bits + # binary R-package + - path: '**\xgboost_*.zip' + name: Bits diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake index 5e34a408b..7919c1959 100644 --- a/cmake/Utils.cmake +++ b/cmake/Utils.cmake @@ -82,5 +82,5 @@ function(setup_rpackage_install_target rlib_target build_dir) if(length(deps)>0) install.packages(deps, repo = 'https://cloud.r-project.org/')") install(CODE "execute_process(COMMAND \"${LIBR_EXECUTABLE}\" \"-q\" \"-e\" \"${XGB_DEPS_SCRIPT}\")") install(CODE "execute_process(COMMAND \"${LIBR_EXECUTABLE}\" CMD INSTALL\ - \"--no-multiarch\" \"${build_dir}/R-package\")") + \"--no-multiarch\" \"--build\" \"${build_dir}/R-package\")") endfunction(setup_rpackage_install_target) diff --git a/cmake/modules/FindLibR.cmake b/cmake/modules/FindLibR.cmake index dbb65006d..db2b89a10 100644 --- a/cmake/modules/FindLibR.cmake +++ b/cmake/modules/FindLibR.cmake @@ -86,7 +86,7 @@ else() # attempt to find R executable if(NOT LIBR_EXECUTABLE) - find_program(LIBR_EXECUTABLE R) + find_program(LIBR_EXECUTABLE NAMES R R.exe) endif() if(UNIX) @@ -117,7 +117,7 @@ else() # ask R for R_HOME if(LIBR_EXECUTABLE) execute_process( - COMMAND ${LIBR_EXECUTABLE} "--slave" "--no-save" "-e" "cat(normalizePath(R.home(), winslash='/')" + COMMAND ${LIBR_EXECUTABLE} "--slave" "--no-save" "-e" "cat(normalizePath(R.home(), winslash='/'))" OUTPUT_VARIABLE LIBR_HOME) endif() # if R executable not available, query R_HOME path from registry @@ -138,6 +138,12 @@ else() set(LIBR_INCLUDE_DIRS "${LIBR_HOME}/include") set(LIBR_LIB_DIR "${LIBR_HOME}/bin/${R_ARCH}") +message(STATUS "LIBR_HOME [${LIBR_HOME}]") +message(STATUS "LIBR_EXECUTABLE [${LIBR_EXECUTABLE}]") +message(STATUS "LIBR_INCLUDE_DIRS [${LIBR_INCLUDE_DIRS}]") +message(STATUS "LIBR_LIB_DIR [${LIBR_LIB_DIR}]") +message(STATUS "LIBR_CORE_LIBRARY [${LIBR_CORE_LIBRARY}]") + endif() endif()