lgb.dl: Install LightGBM from source

Description Usage Arguments Details Value Examples

Description

Downloads and install LightGBM from repository. Allows to customize the commit/branch used, the compiler, use a precompiled lib/dll, the link to the repository (if using a custom fork), and the number of cores used (for non-Visual Studio compilations). Requires git and compiler make (or mingw32-make for MinGW) in PATH environment variable. Windows uses \\ (backward slashes) while Linux uses / (forward slashes) but you can mix them.

Usage

1
2
3
lgb.dl(commit = "master", compiler = "gcc", libdll = "",
  repo = "https://github.com/Microsoft/LightGBM", use_gpu = FALSE,
  cores = 1)

Arguments

commit

The commit / branch to use. Put "" for master branch. Defaults to "master".

compiler

Applicable only to Windows. The compiler to use (either "gcc" for MinGW or "vs" for Visual Studio). Defaults to "gcc".

libdll

Applicable only if you use a precompiled dll/lib. The precompiled dll/lib to use. Defaults to "".

repo

The link to the repository. Defaults to "https://github.com/Microsoft/LightGBM".

use_gpu

Whether to install with GPU enabled or not. Defaults to FALSE.

cores

The number of cores to use for compilation, ignored for Visual Studio. Defaults to 1.

Details

This installation function supports only Windows (Visual Studio and MinGW) and Linux (gcc and any other compiler making use of make). Performance of Visual Studio is higher when multithreading is heavy, while MinGW performance is higher when you are using a domestic computer (low number of physical cores, like 2 or 4).

Check here for more details: Laurae's Microsoft/LightGBM#542 (Visual Studio reports higher CPU usage than MinGW). and guolinke's Microsoft/LightGBM#584 (Compile R package by custom tool chain).

Value

A logical describing whether the LightGBM package was installed or not (TRUE if installed, FALSE if installation failed AND you did not have the package before).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## Not run: 
# Install using Visual Studio
# (Download: http://landinghub.visualstudio.com/visual-cpp-build-tools)
lgb.dl(commit = "master",
       compiler = "vs",
       repo = "https://github.com/Microsoft/LightGBM")

# Install using Rtools MinGW or use Linux compilation
lgb.dl(commit = "master",
       compiler = "gcc",
       repo = "https://github.com/Microsoft/LightGBM",
       cores = 2)

# Install using precompiled DLL in Windows
lgb.dl(commit = "master",
       libdll = "C:\\xgboost\\LightGBM\\windows\\x64\\DLL\\lib_lightgbm.dll",
       repo = "https://github.com/Microsoft/LightGBM",
       cores = 2)

# Test package
library(lightgbm)
data(agaricus.train, package = "lightgbm")
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)
data(agaricus.test, package = "lightgbm")
test <- agaricus.test
dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
params <- list(objective = "regression", metric = "l2")
valids <- list(test = dtest)
model <- lgb.train(params,
                   dtrain,
                   100,
                   valids,
                   min_data = 1,
                   learning_rate = 1,
                   early_stopping_rounds = 10)

## End(Not run)

Laurae2/lgbdl documentation built on May 20, 2019, 2:42 p.m.