# LightGBM R-package
[![CRAN Version](https://www.r-pkg.org/badges/version/lightgbm)](https://cran.r-project.org/package=lightgbm)
[![Downloads](https://cranlogs.r-pkg.org/badges/grand-total/lightgbm)](https://cran.r-project.org/package=lightgbm)
[![API Docs](https://readthedocs.org/projects/lightgbm/badge/?version=latest)](https://lightgbm.readthedocs.io/en/latest/R/reference/)
<img src="man/figures/logo.svg" align="right" alt="" width="175" />
### Contents
* [Installation](#installation)
- [Installing the CRAN Package](#installing-the-cran-package)
- [Installing from Source with CMake](#install)
- [Installing a GPU-enabled Build](#installing-a-gpu-enabled-build)
- [Installing Precompiled Binaries](#installing-precompiled-binaries)
- [Installing from a Pre-compiled lib_lightgbm](#lib_lightgbm)
* [Examples](#examples)
* [Testing](#testing)
* [Preparing a CRAN Package](#preparing-a-cran-package)
* [External Repositories](#external-unofficial-repositories)
* [Known Issues](#known-issues)
Installation
------------
For the easiest installation, go to ["Installing the CRAN package"](#installing-the-cran-package).
If you experience any issues with that, try ["Installing from Source with CMake"](#install). This can produce a more efficient version of the library on Windows systems with Visual Studio.
To build a GPU-enabled version of the package, follow the steps in ["Installing a GPU-enabled Build"](#installing-a-gpu-enabled-build).
If any of the above options do not work for you or do not meet your needs, please let the maintainers know by [opening an issue](https://github.com/microsoft/LightGBM/issues).
When your package installation is done, you can check quickly if your LightGBM R-package is working by running the following:
```r
library(lightgbm)
data(agaricus.train, package='lightgbm')
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)
model <- lgb.cv(
params = list(
objective = "regression"
, metric = "l2"
)
, data = dtrain
)
```
### Installing the CRAN package
`{lightgbm}` is [available on CRAN](https://cran.r-project.org/package=lightgbm), and can be installed with the following R code.
```r
install.packages("lightgbm", repos = "https://cran.r-project.org")
```
This is the easiest way to install `{lightgbm}`. It does not require `CMake` or `Visual Studio`, and should work well on many different operating systems and compilers.
Each CRAN package is also available on [LightGBM releases](https://github.com/microsoft/LightGBM/releases), with a name like `lightgbm-{VERSION}-r-cran.tar.gz`.
#### Custom Installation (Linux, Mac)
The steps above should work on most systems, but users with highly-customized environments might want to change how R builds packages from source.
To change the compiler used when installing the CRAN package, you can create a file `~/.R/Makevars` which overrides `CC` (`C` compiler) and `CXX` (`C++` compiler).
For example, to use `gcc` instead of `clang` on Mac, you could use something like the following:
```make
# ~/.R/Makevars
CC=gcc-8
CXX=g++-8
CXX11=g++-8
```
### Installing from Source with CMake <a name="install"></a>
You need to install git and [CMake](https://cmake.org/) first.
Note: this method is only supported on 64-bit systems. If you need to run LightGBM on 32-bit Windows (i386), follow the instructions in ["Installing the CRAN Package"](#installing-the-cran-package).
#### Windows Preparation
NOTE: Windows users may need to run with administrator rights (either R or the command prompt, depending on the way you are installing this package).
Installing a 64-bit version of [Rtools](https://cran.r-project.org/bin/windows/Rtools/) is mandatory.
After installing `Rtools` and `CMake`, be sure the following paths are added to the environment variable `PATH`. These may have been automatically added when installing other software.
* `Rtools`
- If you have `Rtools` 3.x, example:
- `C:\Rtools\mingw_64\bin`
- If you have `Rtools` 4.0, example:
- `C:\rtools40\mingw64\bin`
- `C:\rtools40\usr\bin`
* `CMake`
- example: `C:\Program Files\CMake\bin`
* `R`
- example: `C:\Program Files\R\R-3.6.1\bin`
NOTE: Two `Rtools` paths are required from `Rtools` 4.0 onwards because paths and the list of included software was changed in `Rtools` 4.0.
#### Windows Toolchain Options
A "toolchain" refers to the collection of software used to build the library. The R package can be built with three different toolchains.
**Warning for Windows users**: it is recommended to use *Visual Studio* for its better multi-threading efficiency in Windows for many core systems. For very simple systems (dual core computers or worse), MinGW64 is recommended for maximum performance. If you do not know what to choose, it is recommended to use [Visual Studio](https://visualstudio.microsoft.com/downloads/), the default compiler. **Do not try using MinGW in Windows on many core systems. It may result in 10x slower results than Visual Studio.**
**Visual Studio (default)**
By default, the package will be built with [Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/).
**MinGW (R 3.x)**
If you are using R 3.x and installation fails with Visual Studio, `LightGBM` will fall back to using [MinGW](http://mingw-w64.org/doku.php) bundled with `Rtools`.
If you want to force `LightGBM` to use MinGW (for any R version), pass `--use-mingw` to the installation script.
```shell
Rscript build_r.R --use-mingw
```
**MSYS2 (R 4.x)**
If you are using R 4.x and installation fails with Visual Studio, `LightGBM` will fall back to using [MSYS2](https://www.msys2.org/). This should work with the tools already bundled in `Rtools` 4.0.
If you want to force `LightGBM` to use MSYS2 (for any R version), pass `--use-msys2` to the installation script.
```shell
Rscript build_r.R --use-msys2
```
#### Mac OS Preparation
You can perform installation either with **Apple Clang** or **gcc**. In case you prefer **Apple Clang**, you should install **OpenMP** (details for installation can be found in [Installation Guide](https://github.com/microsoft/LightGBM/blob/master/docs/Installation-Guide.rst#apple-clang)) first and **CMake** version 3.16 or higher is required. In case you prefer **gcc**, you need to install it (details for installation can be found in [Installation Guide](https://github.com/microsoft/LightGBM/blob/master/docs/Installation-Guide.rst#gcc)) and set some environment variables to tell R to use `gcc` and `g++`. If you install these from Homebrew, your versions of `g++` and `gcc` are most likely in `/usr/local/bin`, as shown below.
```
# replace 8 with version of gcc installed on your machine
export CXX=/usr/local/bin/g++-8 CC=/usr/local/bin/gcc-8
```
#### Install with CMake
After following the "preparation" steps above for your operating system, build and install the R-package with the following commands:
```sh
git clone --recursive https://github.com/microsoft/LightGBM
cd LightGBM
Rscript build_r.R
```
The `build_r.R` script builds the package in a temporary directory called `lightgbm_r`. It will destroy and recreate that directory each time you run the script. That script supports the following command-line options:
- `--skip-install`: Build the package tarball, but do not install it.
- `--use-gpu`: Build a GPU-enabled version of the library.
- `--use-mingw`: Force the use of MinGW toolchain, regardless of R version.
- `--use-msys2`: Force the use of MSYS2 toolchain, regardless of R version.
Note: for the build with Visual Studio/VS Build Tools in Windows, you should use the Windows CMD or PowerShell.
### Installing a GPU-enabled Build
You will need to install Boost and OpenCL first: details for installation can be found in [Installation-Guide](https://github.com/microsoft/LightGBM/blob/master/docs/Installation-Guide.rst#build-gpu-version).
After installing these other libraries, follow the steps in ["Inst
没有合适的资源?快使用搜索试试~ 我知道了~
LightGBM:基于决策树算法的快速,分布式,高性能梯度提升(GBT,GBDT,GBRT,GBM或MART)框架,用于排名,分...
共466个文件
r:50个
png:47个
h:41个
10 下载量 99 浏览量
2021-05-10
17:29:45
上传
评论 2
收藏 6.71MB ZIP 举报
温馨提示
轻梯度升压机 LightGBM是使用基于树的学习算法的梯度增强框架。 它被设计为分布式且高效的,具有以下优点: 更快的训练速度和更高的效率。 降低内存使用率。 更好的准确性。 支持并行,分布式和GPU学习。 能够处理大规模数据。 有关更多详细信息,请参阅。 受益于这些优势,LightGBM被广泛用于许多机器学习竞赛的中。 在公共数据集上进行的表明,LightGBM可以在效率和准确性上均优于现有的Boosting框架,并且显着降低了内存消耗。 此外, 表明,LightGBM通过使用多台机器进行特定设置的训练可以实现线性加速。 入门和文档 我们的主要文档位于并从此存储库生成。 如果您不熟悉LightGBM,请按照站点上进行。 接下来,您可能需要阅读: 显示了常见任务的命令行用法。 LightGBM支持的和算法。 是您可以进行的自定义的详尽列表。 和可以加快计算速度。
资源详情
资源评论
资源推荐
收起资源包目录
LightGBM:基于决策树算法的快速,分布式,高性能梯度提升(GBT,GBDT,GBRT,GBM或MART)框架,用于排名,分类和许多其他机器学习任务 (466个子文件)
00Index 641B
configure.ac 3KB
AUTOCONF_UBUNTU_VERSION 10B
make.bat 799B
LightGBM_logo.cdr 422KB
LightGBM-logo-hex.cdr 416KB
histogram16.cl 41KB
histogram64.cl 33KB
histogram256.cl 33KB
cleanup 29B
FindLibR.cmake 7KB
IntegratedOpenCL.cmake 5KB
Sanitizer.cmake 2KB
FindASan.cmake 376B
FindUBSan.cmake 333B
FindLSan.cmake 311B
FindTSan.cmake 311B
CODEOWNERS 2KB
train.conf 3KB
train.conf 3KB
train_linear.conf 3KB
train.conf 3KB
train.conf 3KB
train.conf 3KB
train.conf 2KB
train.conf 86B
predict.conf 76B
predict.conf 72B
predict.conf 72B
predict.conf 68B
predict.conf 68B
predict.conf 66B
predict.conf 66B
configure 86KB
c_api.cpp 96KB
dataset_loader.cpp 59KB
dataset.cpp 56KB
gpu_tree_learner.cpp 52KB
tree.cpp 41KB
cuda_tree_learner.cpp 39KB
serial_tree_learner.cpp 34KB
gbdt.cpp 31KB
bin.cpp 29KB
config_auto.cpp 25KB
lightgbm_R.cpp 24KB
voting_parallel_tree_learner.cpp 24KB
gbdt_model_text.cpp 23KB
json11.cpp 22KB
metadata.cpp 19KB
train_share_states.cpp 16KB
config.cpp 16KB
linear_tree_learner.cpp 14KB
network.cpp 13KB
data_parallel_tree_learner.cpp 13KB
application.cpp 10KB
test_chunked_array.cpp 9KB
parser.cpp 8KB
linkers_socket.cpp 7KB
linker_topo.cpp 6KB
dcg_calculator.cpp 6KB
test_common.cpp 6KB
file_io.cpp 5KB
objective_function.cpp 4KB
gbdt_prediction.cpp 4KB
feature_parallel_tree_learner.cpp 3KB
ifaddrs_patch.cpp 3KB
metric.cpp 2KB
prediction_early_stop.cpp 2KB
tree_learner.cpp 2KB
boosting.cpp 2KB
linkers_mpi.cpp 2KB
main.cpp 912B
test_main.cpp 355B
histogram_16_64_256.cu 36KB
cuda_kernel_launcher.cu 8KB
categorical.data 292KB
DESCRIPTION 3KB
dockerfile-cli 511B
dockerfile-python 904B
dockerfile-r 324B
.editorconfig 479B
LightGBM.vcxproj.filters 12KB
.gitignore 6KB
.gitignore 6B
.gitkeep 0B
.gitmodules 445B
dockerfile.gpu 5KB
dockerfile-cli-only-distroless.gpu 3KB
dockerfile-cli-only.gpu 2KB
c_api.h 66KB
config.h 63KB
common.h 32KB
tree.h 26KB
dataset.h 24KB
feature_group.h 19KB
gbdt.h 19KB
bin.h 17KB
lightgbm_R.h 16KB
network.h 12KB
gpu_tree_learner.h 11KB
共 466 条
- 1
- 2
- 3
- 4
- 5
普通网友
- 粉丝: 24
- 资源: 4570
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0