diff --git a/.ci/README.md b/.ci/README.md
new file mode 100644
index 000000000000..3805703d0f8c
--- /dev/null
+++ b/.ci/README.md
@@ -0,0 +1,6 @@
+Helper Scripts for CI
+=====================
+
+This folder contains scripts which are run on CI services.
+
+Dockerfile used on CI service is maintained in a separate [GitHub repository](https://github.com/guolinke/lightgbm-ci-docker) and can be pulled from [Docker Hub](https://hub.docker.com/r/lightgbm/vsts-agent).
diff --git a/.ci/dockers/ubuntu-14.04/Dockerfile b/.ci/dockers/ubuntu-14.04/Dockerfile
deleted file mode 100644
index fe6527b1d17d..000000000000
--- a/.ci/dockers/ubuntu-14.04/Dockerfile
+++ /dev/null
@@ -1,79 +0,0 @@
-FROM microsoft/vsts-agent:ubuntu-14.04
-
-# Install basic command-line utilities
-RUN apt-get update \
- && apt-get install -y --no-install-recommends \
- curl \
- locales \
- sudo \
- unzip \
- wget \
- zip \
- && rm -rf /var/lib/apt/lists/*
-
-# Setup the locale
-ENV LANG en_US.UTF-8
-ENV LC_ALL $LANG
-RUN locale-gen $LANG \
- && update-locale
-
-# Install essential build tools
-RUN apt-get update \
- && apt-get install -y --no-install-recommends \
- build-essential \
- && rm -rf /var/lib/apt/lists/*
-
-# Install clang 7.0
-RUN add-apt-repository ppa:ubuntu-toolchain-r/test -y \
- && cd /tmp \
- && wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \
- && add-apt-repository "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-7 main" -y \
- && apt-get update \
- && apt-get install -y --no-install-recommends \
- clang-7 \
- libomp-7-dev \
- && rm -rf /var/lib/apt/lists/*
-
-# Install CMake
-RUN curl -sL https://cmake.org/files/v3.14/cmake-3.14.1-Linux-x86_64.sh -o cmake.sh \
- && chmod +x cmake.sh \
- && ./cmake.sh --prefix=/usr/local --exclude-subdir \
- && rm cmake.sh
-
-# Install Java
-RUN add-apt-repository ppa:openjdk-r/ppa -y \
- && apt-get update \
- && apt-get install -y --no-install-recommends \
- openjdk-8-jdk \
- && rm -rf /var/lib/apt/lists/*
-
-ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
-
-# Install SWIG
-RUN curl -sL https://downloads.sourceforge.net/project/swig/swig/swig-3.0.12/swig-3.0.12.tar.gz -o swig.tar.gz \
- && tar -xzf swig.tar.gz \
- && cd swig-3.0.12 \
- && ./configure --prefix=/usr/local --without-pcre \
- && make \
- && make install \
- && cd .. \
- && rm swig.tar.gz \
- && rm -rf swig-3.0.12
-
-# Install Miniconda
-RUN curl -sL https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -o miniconda.sh \
- && chmod +x miniconda.sh \
- && ./miniconda.sh -b -p /opt/conda \
- && rm miniconda.sh \
- && /opt/conda/bin/conda install python=3 -q -y \
- && /opt/conda/bin/conda install mkl qt -q -y \
- && /opt/conda/bin/conda clean -a -y \
- && chmod -R 777 /opt/conda
-
-ENV CONDA=/opt/conda/
-
-# Clean system
-RUN apt-get clean \
- && rm -rf /var/lib/apt/lists/* \
- && rm -rf /etc/apt/sources.list.d/* \
- && rm -rf /tmp/*
diff --git a/.ci/setup.sh b/.ci/setup.sh
index a91a944a8814..f8bc41726bc5 100755
--- a/.ci/setup.sh
+++ b/.ci/setup.sh
@@ -22,6 +22,9 @@ if [[ $OS_NAME == "macos" ]]; then
if [[ $TASK == "mpi" ]]; then
brew install open-mpi
fi
+ if [[ $AZURE == "true" ]] && [[ $TASK == "sdist" ]]; then
+ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f3544543a3115023fc7ca962c21d14b443f419d0/Formula/swig.rb # swig 3.0.12
+ fi
wget -q -O conda.sh https://repo.continuum.io/miniconda/Miniconda${PYTHON_VERSION:0:1}-latest-MacOSX-x86_64.sh
else # Linux
if [[ $AZURE == "true" ]] && [[ $COMPILER == "clang" ]]; then
diff --git a/.ci/test.sh b/.ci/test.sh
index 6830bebbd974..f397df135bc5 100755
--- a/.ci/test.sh
+++ b/.ci/test.sh
@@ -18,19 +18,6 @@ else
CMAKE_OPTS=()
fi
-if [[ $AZURE == "true" ]] && [[ $OS_NAME == "linux" ]] && [[ $TASK == "swig" ]]; then
- mkdir $BUILD_DIRECTORY/build && cd $BUILD_DIRECTORY/build
- cmake -DUSE_SWIG=ON "${CMAKE_OPTS[@]}" ..
- make -j4 || exit -1
- if [[ $COMPILER == "gcc" ]]; then
- objdump -T $BUILD_DIRECTORY/lib_lightgbm.so > $BUILD_DIRECTORY/objdump.log || exit -1
- objdump -T $BUILD_DIRECTORY/lib_lightgbm_swig.so >> $BUILD_DIRECTORY/objdump.log || exit -1
- python $BUILD_DIRECTORY/helpers/check_dynamic_dependencies.py $BUILD_DIRECTORY/objdump.log || exit -1
- fi
- cp $BUILD_DIRECTORY/build/lightgbmlib.jar $BUILD_ARTIFACTSTAGINGDIRECTORY/lightgbmlib.jar
- exit 0
-fi
-
conda create -q -y -n $CONDA_ENV python=$PYTHON_VERSION
source activate $CONDA_ENV
@@ -91,6 +78,19 @@ if [[ $TASK == "sdist" ]]; then
pip install --user $BUILD_DIRECTORY/python-package/dist/lightgbm-$LGB_VER.tar.gz -v || exit -1
if [[ $AZURE == "true" ]]; then
cp $BUILD_DIRECTORY/python-package/dist/lightgbm-$LGB_VER.tar.gz $BUILD_ARTIFACTSTAGINGDIRECTORY
+ mkdir $BUILD_DIRECTORY/build && cd $BUILD_DIRECTORY/build
+ if [[ $OS_NAME == "macos" ]]; then
+ cmake -DUSE_SWIG=ON -DAPPLE_OUTPUT_DYLIB=ON "${CMAKE_OPTS[@]}" ..
+ else
+ cmake -DUSE_SWIG=ON "${CMAKE_OPTS[@]}" ..
+ fi
+ make -j4 || exit -1
+ if [[ $OS_NAME == "linux" ]] && [[ $COMPILER == "gcc" ]]; then
+ objdump -T $BUILD_DIRECTORY/lib_lightgbm.so > $BUILD_DIRECTORY/objdump.log || exit -1
+ objdump -T $BUILD_DIRECTORY/lib_lightgbm_swig.so >> $BUILD_DIRECTORY/objdump.log || exit -1
+ python $BUILD_DIRECTORY/helpers/check_dynamic_dependencies.py $BUILD_DIRECTORY/objdump.log || exit -1
+ fi
+ cp $BUILD_DIRECTORY/build/lightgbmlib.jar $BUILD_ARTIFACTSTAGINGDIRECTORY/lightgbmlib_$OS_NAME.jar
fi
pytest $BUILD_DIRECTORY/tests/python_package_test || exit -1
exit 0
diff --git a/.ci/test_windows.ps1 b/.ci/test_windows.ps1
index e4425266695e..eececf18cdcd 100644
--- a/.ci/test_windows.ps1
+++ b/.ci/test_windows.ps1
@@ -20,6 +20,15 @@ elseif ($env:TASK -eq "sdist") {
cd $env:BUILD_SOURCESDIRECTORY/python-package
python setup.py sdist --formats gztar ; Check-Output $?
cd dist; pip install @(Get-ChildItem *.gz) -v ; Check-Output $?
+
+ $env:JAVA_HOME = $env:JAVA_HOME_8_X64 # there is pre-installed Zulu OpenJDK-8 somewhere
+ Invoke-WebRequest -Uri "https://sourceforge.net/projects/swig/files/swigwin/swigwin-3.0.12/swigwin-3.0.12.zip/download" -OutFile $env:BUILD_SOURCESDIRECTORY/swig/swigwin.zip -UserAgent "NativeHost"
+ Add-Type -AssemblyName System.IO.Compression.FileSystem
+ [System.IO.Compression.ZipFile]::ExtractToDirectory("$env:BUILD_SOURCESDIRECTORY/swig/swigwin.zip", "$env:BUILD_SOURCESDIRECTORY/swig")
+ $env:PATH += ";$env:BUILD_SOURCESDIRECTORY/swig/swigwin-3.0.12"
+ mkdir $env:BUILD_SOURCESDIRECTORY/build; cd $env:BUILD_SOURCESDIRECTORY/build
+ cmake -A x64 -DUSE_SWIG=ON .. ; cmake --build . --target ALL_BUILD --config Release ; Check-Output $?
+ cp $env:BUILD_SOURCESDIRECTORY/build/lightgbmlib.jar $env:BUILD_ARTIFACTSTAGINGDIRECTORY/lightgbmlib_win.jar
}
elseif ($env:TASK -eq "bdist") {
cd $env:BUILD_SOURCESDIRECTORY/python-package
diff --git a/R-package/R/lgb.prepare.R b/R-package/R/lgb.prepare.R
index 2f556ef42289..e0f30d619be2 100644
--- a/R-package/R/lgb.prepare.R
+++ b/R-package/R/lgb.prepare.R
@@ -26,6 +26,7 @@
#' # $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
#' # $ Species : num 1 1 1 1 1 1 1 1 1 1 ...
#'
+#' \dontrun{
#' # When lightgbm package is installed, and you do not want to load it
#' # You can still use the function!
#' lgb.unloader()
@@ -36,6 +37,7 @@
#' # $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
#' # $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
#' # $ Species : num 1 1 1 1 1 1 1 1 1 1 ...
+#' }
#'
#' @export
lgb.prepare <- function(data) {
diff --git a/R-package/R/lgb.prepare2.R b/R-package/R/lgb.prepare2.R
index afc8c1599375..b0730fb7cb2f 100644
--- a/R-package/R/lgb.prepare2.R
+++ b/R-package/R/lgb.prepare2.R
@@ -27,6 +27,7 @@
#' # $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
#' # $ Species : int 1 1 1 1 1 1 1 1 1 1 ...
#'
+#' \dontrun{
#' # When lightgbm package is installed, and you do not want to load it
#' # You can still use the function!
#' lgb.unloader()
@@ -37,6 +38,7 @@
#' # $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
#' # $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
#' # $ Species : int 1 1 1 1 1 1 1 1 1 1 ...
+#' }
#'
#' @export
lgb.prepare2 <- function(data) {
diff --git a/R-package/R/lgb.unloader.R b/R-package/R/lgb.unloader.R
index d3f68568701e..00aa7e3f9db7 100644
--- a/R-package/R/lgb.unloader.R
+++ b/R-package/R/lgb.unloader.R
@@ -25,12 +25,15 @@
#' min_data = 1,
#' learning_rate = 1,
#' early_stopping_rounds = 10)
+#'
+#' \dontrun{
#' lgb.unloader(restore = FALSE, wipe = FALSE, envir = .GlobalEnv)
#' rm(model, dtrain, dtest) # Not needed if wipe = TRUE
#' gc() # Not needed if wipe = TRUE
#'
#' library(lightgbm)
#' # Do whatever you want again with LightGBM without object clashing
+#' }
#'
#' @export
lgb.unloader <- function(restore = TRUE, wipe = FALSE, envir = .GlobalEnv) {
diff --git a/R-package/README.md b/R-package/README.md
index 1b9531d1533a..de784b59310c 100644
--- a/R-package/README.md
+++ b/R-package/README.md
@@ -116,12 +116,12 @@ You may also read [Microsoft/LightGBM#912](https://github.com/microsoft/LightGBM
Examples
--------
-Please visit [demo](demo):
-
-* [Basic walkthrough of wrappers](demo/basic_walkthrough.R)
-* [Boosting from existing prediction](demo/boost_from_prediction.R)
-* [Early Stopping](demo/early_stopping.R)
-* [Cross Validation](demo/cross_validation.R)
-* [Multiclass Training/Prediction](demo/multiclass.R)
-* [Leaf (in)Stability](demo/leaf_stability.R)
-* [Weight-Parameter Adjustment Relationship](demo/weight_param.R)
+Please visit [demo](https://github.com/microsoft/LightGBM/tree/docs/R-package/demo):
+
+* [Basic walkthrough of wrappers](https://github.com/microsoft/LightGBM/blob/master/R-package/demo/basic_walkthrough.R)
+* [Boosting from existing prediction](https://github.com/microsoft/LightGBM/blob/master/R-package/demo/boost_from_prediction.R)
+* [Early Stopping](https://github.com/microsoft/LightGBM/blob/master/R-package/demo/early_stopping.R)
+* [Cross Validation](https://github.com/microsoft/LightGBM/blob/master/R-package/demo/cross_validation.R)
+* [Multiclass Training/Prediction](https://github.com/microsoft/LightGBM/blob/master/R-package/demo/multiclass.R)
+* [Leaf (in)Stability](https://github.com/microsoft/LightGBM/blob/master/R-package/demo/leaf_stability.R)
+* [Weight-Parameter Adjustment Relationship](https://github.com/microsoft/LightGBM/blob/master/R-package/demo/weight_param.R)
diff --git a/R-package/_pkgdown.yml b/R-package/_pkgdown.yml
index 9cf6f6d8ad66..00f41798e566 100644
--- a/R-package/_pkgdown.yml
+++ b/R-package/_pkgdown.yml
@@ -2,6 +2,10 @@ template:
params:
bootswatch: united
+site:
+ root: ''
+ title: LightGBM, Light Gradient Boosting Machine
+
authors:
Guolin Ke:
href: https://github.com/guolinke
@@ -14,15 +18,22 @@ authors:
html: Yachen Yan
James Lamb:
href: https://github.com/jameslamb
- html: James Lamb
-
+ html: James Lamb
-site:
- root: ''
- title: LightGBM, Light Gradient Boosting Machine
+navbar:
+ title: LightGBM
+ type: default
+ left:
+ - icon: fa-home fa-lg
+ href: index.html
+ - text: Reference
+ href: reference/index.html
+ right:
+ - icon: fa-github fa-lg
+ href: https://github.com/microsoft/LightGBM/tree/master/R-package
reference:
- - title: Dataset
+ - title: Datasets
desc: Datasets included with the R package
contents:
- '`agaricus.test`'
@@ -52,7 +63,7 @@ reference:
- '`lgb.cv`'
- '`lgb.train`'
- title: Saving / Loading Models
- desc: Save and Load LightGBM models
+ desc: Save and load LightGBM models
contents:
- '`lgb.dump`'
- '`lgb.load`'
@@ -73,52 +84,3 @@ reference:
desc: Ungroupable functions to troubleshoot LightGBM
contents:
- '`lgb.unloader`'
-
-navbar:
- title: LightGBM
- type: default
- left:
- - icon: fa-home fa-lg
- href: index.html
- - text: Reference
- href: reference/index.html
- - text: Vignettes
- menu:
- - text: Basic Walkthrough
- href: articles/basic_walkthrough.html
- - text: Boosting from existing prediction
- href: articles/boost_from_prediction.html
- - text: Categorical Feature Preparation
- href: articles/categorical_features_prepare.html
- - text: Categorical Feature Preparation with Rule
- href: articles/categorical_features_rules.html
- - text: Cross Validation
- href: articles/cross_validation.html
- - text: Early Stop in training
- href: articles/early_stopping.html
- - text: Efficiency for Many Model Trainings
- href: articles/efficient_many_training.html
- - text: Leaf (in)Stability example
- href: articles/leaf_stability.html
- - text: Multiclass training/prediction
- href: articles/multiclass.html
- - text: Weight-Parameter adjustment relationship
- href: articles/weight_param.html
- right:
- - icon: fa-github fa-lg
- href: https://github.com/Microsoft/LightGBM
-
-articles:
-- title: Vignettes
- desc: ~
- contents:
- - '`basic_walkthrough`'
- - '`boost_from_prediction`'
- - '`categorical_features_prepare`'
- - '`categorical_features_rules`'
- - '`cross_validation`'
- - '`early_stopping`'
- - '`efficient_many_training`'
- - '`leaf_stability`'
- - '`multiclass`'
- - '`weight_param`'
diff --git a/R-package/man/agaricus.test.Rd b/R-package/man/agaricus.test.Rd
deleted file mode 100644
index dcff0241b7c5..000000000000
--- a/R-package/man/agaricus.test.Rd
+++ /dev/null
@@ -1,31 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lightgbm.R
-\docType{data}
-\name{agaricus.test}
-\alias{agaricus.test}
-\title{Test part from Mushroom Data Set}
-\format{A list containing a label vector, and a dgCMatrix object with 1611
-rows and 126 variables}
-\usage{
-data(agaricus.test)
-}
-\description{
-This data set is originally from the Mushroom data set,
-UCI Machine Learning Repository.
-}
-\details{
-This data set includes the following fields:
-
-\itemize{
- \item \code{label} the label for each record
- \item \code{data} a sparse Matrix of \code{dgCMatrix} class, with 126 columns.
-}
-}
-\references{
-https://archive.ics.uci.edu/ml/datasets/Mushroom
-
-Bache, K. & Lichman, M. (2013). UCI Machine Learning Repository
-[http://archive.ics.uci.edu/ml]. Irvine, CA: University of California,
-School of Information and Computer Science.
-}
-\keyword{datasets}
diff --git a/R-package/man/agaricus.train.Rd b/R-package/man/agaricus.train.Rd
deleted file mode 100644
index 539f8a5ba2d0..000000000000
--- a/R-package/man/agaricus.train.Rd
+++ /dev/null
@@ -1,31 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lightgbm.R
-\docType{data}
-\name{agaricus.train}
-\alias{agaricus.train}
-\title{Training part from Mushroom Data Set}
-\format{A list containing a label vector, and a dgCMatrix object with 6513
-rows and 127 variables}
-\usage{
-data(agaricus.train)
-}
-\description{
-This data set is originally from the Mushroom data set,
-UCI Machine Learning Repository.
-}
-\details{
-This data set includes the following fields:
-
-\itemize{
- \item \code{label} the label for each record
- \item \code{data} a sparse Matrix of \code{dgCMatrix} class, with 126 columns.
-}
-}
-\references{
-https://archive.ics.uci.edu/ml/datasets/Mushroom
-
-Bache, K. & Lichman, M. (2013). UCI Machine Learning Repository
-[http://archive.ics.uci.edu/ml]. Irvine, CA: University of California,
-School of Information and Computer Science.
-}
-\keyword{datasets}
diff --git a/R-package/man/bank.Rd b/R-package/man/bank.Rd
deleted file mode 100644
index dff44d63dd00..000000000000
--- a/R-package/man/bank.Rd
+++ /dev/null
@@ -1,25 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lightgbm.R
-\docType{data}
-\name{bank}
-\alias{bank}
-\title{Bank Marketing Data Set}
-\format{A data.table with 4521 rows and 17 variables}
-\usage{
-data(bank)
-}
-\description{
-This data set is originally from the Bank Marketing data set,
-UCI Machine Learning Repository.
-}
-\details{
-It contains only the following: bank.csv with 10% of the examples and 17 inputs,
-randomly selected from 3 (older version of this dataset with less inputs).
-}
-\references{
-http://archive.ics.uci.edu/ml/datasets/Bank+Marketing
-
-S. Moro, P. Cortez and P. Rita. (2014)
-A Data-Driven Approach to Predict the Success of Bank Telemarketing. Decision Support Systems
-}
-\keyword{datasets}
diff --git a/R-package/man/dim.Rd b/R-package/man/dim.Rd
deleted file mode 100644
index a8a567c9b85c..000000000000
--- a/R-package/man/dim.Rd
+++ /dev/null
@@ -1,34 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.Dataset.R
-\name{dim.lgb.Dataset}
-\alias{dim.lgb.Dataset}
-\title{Dimensions of an lgb.Dataset}
-\usage{
-\method{dim}{lgb.Dataset}(x, ...)
-}
-\arguments{
-\item{x}{Object of class \code{lgb.Dataset}}
-
-\item{...}{other parameters}
-}
-\value{
-a vector of numbers of rows and of columns
-}
-\description{
-Returns a vector of numbers of rows and of columns in an \code{lgb.Dataset}.
-}
-\details{
-Note: since \code{nrow} and \code{ncol} internally use \code{dim}, they can also
-be directly used with an \code{lgb.Dataset} object.
-}
-\examples{
-library(lightgbm)
-data(agaricus.train, package = "lightgbm")
-train <- agaricus.train
-dtrain <- lgb.Dataset(train$data, label = train$label)
-
-stopifnot(nrow(dtrain) == nrow(train$data))
-stopifnot(ncol(dtrain) == ncol(train$data))
-stopifnot(all(dim(dtrain) == dim(train$data)))
-
-}
diff --git a/R-package/man/dimnames.lgb.Dataset.Rd b/R-package/man/dimnames.lgb.Dataset.Rd
deleted file mode 100644
index 54563ac5c00c..000000000000
--- a/R-package/man/dimnames.lgb.Dataset.Rd
+++ /dev/null
@@ -1,37 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.Dataset.R
-\name{dimnames.lgb.Dataset}
-\alias{dimnames.lgb.Dataset}
-\alias{dimnames<-.lgb.Dataset}
-\title{Handling of column names of \code{lgb.Dataset}}
-\usage{
-\method{dimnames}{lgb.Dataset}(x)
-
-\method{dimnames}{lgb.Dataset}(x) <- value
-}
-\arguments{
-\item{x}{object of class \code{lgb.Dataset}}
-
-\item{value}{a list of two elements: the first one is ignored
-and the second one is column names}
-}
-\description{
-Only column names are supported for \code{lgb.Dataset}, thus setting of
-row names would have no effect and returned row names would be NULL.
-}
-\details{
-Generic \code{dimnames} methods are used by \code{colnames}.
-Since row names are irrelevant, it is recommended to use \code{colnames} directly.
-}
-\examples{
-library(lightgbm)
-data(agaricus.train, package = "lightgbm")
-train <- agaricus.train
-dtrain <- lgb.Dataset(train$data, label = train$label)
-lgb.Dataset.construct(dtrain)
-dimnames(dtrain)
-colnames(dtrain)
-colnames(dtrain) <- make.names(1:ncol(train$data))
-print(dtrain, verbose = TRUE)
-
-}
diff --git a/R-package/man/getinfo.Rd b/R-package/man/getinfo.Rd
deleted file mode 100644
index 04116a46b474..000000000000
--- a/R-package/man/getinfo.Rd
+++ /dev/null
@@ -1,48 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.Dataset.R
-\name{getinfo}
-\alias{getinfo}
-\alias{getinfo.lgb.Dataset}
-\title{Get information of an lgb.Dataset object}
-\usage{
-getinfo(dataset, ...)
-
-\method{getinfo}{lgb.Dataset}(dataset, name, ...)
-}
-\arguments{
-\item{dataset}{Object of class \code{lgb.Dataset}}
-
-\item{...}{other parameters}
-
-\item{name}{the name of the information field to get (see details)}
-}
-\value{
-info data
-}
-\description{
-Get information of an lgb.Dataset object
-}
-\details{
-The \code{name} field can be one of the following:
-
-\itemize{
- \item \code{label}: label lightgbm learn from ;
- \item \code{weight}: to do a weight rescale ;
- \item \code{group}: group size
- \item \code{init_score}: initial score is the base prediction lightgbm will boost from ;
-}
-}
-\examples{
-library(lightgbm)
-data(agaricus.train, package = "lightgbm")
-train <- agaricus.train
-dtrain <- lgb.Dataset(train$data, label = train$label)
-lgb.Dataset.construct(dtrain)
-
-labels <- lightgbm::getinfo(dtrain, "label")
-lightgbm::setinfo(dtrain, "label", 1 - labels)
-
-labels2 <- lightgbm::getinfo(dtrain, "label")
-stopifnot(all(labels2 == 1 - labels))
-
-}
diff --git a/R-package/man/lgb.Dataset.Rd b/R-package/man/lgb.Dataset.Rd
deleted file mode 100644
index e0d6b64aa98b..000000000000
--- a/R-package/man/lgb.Dataset.Rd
+++ /dev/null
@@ -1,44 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.Dataset.R
-\name{lgb.Dataset}
-\alias{lgb.Dataset}
-\title{Construct lgb.Dataset object}
-\usage{
-lgb.Dataset(data, params = list(), reference = NULL, colnames = NULL,
- categorical_feature = NULL, free_raw_data = TRUE, info = list(),
- ...)
-}
-\arguments{
-\item{data}{a \code{matrix} object, a \code{dgCMatrix} object or a character representing a filename}
-
-\item{params}{a list of parameters}
-
-\item{reference}{reference dataset}
-
-\item{colnames}{names of columns}
-
-\item{categorical_feature}{categorical features}
-
-\item{free_raw_data}{TRUE for need to free raw data after construct}
-
-\item{info}{a list of information of the lgb.Dataset object}
-
-\item{...}{other information to pass to \code{info} or parameters pass to \code{params}}
-}
-\value{
-constructed dataset
-}
-\description{
-Construct lgb.Dataset object from dense matrix, sparse matrix
-or local file (that was created previously by saving an \code{lgb.Dataset}).
-}
-\examples{
-library(lightgbm)
-data(agaricus.train, package = "lightgbm")
-train <- agaricus.train
-dtrain <- lgb.Dataset(train$data, label = train$label)
-lgb.Dataset.save(dtrain, "lgb.Dataset.data")
-dtrain <- lgb.Dataset("lgb.Dataset.data")
-lgb.Dataset.construct(dtrain)
-
-}
diff --git a/R-package/man/lgb.Dataset.construct.Rd b/R-package/man/lgb.Dataset.construct.Rd
deleted file mode 100644
index 23dfc0e9f67b..000000000000
--- a/R-package/man/lgb.Dataset.construct.Rd
+++ /dev/null
@@ -1,22 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.Dataset.R
-\name{lgb.Dataset.construct}
-\alias{lgb.Dataset.construct}
-\title{Construct Dataset explicitly}
-\usage{
-lgb.Dataset.construct(dataset)
-}
-\arguments{
-\item{dataset}{Object of class \code{lgb.Dataset}}
-}
-\description{
-Construct Dataset explicitly
-}
-\examples{
-library(lightgbm)
-data(agaricus.train, package = "lightgbm")
-train <- agaricus.train
-dtrain <- lgb.Dataset(train$data, label = train$label)
-lgb.Dataset.construct(dtrain)
-
-}
diff --git a/R-package/man/lgb.Dataset.create.valid.Rd b/R-package/man/lgb.Dataset.create.valid.Rd
deleted file mode 100644
index 0d0f3454a8e2..000000000000
--- a/R-package/man/lgb.Dataset.create.valid.Rd
+++ /dev/null
@@ -1,33 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.Dataset.R
-\name{lgb.Dataset.create.valid}
-\alias{lgb.Dataset.create.valid}
-\title{Construct validation data}
-\usage{
-lgb.Dataset.create.valid(dataset, data, info = list(), ...)
-}
-\arguments{
-\item{dataset}{\code{lgb.Dataset} object, training data}
-
-\item{data}{a \code{matrix} object, a \code{dgCMatrix} object or a character representing a filename}
-
-\item{info}{a list of information of the lgb.Dataset object}
-
-\item{...}{other information to pass to \code{info}.}
-}
-\value{
-constructed dataset
-}
-\description{
-Construct validation data according to training data
-}
-\examples{
-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)
-
-}
diff --git a/R-package/man/lgb.Dataset.save.Rd b/R-package/man/lgb.Dataset.save.Rd
deleted file mode 100644
index f5664a9841a4..000000000000
--- a/R-package/man/lgb.Dataset.save.Rd
+++ /dev/null
@@ -1,28 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.Dataset.R
-\name{lgb.Dataset.save}
-\alias{lgb.Dataset.save}
-\title{Save \code{lgb.Dataset} to a binary file}
-\usage{
-lgb.Dataset.save(dataset, fname)
-}
-\arguments{
-\item{dataset}{object of class \code{lgb.Dataset}}
-
-\item{fname}{object filename of output file}
-}
-\value{
-passed dataset
-}
-\description{
-Save \code{lgb.Dataset} to a binary file
-}
-\examples{
-
-library(lightgbm)
-data(agaricus.train, package = "lightgbm")
-train <- agaricus.train
-dtrain <- lgb.Dataset(train$data, label = train$label)
-lgb.Dataset.save(dtrain, "data.bin")
-
-}
diff --git a/R-package/man/lgb.Dataset.set.categorical.Rd b/R-package/man/lgb.Dataset.set.categorical.Rd
deleted file mode 100644
index 1cec77c13d85..000000000000
--- a/R-package/man/lgb.Dataset.set.categorical.Rd
+++ /dev/null
@@ -1,29 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.Dataset.R
-\name{lgb.Dataset.set.categorical}
-\alias{lgb.Dataset.set.categorical}
-\title{Set categorical feature of \code{lgb.Dataset}}
-\usage{
-lgb.Dataset.set.categorical(dataset, categorical_feature)
-}
-\arguments{
-\item{dataset}{object of class \code{lgb.Dataset}}
-
-\item{categorical_feature}{categorical features}
-}
-\value{
-passed dataset
-}
-\description{
-Set categorical feature of \code{lgb.Dataset}
-}
-\examples{
-library(lightgbm)
-data(agaricus.train, package = "lightgbm")
-train <- agaricus.train
-dtrain <- lgb.Dataset(train$data, label = train$label)
-lgb.Dataset.save(dtrain, "lgb.Dataset.data")
-dtrain <- lgb.Dataset("lgb.Dataset.data")
-lgb.Dataset.set.categorical(dtrain, 1:2)
-
-}
diff --git a/R-package/man/lgb.Dataset.set.reference.Rd b/R-package/man/lgb.Dataset.set.reference.Rd
deleted file mode 100644
index fabe7c03e6fd..000000000000
--- a/R-package/man/lgb.Dataset.set.reference.Rd
+++ /dev/null
@@ -1,30 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.Dataset.R
-\name{lgb.Dataset.set.reference}
-\alias{lgb.Dataset.set.reference}
-\title{Set reference of \code{lgb.Dataset}}
-\usage{
-lgb.Dataset.set.reference(dataset, reference)
-}
-\arguments{
-\item{dataset}{object of class \code{lgb.Dataset}}
-
-\item{reference}{object of class \code{lgb.Dataset}}
-}
-\value{
-passed dataset
-}
-\description{
-If you want to use validation data, you should set reference to training data
-}
-\examples{
-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(test$data, test = train$label)
-lgb.Dataset.set.reference(dtest, dtrain)
-
-}
diff --git a/R-package/man/lgb.cv.Rd b/R-package/man/lgb.cv.Rd
deleted file mode 100644
index 28652ba1141e..000000000000
--- a/R-package/man/lgb.cv.Rd
+++ /dev/null
@@ -1,99 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.cv.R
-\name{lgb.cv}
-\alias{lgb.cv}
-\title{Main CV logic for LightGBM}
-\usage{
-lgb.cv(params = list(), data, nrounds = 10, nfold = 3,
- label = NULL, weight = NULL, obj = NULL, eval = NULL,
- verbose = 1, record = TRUE, eval_freq = 1L, showsd = TRUE,
- stratified = TRUE, folds = NULL, init_model = NULL,
- colnames = NULL, categorical_feature = NULL,
- early_stopping_rounds = NULL, callbacks = list(),
- reset_data = FALSE, ...)
-}
-\arguments{
-\item{params}{List of parameters}
-
-\item{data}{a \code{lgb.Dataset} object, used for training}
-
-\item{nrounds}{number of training rounds}
-
-\item{nfold}{the original dataset is randomly partitioned into \code{nfold} equal size subsamples.}
-
-\item{label}{vector of response values. Should be provided only when data is an R-matrix.}
-
-\item{weight}{vector of response values. If not NULL, will set to dataset}
-
-\item{obj}{objective function, can be character or custom objective function. Examples include
-\code{regression}, \code{regression_l1}, \code{huber},
-\code{binary}, \code{lambdarank}, \code{multiclass}, \code{multiclass}}
-
-\item{eval}{evaluation function, can be (list of) character or custom eval function}
-
-\item{verbose}{verbosity for output, if <= 0, also will disable the print of evaluation during training}
-
-\item{record}{Boolean, TRUE will record iteration message to \code{booster$record_evals}}
-
-\item{eval_freq}{evaluation output frequency, only effect when verbose > 0}
-
-\item{showsd}{\code{boolean}, whether to show standard deviation of cross validation}
-
-\item{stratified}{a \code{boolean} indicating whether sampling of folds should be stratified
-by the values of outcome labels.}
-
-\item{folds}{\code{list} provides a possibility to use a list of pre-defined CV folds
-(each element must be a vector of test fold's indices). When folds are supplied,
-the \code{nfold} and \code{stratified} parameters are ignored.}
-
-\item{init_model}{path of model file of \code{lgb.Booster} object, will continue training from this model}
-
-\item{colnames}{feature names, if not null, will use this to overwrite the names in dataset}
-
-\item{categorical_feature}{list of str or int
-type int represents index,
-type str represents feature names}
-
-\item{early_stopping_rounds}{int
-Activates early stopping.
-Requires at least one validation data and one metric
-If there's more than one, will check all of them except the training data
-Returns the model with (best_iter + early_stopping_rounds)
-If early stopping occurs, the model will have 'best_iter' field}
-
-\item{callbacks}{list of callback functions
-List of callback functions that are applied at each iteration.}
-
-\item{reset_data}{Boolean, setting it to TRUE (not the default value) will transform the booster model into a predictor model which frees up memory and the original datasets}
-
-\item{...}{other parameters, see Parameters.rst for more information. A few key parameters:
-\itemize{
- \item{boosting}{Boosting type. \code{"gbdt"} or \code{"dart"}}
- \item{num_leaves}{number of leaves in one tree. defaults to 127}
- \item{max_depth}{Limit the max depth for tree model. This is used to deal with
- overfit when #data is small. Tree still grow by leaf-wise.}
- \item{num_threads}{Number of threads for LightGBM. For the best speed, set this to
- the number of real CPU cores, not the number of threads (most
- CPU using hyper-threading to generate 2 threads per CPU core).}
-}}
-}
-\value{
-a trained model \code{lgb.CVBooster}.
-}
-\description{
-Cross validation logic used by LightGBM
-}
-\examples{
-library(lightgbm)
-data(agaricus.train, package = "lightgbm")
-train <- agaricus.train
-dtrain <- lgb.Dataset(train$data, label = train$label)
-params <- list(objective = "regression", metric = "l2")
-model <- lgb.cv(params,
- dtrain,
- 10,
- nfold = 5,
- min_data = 1,
- learning_rate = 1,
- early_stopping_rounds = 10)
-}
diff --git a/R-package/man/lgb.dump.Rd b/R-package/man/lgb.dump.Rd
deleted file mode 100644
index a18483e3dad9..000000000000
--- a/R-package/man/lgb.dump.Rd
+++ /dev/null
@@ -1,39 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.Booster.R
-\name{lgb.dump}
-\alias{lgb.dump}
-\title{Dump LightGBM model to json}
-\usage{
-lgb.dump(booster, num_iteration = NULL)
-}
-\arguments{
-\item{booster}{Object of class \code{lgb.Booster}}
-
-\item{num_iteration}{number of iteration want to predict with, NULL or <= 0 means use best iteration}
-}
-\value{
-json format of model
-}
-\description{
-Dump LightGBM model to json
-}
-\examples{
-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)
-json_model <- lgb.dump(model)
-
-}
diff --git a/R-package/man/lgb.get.eval.result.Rd b/R-package/man/lgb.get.eval.result.Rd
deleted file mode 100644
index 52dd2b1dd18d..000000000000
--- a/R-package/man/lgb.get.eval.result.Rd
+++ /dev/null
@@ -1,46 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.Booster.R
-\name{lgb.get.eval.result}
-\alias{lgb.get.eval.result}
-\title{Get record evaluation result from booster}
-\usage{
-lgb.get.eval.result(booster, data_name, eval_name, iters = NULL,
- is_err = FALSE)
-}
-\arguments{
-\item{booster}{Object of class \code{lgb.Booster}}
-
-\item{data_name}{name of dataset}
-
-\item{eval_name}{name of evaluation}
-
-\item{iters}{iterations, NULL will return all}
-
-\item{is_err}{TRUE will return evaluation error instead}
-}
-\value{
-vector of evaluation result
-}
-\description{
-Get record evaluation result from booster
-}
-\examples{
-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)
-lgb.get.eval.result(model, "test", "l2")
-
-}
diff --git a/R-package/man/lgb.importance.Rd b/R-package/man/lgb.importance.Rd
deleted file mode 100644
index 8e7fe941644e..000000000000
--- a/R-package/man/lgb.importance.Rd
+++ /dev/null
@@ -1,41 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.importance.R
-\name{lgb.importance}
-\alias{lgb.importance}
-\title{Compute feature importance in a model}
-\usage{
-lgb.importance(model, percentage = TRUE)
-}
-\arguments{
-\item{model}{object of class \code{lgb.Booster}.}
-
-\item{percentage}{whether to show importance in relative percentage.}
-}
-\value{
-For a tree model, a \code{data.table} with the following columns:
-\itemize{
- \item \code{Feature} Feature names in the model.
- \item \code{Gain} The total gain of this feature's splits.
- \item \code{Cover} The number of observation related to this feature.
- \item \code{Frequency} The number of times a feature splited in trees.
-}
-}
-\description{
-Creates a \code{data.table} of feature importances in a model.
-}
-\examples{
-library(lightgbm)
-data(agaricus.train, package = "lightgbm")
-train <- agaricus.train
-dtrain <- lgb.Dataset(train$data, label = train$label)
-
-params <- list(objective = "binary",
- learning_rate = 0.01, num_leaves = 63, max_depth = -1,
- min_data_in_leaf = 1, min_sum_hessian_in_leaf = 1)
- model <- lgb.train(params, dtrain, 20)
-model <- lgb.train(params, dtrain, 20)
-
-tree_imp1 <- lgb.importance(model, percentage = TRUE)
-tree_imp2 <- lgb.importance(model, percentage = FALSE)
-
-}
diff --git a/R-package/man/lgb.interprete.Rd b/R-package/man/lgb.interprete.Rd
deleted file mode 100644
index da28a542a852..000000000000
--- a/R-package/man/lgb.interprete.Rd
+++ /dev/null
@@ -1,51 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.interprete.R
-\name{lgb.interprete}
-\alias{lgb.interprete}
-\title{Compute feature contribution of prediction}
-\usage{
-lgb.interprete(model, data, idxset, num_iteration = NULL)
-}
-\arguments{
-\item{model}{object of class \code{lgb.Booster}.}
-
-\item{data}{a matrix object or a dgCMatrix object.}
-
-\item{idxset}{a integer vector of indices of rows needed.}
-
-\item{num_iteration}{number of iteration want to predict with, NULL or <= 0 means use best iteration.}
-}
-\value{
-For regression, binary classification and lambdarank model, a \code{list} of \code{data.table} with the following columns:
-\itemize{
- \item \code{Feature} Feature names in the model.
- \item \code{Contribution} The total contribution of this feature's splits.
-}
-For multiclass classification, a \code{list} of \code{data.table} with the Feature column and Contribution columns to each class.
-}
-\description{
-Computes feature contribution components of rawscore prediction.
-}
-\examples{
-Sigmoid <- function(x) 1 / (1 + exp(-x))
-Logit <- function(x) log(x / (1 - x))
-data(agaricus.train, package = "lightgbm")
-train <- agaricus.train
-dtrain <- lgb.Dataset(train$data, label = train$label)
-setinfo(dtrain, "init_score", rep(Logit(mean(train$label)), length(train$label)))
-data(agaricus.test, package = "lightgbm")
-test <- agaricus.test
-
-params <- list(
- objective = "binary"
- , learning_rate = 0.01
- , num_leaves = 63
- , max_depth = -1
- , min_data_in_leaf = 1
- , min_sum_hessian_in_leaf = 1
-)
-model <- lgb.train(params, dtrain, 20)
-
-tree_interpretation <- lgb.interprete(model, test$data, 1:5)
-
-}
diff --git a/R-package/man/lgb.load.Rd b/R-package/man/lgb.load.Rd
deleted file mode 100644
index bf298920e75d..000000000000
--- a/R-package/man/lgb.load.Rd
+++ /dev/null
@@ -1,44 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.Booster.R
-\name{lgb.load}
-\alias{lgb.load}
-\title{Load LightGBM model}
-\usage{
-lgb.load(filename = NULL, model_str = NULL)
-}
-\arguments{
-\item{filename}{path of model file}
-
-\item{model_str}{a str containing the model}
-}
-\value{
-lgb.Booster
-}
-\description{
-Load LightGBM model from saved model file or string
-Load LightGBM takes in either a file path or model string
-If both are provided, Load will default to loading from file
-}
-\examples{
-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)
-lgb.save(model, "model.txt")
-load_booster <- lgb.load(filename = "model.txt")
-model_string <- model$save_model_to_string(NULL) # saves best iteration
-load_booster_from_str <- lgb.load(model_str = model_string)
-
-}
diff --git a/R-package/man/lgb.model.dt.tree.Rd b/R-package/man/lgb.model.dt.tree.Rd
deleted file mode 100644
index be622f428e43..000000000000
--- a/R-package/man/lgb.model.dt.tree.Rd
+++ /dev/null
@@ -1,55 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.model.dt.tree.R
-\name{lgb.model.dt.tree}
-\alias{lgb.model.dt.tree}
-\title{Parse a LightGBM model json dump}
-\usage{
-lgb.model.dt.tree(model, num_iteration = NULL)
-}
-\arguments{
-\item{model}{object of class \code{lgb.Booster}}
-
-\item{num_iteration}{number of iterations you want to predict with. NULL or
-<= 0 means use best iteration}
-}
-\value{
-A \code{data.table} with detailed information about model trees' nodes and leafs.
-
-The columns of the \code{data.table} are:
-
-\itemize{
- \item \code{tree_index}: ID of a tree in a model (integer)
- \item \code{split_index}: ID of a node in a tree (integer)
- \item \code{split_feature}: for a node, it's a feature name (character);
- for a leaf, it simply labels it as \code{"NA"}
- \item \code{node_parent}: ID of the parent node for current node (integer)
- \item \code{leaf_index}: ID of a leaf in a tree (integer)
- \item \code{leaf_parent}: ID of the parent node for current leaf (integer)
- \item \code{split_gain}: Split gain of a node
- \item \code{threshold}: Splitting threshold value of a node
- \item \code{decision_type}: Decision type of a node
- \item \code{default_left}: Determine how to handle NA value, TRUE -> Left, FALSE -> Right
- \item \code{internal_value}: Node value
- \item \code{internal_count}: The number of observation collected by a node
- \item \code{leaf_value}: Leaf value
- \item \code{leaf_count}: The number of observation collected by a leaf
-}
-}
-\description{
-Parse a LightGBM model json dump into a \code{data.table} structure.
-}
-\examples{
-
-data(agaricus.train, package = "lightgbm")
-train <- agaricus.train
-dtrain <- lgb.Dataset(train$data, label = train$label)
-
-params <- list(objective = "binary",
- learning_rate = 0.01, num_leaves = 63, max_depth = -1,
- min_data_in_leaf = 1, min_sum_hessian_in_leaf = 1)
- model <- lgb.train(params, dtrain, 20)
-model <- lgb.train(params, dtrain, 20)
-
-tree_dt <- lgb.model.dt.tree(model)
-
-}
diff --git a/R-package/man/lgb.plot.importance.Rd b/R-package/man/lgb.plot.importance.Rd
deleted file mode 100644
index 9e7e688d2bd9..000000000000
--- a/R-package/man/lgb.plot.importance.Rd
+++ /dev/null
@@ -1,50 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.plot.importance.R
-\name{lgb.plot.importance}
-\alias{lgb.plot.importance}
-\title{Plot feature importance as a bar graph}
-\usage{
-lgb.plot.importance(tree_imp, top_n = 10, measure = "Gain",
- left_margin = 10, cex = NULL)
-}
-\arguments{
-\item{tree_imp}{a \code{data.table} returned by \code{\link{lgb.importance}}.}
-
-\item{top_n}{maximal number of top features to include into the plot.}
-
-\item{measure}{the name of importance measure to plot, can be "Gain", "Cover" or "Frequency".}
-
-\item{left_margin}{(base R barplot) allows to adjust the left margin size to fit feature names.}
-
-\item{cex}{(base R barplot) passed as \code{cex.names} parameter to \code{barplot}.}
-}
-\value{
-The \code{lgb.plot.importance} function creates a \code{barplot}
-and silently returns a processed data.table with \code{top_n} features sorted by defined importance.
-}
-\description{
-Plot previously calculated feature importance: Gain, Cover and Frequency, as a bar graph.
-}
-\details{
-The graph represents each feature as a horizontal bar of length proportional to the defined importance of a feature.
-Features are shown ranked in a decreasing importance order.
-}
-\examples{
-data(agaricus.train, package = "lightgbm")
-train <- agaricus.train
-dtrain <- lgb.Dataset(train$data, label = train$label)
-
-params <- list(
- objective = "binary"
- , learning_rate = 0.01
- , num_leaves = 63
- , max_depth = -1
- , min_data_in_leaf = 1
- , min_sum_hessian_in_leaf = 1
-)
-
-model <- lgb.train(params, dtrain, 20)
-
-tree_imp <- lgb.importance(model, percentage = TRUE)
-lgb.plot.importance(tree_imp, top_n = 10, measure = "Gain")
-}
diff --git a/R-package/man/lgb.plot.interpretation.Rd b/R-package/man/lgb.plot.interpretation.Rd
deleted file mode 100644
index c69b8f3354e6..000000000000
--- a/R-package/man/lgb.plot.interpretation.Rd
+++ /dev/null
@@ -1,50 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.plot.interpretation.R
-\name{lgb.plot.interpretation}
-\alias{lgb.plot.interpretation}
-\title{Plot feature contribution as a bar graph}
-\usage{
-lgb.plot.interpretation(tree_interpretation_dt, top_n = 10, cols = 1,
- left_margin = 10, cex = NULL)
-}
-\arguments{
-\item{tree_interpretation_dt}{a \code{data.table} returned by \code{\link{lgb.interprete}}.}
-
-\item{top_n}{maximal number of top features to include into the plot.}
-
-\item{cols}{the column numbers of layout, will be used only for multiclass classification feature contribution.}
-
-\item{left_margin}{(base R barplot) allows to adjust the left margin size to fit feature names.}
-
-\item{cex}{(base R barplot) passed as \code{cex.names} parameter to \code{barplot}.}
-}
-\value{
-The \code{lgb.plot.interpretation} function creates a \code{barplot}.
-}
-\description{
-Plot previously calculated feature contribution as a bar graph.
-}
-\details{
-The graph represents each feature as a horizontal bar of length proportional to the defined contribution of a feature.
-Features are shown ranked in a decreasing contribution order.
-}
-\examples{
-library(lightgbm)
-Sigmoid <- function(x) {1 / (1 + exp(-x))}
-Logit <- function(x) {log(x / (1 - x))}
-data(agaricus.train, package = "lightgbm")
-train <- agaricus.train
-dtrain <- lgb.Dataset(train$data, label = train$label)
-setinfo(dtrain, "init_score", rep(Logit(mean(train$label)), length(train$label)))
-data(agaricus.test, package = "lightgbm")
-test <- agaricus.test
-
-params <- list(objective = "binary",
- learning_rate = 0.01, num_leaves = 63, max_depth = -1,
- min_data_in_leaf = 1, min_sum_hessian_in_leaf = 1)
- model <- lgb.train(params, dtrain, 20)
-model <- lgb.train(params, dtrain, 20)
-
-tree_interpretation <- lgb.interprete(model, test$data, 1:5)
-lgb.plot.interpretation(tree_interpretation[[1]], top_n = 10)
-}
diff --git a/R-package/man/lgb.prepare.Rd b/R-package/man/lgb.prepare.Rd
deleted file mode 100644
index 625cb5a8e2db..000000000000
--- a/R-package/man/lgb.prepare.Rd
+++ /dev/null
@@ -1,49 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.prepare.R
-\name{lgb.prepare}
-\alias{lgb.prepare}
-\title{Data preparator for LightGBM datasets (numeric)}
-\usage{
-lgb.prepare(data)
-}
-\arguments{
-\item{data}{A data.frame or data.table to prepare.}
-}
-\value{
-The cleaned dataset. It must be converted to a matrix format (\code{as.matrix}) for input in lgb.Dataset.
-}
-\description{
-Attempts to prepare a clean dataset to prepare to put in a lgb.Dataset. Factors and characters are converted to numeric without integers. Please use \code{lgb.prepare_rules} if you want to apply this transformation to other datasets.
-}
-\examples{
-library(lightgbm)
-data(iris)
-
-str(iris)
-# 'data.frame': 150 obs. of 5 variables:
-# $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
-# $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
-# $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
-# $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
-# $ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 ...
-
-str(lgb.prepare(data = iris)) # Convert all factors/chars to numeric
-# 'data.frame': 150 obs. of 5 variables:
-# $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
-# $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
-# $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
-# $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
-# $ Species : num 1 1 1 1 1 1 1 1 1 1 ...
-
-# When lightgbm package is installed, and you do not want to load it
-# You can still use the function!
-lgb.unloader()
-str(lightgbm::lgb.prepare(data = iris))
-# 'data.frame': 150 obs. of 5 variables:
-# $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
-# $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
-# $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
-# $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
-# $ Species : num 1 1 1 1 1 1 1 1 1 1 ...
-
-}
diff --git a/R-package/man/lgb.prepare2.Rd b/R-package/man/lgb.prepare2.Rd
deleted file mode 100644
index 5739b03363d5..000000000000
--- a/R-package/man/lgb.prepare2.Rd
+++ /dev/null
@@ -1,50 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.prepare2.R
-\name{lgb.prepare2}
-\alias{lgb.prepare2}
-\title{Data preparator for LightGBM datasets (integer)}
-\usage{
-lgb.prepare2(data)
-}
-\arguments{
-\item{data}{A data.frame or data.table to prepare.}
-}
-\value{
-The cleaned dataset. It must be converted to a matrix format (\code{as.matrix}) for input in lgb.Dataset.
-}
-\description{
-Attempts to prepare a clean dataset to prepare to put in a lgb.Dataset. Factors and characters are converted to numeric (specifically: integer). Please use \code{lgb.prepare_rules2} if you want to apply this transformation to other datasets. This is useful if you have a specific need for integer dataset instead of numeric dataset. Note that there are programs which do not support integer-only input. Consider this as a half memory technique which is dangerous, especially for LightGBM.
-}
-\examples{
-library(lightgbm)
-data(iris)
-
-str(iris)
-# 'data.frame': 150 obs. of 5 variables:
-# $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
-# $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
-# $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
-# $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
-# $ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 ...
-
-# Convert all factors/chars to integer
-str(lgb.prepare2(data = iris))
-# 'data.frame': 150 obs. of 5 variables:
-# $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
-# $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
-# $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
-# $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
-# $ Species : int 1 1 1 1 1 1 1 1 1 1 ...
-
-# When lightgbm package is installed, and you do not want to load it
-# You can still use the function!
-lgb.unloader()
-str(lightgbm::lgb.prepare2(data = iris))
-# 'data.frame': 150 obs. of 5 variables:
-# $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
-# $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
-# $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
-# $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
-# $ Species : int 1 1 1 1 1 1 1 1 1 1 ...
-
-}
diff --git a/R-package/man/lgb.prepare_rules.Rd b/R-package/man/lgb.prepare_rules.Rd
deleted file mode 100644
index ac8a8d43ef45..000000000000
--- a/R-package/man/lgb.prepare_rules.Rd
+++ /dev/null
@@ -1,78 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.prepare_rules.R
-\name{lgb.prepare_rules}
-\alias{lgb.prepare_rules}
-\title{Data preparator for LightGBM datasets with rules (numeric)}
-\usage{
-lgb.prepare_rules(data, rules = NULL)
-}
-\arguments{
-\item{data}{A data.frame or data.table to prepare.}
-
-\item{rules}{A set of rules from the data preparator, if already used.}
-}
-\value{
-A list with the cleaned dataset (\code{data}) and the rules (\code{rules}). The data must be converted to a matrix format (\code{as.matrix}) for input in lgb.Dataset.
-}
-\description{
-Attempts to prepare a clean dataset to prepare to put in a lgb.Dataset. Factors and characters are converted to numeric. In addition, keeps rules created so you can convert other datasets using this converter.
-}
-\examples{
-library(lightgbm)
-data(iris)
-
-str(iris)
-# 'data.frame': 150 obs. of 5 variables:
-# $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
-# $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
-# $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
-# $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
-# $ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 ...
-
-new_iris <- lgb.prepare_rules(data = iris) # Autoconverter
-str(new_iris$data)
-# 'data.frame': 150 obs. of 5 variables:
-# $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
-# $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
-# $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
-# $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
-# $ Species : num 1 1 1 1 1 1 1 1 1 1 ...
-
-data(iris) # Erase iris dataset
-iris$Species[1] <- "NEW FACTOR" # Introduce junk factor (NA)
-# Warning message:
-# In `[<-.factor`(`*tmp*`, 1, value = c(NA, 1L, 1L, 1L, 1L, 1L, 1L, :
-# invalid factor level, NA generated
-
-# Use conversion using known rules
-# Unknown factors become 0, excellent for sparse datasets
-newer_iris <- lgb.prepare_rules(data = iris, rules = new_iris$rules)
-
-# Unknown factor is now zero, perfect for sparse datasets
-newer_iris$data[1, ] # Species became 0 as it is an unknown factor
-# Sepal.Length Sepal.Width Petal.Length Petal.Width Species
-# 1 5.1 3.5 1.4 0.2 0
-
-newer_iris$data[1, 5] <- 1 # Put back real initial value
-
-# Is the newly created dataset equal? YES!
-all.equal(new_iris$data, newer_iris$data)
-# [1] TRUE
-
-# Can we test our own rules?
-data(iris) # Erase iris dataset
-
-# We remapped values differently
-personal_rules <- list(Species = c("setosa" = 3,
- "versicolor" = 2,
- "virginica" = 1))
-newest_iris <- lgb.prepare_rules(data = iris, rules = personal_rules)
-str(newest_iris$data) # SUCCESS!
-# 'data.frame': 150 obs. of 5 variables:
-# $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
-# $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
-# $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
-# $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
-# $ Species : num 3 3 3 3 3 3 3 3 3 3 ...
-
-}
diff --git a/R-package/man/lgb.prepare_rules2.Rd b/R-package/man/lgb.prepare_rules2.Rd
deleted file mode 100644
index 2422cbc073d0..000000000000
--- a/R-package/man/lgb.prepare_rules2.Rd
+++ /dev/null
@@ -1,78 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.prepare_rules2.R
-\name{lgb.prepare_rules2}
-\alias{lgb.prepare_rules2}
-\title{Data preparator for LightGBM datasets with rules (integer)}
-\usage{
-lgb.prepare_rules2(data, rules = NULL)
-}
-\arguments{
-\item{data}{A data.frame or data.table to prepare.}
-
-\item{rules}{A set of rules from the data preparator, if already used.}
-}
-\value{
-A list with the cleaned dataset (\code{data}) and the rules (\code{rules}). The data must be converted to a matrix format (\code{as.matrix}) for input in lgb.Dataset.
-}
-\description{
-Attempts to prepare a clean dataset to prepare to put in a lgb.Dataset. Factors and characters are converted to numeric (specifically: integer). In addition, keeps rules created so you can convert other datasets using this converter. This is useful if you have a specific need for integer dataset instead of numeric dataset. Note that there are programs which do not support integer-only input. Consider this as a half memory technique which is dangerous, especially for LightGBM.
-}
-\examples{
-library(lightgbm)
-data(iris)
-
-str(iris)
-# 'data.frame': 150 obs. of 5 variables:
-# $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
-# $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
-# $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
-# $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
-# $ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 ...
-
-new_iris <- lgb.prepare_rules2(data = iris) # Autoconverter
-str(new_iris$data)
-# 'data.frame': 150 obs. of 5 variables:
-# $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
-# $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
-# $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
-# $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
-# $ Species : int 1 1 1 1 1 1 1 1 1 1 ...
-
-data(iris) # Erase iris dataset
-iris$Species[1] <- "NEW FACTOR" # Introduce junk factor (NA)
-# Warning message:
-# In `[<-.factor`(`*tmp*`, 1, value = c(NA, 1L, 1L, 1L, 1L, 1L, 1L, :
-# invalid factor level, NA generated
-
-# Use conversion using known rules
-# Unknown factors become 0, excellent for sparse datasets
-newer_iris <- lgb.prepare_rules2(data = iris, rules = new_iris$rules)
-
-# Unknown factor is now zero, perfect for sparse datasets
-newer_iris$data[1, ] # Species became 0 as it is an unknown factor
-# Sepal.Length Sepal.Width Petal.Length Petal.Width Species
-# 1 5.1 3.5 1.4 0.2 0
-
-newer_iris$data[1, 5] <- 1 # Put back real initial value
-
-# Is the newly created dataset equal? YES!
-all.equal(new_iris$data, newer_iris$data)
-# [1] TRUE
-
-# Can we test our own rules?
-data(iris) # Erase iris dataset
-
-# We remapped values differently
-personal_rules <- list(Species = c("setosa" = 3L,
- "versicolor" = 2L,
- "virginica" = 1L))
-newest_iris <- lgb.prepare_rules2(data = iris, rules = personal_rules)
-str(newest_iris$data) # SUCCESS!
-# 'data.frame': 150 obs. of 5 variables:
-# $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
-# $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
-# $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
-# $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
-# $ Species : int 3 3 3 3 3 3 3 3 3 3 ...
-
-}
diff --git a/R-package/man/lgb.save.Rd b/R-package/man/lgb.save.Rd
deleted file mode 100644
index bad52ad603ad..000000000000
--- a/R-package/man/lgb.save.Rd
+++ /dev/null
@@ -1,41 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.Booster.R
-\name{lgb.save}
-\alias{lgb.save}
-\title{Save LightGBM model}
-\usage{
-lgb.save(booster, filename, num_iteration = NULL)
-}
-\arguments{
-\item{booster}{Object of class \code{lgb.Booster}}
-
-\item{filename}{saved filename}
-
-\item{num_iteration}{number of iteration want to predict with, NULL or <= 0 means use best iteration}
-}
-\value{
-lgb.Booster
-}
-\description{
-Save LightGBM model
-}
-\examples{
-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)
-lgb.save(model, "model.txt")
-
-}
diff --git a/R-package/man/lgb.train.Rd b/R-package/man/lgb.train.Rd
deleted file mode 100644
index 7f1e9f957893..000000000000
--- a/R-package/man/lgb.train.Rd
+++ /dev/null
@@ -1,89 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.train.R
-\name{lgb.train}
-\alias{lgb.train}
-\title{Main training logic for LightGBM}
-\usage{
-lgb.train(params = list(), data, nrounds = 10, valids = list(),
- obj = NULL, eval = NULL, verbose = 1, record = TRUE,
- eval_freq = 1L, init_model = NULL, colnames = NULL,
- categorical_feature = NULL, early_stopping_rounds = NULL,
- callbacks = list(), reset_data = FALSE, ...)
-}
-\arguments{
-\item{params}{List of parameters}
-
-\item{data}{a \code{lgb.Dataset} object, used for training}
-
-\item{nrounds}{number of training rounds}
-
-\item{valids}{a list of \code{lgb.Dataset} objects, used for validation}
-
-\item{obj}{objective function, can be character or custom objective function. Examples include
-\code{regression}, \code{regression_l1}, \code{huber},
-\code{binary}, \code{lambdarank}, \code{multiclass}, \code{multiclass}}
-
-\item{eval}{evaluation function, can be (a list of) character or custom eval function}
-
-\item{verbose}{verbosity for output, if <= 0, also will disable the print of evaluation during training}
-
-\item{record}{Boolean, TRUE will record iteration message to \code{booster$record_evals}}
-
-\item{eval_freq}{evaluation output frequency, only effect when verbose > 0}
-
-\item{init_model}{path of model file of \code{lgb.Booster} object, will continue training from this model}
-
-\item{colnames}{feature names, if not null, will use this to overwrite the names in dataset}
-
-\item{categorical_feature}{list of str or int
-type int represents index,
-type str represents feature names}
-
-\item{early_stopping_rounds}{int
-Activates early stopping.
-Requires at least one validation data and one metric
-If there's more than one, will check all of them except the training data
-Returns the model with (best_iter + early_stopping_rounds)
-If early stopping occurs, the model will have 'best_iter' field}
-
-\item{callbacks}{list of callback functions
-List of callback functions that are applied at each iteration.}
-
-\item{reset_data}{Boolean, setting it to TRUE (not the default value) will transform the booster model into a predictor model which frees up memory and the original datasets}
-
-\item{...}{other parameters, see Parameters.rst for more information. A few key parameters:
-\itemize{
- \item{boosting}{Boosting type. \code{"gbdt"} or \code{"dart"}}
- \item{num_leaves}{number of leaves in one tree. defaults to 127}
- \item{max_depth}{Limit the max depth for tree model. This is used to deal with
- overfit when #data is small. Tree still grow by leaf-wise.}
- \item{num_threads}{Number of threads for LightGBM. For the best speed, set this to
- the number of real CPU cores, not the number of threads (most
- CPU using hyper-threading to generate 2 threads per CPU core).}
-}}
-}
-\value{
-a trained booster model \code{lgb.Booster}.
-}
-\description{
-Logic to train with LightGBM
-}
-\examples{
-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)
-
-}
diff --git a/R-package/man/lgb.unloader.Rd b/R-package/man/lgb.unloader.Rd
deleted file mode 100644
index 9ea57f54a195..000000000000
--- a/R-package/man/lgb.unloader.Rd
+++ /dev/null
@@ -1,46 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.unloader.R
-\name{lgb.unloader}
-\alias{lgb.unloader}
-\title{LightGBM unloading error fix}
-\usage{
-lgb.unloader(restore = TRUE, wipe = FALSE, envir = .GlobalEnv)
-}
-\arguments{
-\item{restore}{Whether to reload \code{LightGBM} immediately after detaching from R. Defaults to \code{TRUE} which means automatically reload \code{LightGBM} once unloading is performed.}
-
-\item{wipe}{Whether to wipe all \code{lgb.Dataset} and \code{lgb.Booster} from the global environment. Defaults to \code{FALSE} which means to not remove them.}
-
-\item{envir}{The environment to perform wiping on if \code{wipe == TRUE}. Defaults to \code{.GlobalEnv} which is the global environment.}
-}
-\value{
-NULL invisibly.
-}
-\description{
-Attempts to unload LightGBM packages so you can remove objects cleanly without having to restart R. This is useful for instance if an object becomes stuck for no apparent reason and you do not want to restart R to fix the lost object.
-}
-\examples{
-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)
-lgb.unloader(restore = FALSE, wipe = FALSE, envir = .GlobalEnv)
-rm(model, dtrain, dtest) # Not needed if wipe = TRUE
-gc() # Not needed if wipe = TRUE
-
-library(lightgbm)
-# Do whatever you want again with LightGBM without object clashing
-
-}
diff --git a/R-package/man/lgb_shared_params.Rd b/R-package/man/lgb_shared_params.Rd
deleted file mode 100644
index 0a40c2ae31ed..000000000000
--- a/R-package/man/lgb_shared_params.Rd
+++ /dev/null
@@ -1,31 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lightgbm.R
-\name{lgb_shared_params}
-\alias{lgb_shared_params}
-\title{Shared parameter docs}
-\arguments{
-\item{callbacks}{list of callback functions
-List of callback functions that are applied at each iteration.}
-
-\item{data}{a \code{lgb.Dataset} object, used for training}
-
-\item{early_stopping_rounds}{int
-Activates early stopping.
-Requires at least one validation data and one metric
-If there's more than one, will check all of them except the training data
-Returns the model with (best_iter + early_stopping_rounds)
-If early stopping occurs, the model will have 'best_iter' field}
-
-\item{eval_freq}{evaluation output frequency, only effect when verbose > 0}
-
-\item{init_model}{path of model file of \code{lgb.Booster} object, will continue training from this model}
-
-\item{nrounds}{number of training rounds}
-
-\item{params}{List of parameters}
-
-\item{verbose}{verbosity for output, if <= 0, also will disable the print of evaluation during training}
-}
-\description{
-Parameter docs shared by \code{lgb.train}, \code{lgb.cv}, and \code{lightgbm}
-}
diff --git a/R-package/man/lightgbm.Rd b/R-package/man/lightgbm.Rd
deleted file mode 100644
index d0582110a156..000000000000
--- a/R-package/man/lightgbm.Rd
+++ /dev/null
@@ -1,64 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lightgbm.R
-\name{lightgbm}
-\alias{lightgbm}
-\title{Train a LightGBM model}
-\usage{
-lightgbm(data, label = NULL, weight = NULL, params = list(),
- nrounds = 10, verbose = 1, eval_freq = 1L,
- early_stopping_rounds = NULL, save_name = "lightgbm.model",
- init_model = NULL, callbacks = list(), ...)
-}
-\arguments{
-\item{data}{a \code{lgb.Dataset} object, used for training}
-
-\item{label}{Vector of labels, used if \code{data} is not an \code{\link{lgb.Dataset}}}
-
-\item{weight}{vector of response values. If not NULL, will set to dataset}
-
-\item{params}{List of parameters}
-
-\item{nrounds}{number of training rounds}
-
-\item{verbose}{verbosity for output, if <= 0, also will disable the print of evaluation during training}
-
-\item{eval_freq}{evaluation output frequency, only effect when verbose > 0}
-
-\item{early_stopping_rounds}{int
-Activates early stopping.
-Requires at least one validation data and one metric
-If there's more than one, will check all of them except the training data
-Returns the model with (best_iter + early_stopping_rounds)
-If early stopping occurs, the model will have 'best_iter' field}
-
-\item{save_name}{File name to use when writing the trained model to disk. Should end in ".model".}
-
-\item{init_model}{path of model file of \code{lgb.Booster} object, will continue training from this model}
-
-\item{callbacks}{list of callback functions
-List of callback functions that are applied at each iteration.}
-
-\item{...}{Additional arguments passed to \code{\link{lgb.train}}. For example
-\itemize{
- \item{valids}{a list of \code{lgb.Dataset} objects, used for validation}
- \item{obj}{objective function, can be character or custom objective function. Examples include
- \code{regression}, \code{regression_l1}, \code{huber},
- \code{binary}, \code{lambdarank}, \code{multiclass}, \code{multiclass}}
- \item{eval}{evaluation function, can be (a list of) character or custom eval function}
- \item{record}{Boolean, TRUE will record iteration message to \code{booster$record_evals}}
- \item{colnames}{feature names, if not null, will use this to overwrite the names in dataset}
- \item{categorical_feature}{list of str or int. type int represents index, type str represents feature names}
- \item{reset_data}{Boolean, setting it to TRUE (not the default value) will transform the booster model
- into a predictor model which frees up memory and the original datasets}
- \item{boosting}{Boosting type. \code{"gbdt"} or \code{"dart"}}
- \item{num_leaves}{number of leaves in one tree. defaults to 127}
- \item{max_depth}{Limit the max depth for tree model. This is used to deal with
- overfit when #data is small. Tree still grow by leaf-wise.}
- \item{num_threads}{Number of threads for LightGBM. For the best speed, set this to
- the number of real CPU cores, not the number of threads (most
- CPU using hyper-threading to generate 2 threads per CPU core).}
-}}
-}
-\description{
-Simple interface for training an LightGBM model.
-}
diff --git a/R-package/man/predict.lgb.Booster.Rd b/R-package/man/predict.lgb.Booster.Rd
deleted file mode 100644
index 310375ba8742..000000000000
--- a/R-package/man/predict.lgb.Booster.Rd
+++ /dev/null
@@ -1,65 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.Booster.R
-\name{predict.lgb.Booster}
-\alias{predict.lgb.Booster}
-\title{Predict method for LightGBM model}
-\usage{
-\method{predict}{lgb.Booster}(object, data, num_iteration = NULL,
- rawscore = FALSE, predleaf = FALSE, predcontrib = FALSE,
- header = FALSE, reshape = FALSE, ...)
-}
-\arguments{
-\item{object}{Object of class \code{lgb.Booster}}
-
-\item{data}{a \code{matrix} object, a \code{dgCMatrix} object or a character representing a filename}
-
-\item{num_iteration}{number of iteration want to predict with, NULL or <= 0 means use best iteration}
-
-\item{rawscore}{whether the prediction should be returned in the for of original untransformed
-sum of predictions from boosting iterations' results. E.g., setting \code{rawscore=TRUE} for
-logistic regression would result in predictions for log-odds instead of probabilities.}
-
-\item{predleaf}{whether predict leaf index instead.}
-
-\item{predcontrib}{return per-feature contributions for each record.}
-
-\item{header}{only used for prediction for text file. True if text file has header}
-
-\item{reshape}{whether to reshape the vector of predictions to a matrix form when there are several
-prediction outputs per case.}
-
-\item{...}{Additional named arguments passed to the \code{predict()} method of
-the \code{lgb.Booster} object passed to \code{object}.}
-}
-\value{
-For regression or binary classification, it returns a vector of length \code{nrows(data)}.
-For multiclass classification, either a \code{num_class * nrows(data)} vector or
-a \code{(nrows(data), num_class)} dimension matrix is returned, depending on
-the \code{reshape} value.
-
-When \code{predleaf = TRUE}, the output is a matrix object with the
-number of columns corresponding to the number of trees.
-}
-\description{
-Predicted values based on class \code{lgb.Booster}
-}
-\examples{
-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)
-preds <- predict(model, test$data)
-
-}
diff --git a/R-package/man/readRDS.lgb.Booster.Rd b/R-package/man/readRDS.lgb.Booster.Rd
deleted file mode 100644
index 05f4eedb104e..000000000000
--- a/R-package/man/readRDS.lgb.Booster.Rd
+++ /dev/null
@@ -1,40 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/readRDS.lgb.Booster.R
-\name{readRDS.lgb.Booster}
-\alias{readRDS.lgb.Booster}
-\title{readRDS for lgb.Booster models}
-\usage{
-readRDS.lgb.Booster(file = "", refhook = NULL)
-}
-\arguments{
-\item{file}{a connection or the name of the file where the R object is saved to or read from.}
-
-\item{refhook}{a hook function for handling reference objects.}
-}
-\value{
-lgb.Booster.
-}
-\description{
-Attempts to load a model using RDS.
-}
-\examples{
-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)
-saveRDS.lgb.Booster(model, "model.rds")
-new_model <- readRDS.lgb.Booster("model.rds")
-
-}
diff --git a/R-package/man/saveRDS.lgb.Booster.Rd b/R-package/man/saveRDS.lgb.Booster.Rd
deleted file mode 100644
index b302b2c3b6c0..000000000000
--- a/R-package/man/saveRDS.lgb.Booster.Rd
+++ /dev/null
@@ -1,51 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/saveRDS.lgb.Booster.R
-\name{saveRDS.lgb.Booster}
-\alias{saveRDS.lgb.Booster}
-\title{saveRDS for lgb.Booster models}
-\usage{
-saveRDS.lgb.Booster(object, file = "", ascii = FALSE, version = NULL,
- compress = TRUE, refhook = NULL, raw = TRUE)
-}
-\arguments{
-\item{object}{R object to serialize.}
-
-\item{file}{a connection or the name of the file where the R object is saved to or read from.}
-
-\item{ascii}{a logical. If TRUE or NA, an ASCII representation is written; otherwise (default), a binary one is used. See the comments in the help for save.}
-
-\item{version}{the workspace format version to use. \code{NULL} specifies the current default version (2). Versions prior to 2 are not supported, so this will only be relevant when there are later versions.}
-
-\item{compress}{a logical specifying whether saving to a named file is to use "gzip" compression, or one of \code{"gzip"}, \code{"bzip2"} or \code{"xz"} to indicate the type of compression to be used. Ignored if file is a connection.}
-
-\item{refhook}{a hook function for handling reference objects.}
-
-\item{raw}{whether to save the model in a raw variable or not, recommended to leave it to \code{TRUE}.}
-}
-\value{
-NULL invisibly.
-}
-\description{
-Attempts to save a model using RDS. Has an additional parameter (\code{raw}) which decides whether to save the raw model or not.
-}
-\examples{
-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
-)
-saveRDS.lgb.Booster(model, "model.rds")
-}
diff --git a/R-package/man/setinfo.Rd b/R-package/man/setinfo.Rd
deleted file mode 100644
index 92da5034659a..000000000000
--- a/R-package/man/setinfo.Rd
+++ /dev/null
@@ -1,50 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.Dataset.R
-\name{setinfo}
-\alias{setinfo}
-\alias{setinfo.lgb.Dataset}
-\title{Set information of an lgb.Dataset object}
-\usage{
-setinfo(dataset, ...)
-
-\method{setinfo}{lgb.Dataset}(dataset, name, info, ...)
-}
-\arguments{
-\item{dataset}{Object of class "lgb.Dataset"}
-
-\item{...}{other parameters}
-
-\item{name}{the name of the field to get}
-
-\item{info}{the specific field of information to set}
-}
-\value{
-passed object
-}
-\description{
-Set information of an lgb.Dataset object
-}
-\details{
-The \code{name} field can be one of the following:
-
-\itemize{
- \item \code{label}: label lightgbm learn from ;
- \item \code{weight}: to do a weight rescale ;
- \item \code{init_score}: initial score is the base prediction lightgbm will boost from ;
- \item \code{group}.
-}
-}
-\examples{
-library(lightgbm)
-data(agaricus.train, package = "lightgbm")
-train <- agaricus.train
-dtrain <- lgb.Dataset(train$data, label = train$label)
-lgb.Dataset.construct(dtrain)
-
-labels <- lightgbm::getinfo(dtrain, "label")
-lightgbm::setinfo(dtrain, "label", 1 - labels)
-
-labels2 <- lightgbm::getinfo(dtrain, "label")
-stopifnot(all.equal(labels2, 1 - labels))
-
-}
diff --git a/R-package/man/slice.Rd b/R-package/man/slice.Rd
deleted file mode 100644
index e126b89a837a..000000000000
--- a/R-package/man/slice.Rd
+++ /dev/null
@@ -1,36 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lgb.Dataset.R
-\name{slice}
-\alias{slice}
-\alias{slice.lgb.Dataset}
-\title{Slice a dataset}
-\usage{
-slice(dataset, ...)
-
-\method{slice}{lgb.Dataset}(dataset, idxset, ...)
-}
-\arguments{
-\item{dataset}{Object of class "lgb.Dataset"}
-
-\item{...}{other parameters (currently not used)}
-
-\item{idxset}{a integer vector of indices of rows needed}
-}
-\value{
-constructed sub dataset
-}
-\description{
-Get a new \code{lgb.Dataset} containing the specified rows of
-original lgb.Dataset object
-}
-\examples{
-library(lightgbm)
-data(agaricus.train, package = "lightgbm")
-train <- agaricus.train
-dtrain <- lgb.Dataset(train$data, label = train$label)
-
-dsub <- lightgbm::slice(dtrain, 1:42)
-lgb.Dataset.construct(dsub)
-labels <- lightgbm::getinfo(dsub, "label")
-
-}
diff --git a/build_r_site.R b/build_r_site.R
index 3538daee8f54..6c456934baba 100644
--- a/build_r_site.R
+++ b/build_r_site.R
@@ -1,23 +1,22 @@
-setwd("/home/docs/checkouts/readthedocs.org/user_builds/lightgbm/checkouts/docs/lightgbm_r")
+library(pkgdown)
-if (!dir.exists("./docs")) {
- dir.create("./docs")
+setwd("lightgbm_r")
+if (!dir.exists("docs")) {
+ dir.create("docs")
}
-print("========================building pkgdown site====================================")
-# options(pkgdown.internet=FALSE)
-library(pkgdown)
-
clean_site()
init_site()
-build_home(quiet = FALSE, preview = FALSE)
-build_reference(document = TRUE, preview = FALSE)
+build_home(preview = FALSE, quiet = FALSE)
+build_reference(lazy = FALSE, document = TRUE,
+ examples = TRUE, run_dont_run = FALSE,
+ seed = 42, preview = FALSE)
# # to-do
# build_articles(preview = FALSE)
# build_tutorials(preview = FALSE)
# build_news(preview = FALSE)
-# # don't work
+# # doesn't work
# pkgdown::build_site(pkg = ".", examples = FALSE, document = TRUE,
# run_dont_run = TRUE, seed = 1014, lazy = FALSE,
# override = list(), preview = NA, new_process = FALSE)
diff --git a/docs/Parameters.rst b/docs/Parameters.rst
index 99d5a2bb1c82..d1c1f476906d 100644
--- a/docs/Parameters.rst
+++ b/docs/Parameters.rst
@@ -51,7 +51,7 @@ Core Parameters
- **Note**: can be used only in CLI version; for language-specific packages you can use the correspondent functions
-- ``objective`` :raw-html:`🔗︎`, default = ``regression``, type = enum, options: ``regression``, ``regression_l1``, ``huber``, ``fair``, ``poisson``, ``quantile``, ``mape``, ``gammma``, ``tweedie``, ``binary``, ``multiclass``, ``multiclassova``, ``xentropy``, ``xentlambda``, ``lambdarank``, aliases: ``objective_type``, ``app``, ``application``
+- ``objective`` :raw-html:`🔗︎`, default = ``regression``, type = enum, options: ``regression``, ``regression_l1``, ``huber``, ``fair``, ``poisson``, ``quantile``, ``mape``, ``gamma``, ``tweedie``, ``binary``, ``multiclass``, ``multiclassova``, ``xentropy``, ``xentlambda``, ``lambdarank``, aliases: ``objective_type``, ``app``, ``application``
- regression application
@@ -190,7 +190,7 @@ Learning Control Parameters
- limit the max depth for tree model. This is used to deal with over-fitting when ``#data`` is small. Tree still grows leaf-wise
- - ``< 0`` means no limit
+ - ``<= 0`` means no limit
- ``min_data_in_leaf`` :raw-html:`🔗︎`, default = ``20``, type = int, aliases: ``min_data_per_leaf``, ``min_data``, ``min_child_samples``, constraints: ``min_data_in_leaf >= 0``
diff --git a/docs/Python-Intro.rst b/docs/Python-Intro.rst
index e0622e45f858..edb7043f9a10 100644
--- a/docs/Python-Intro.rst
+++ b/docs/Python-Intro.rst
@@ -207,7 +207,7 @@ Note that ``train()`` will return a model from the best iteration.
This works with both metrics to minimize (L2, log loss, etc.) and to maximize (NDCG, AUC, etc.).
Note that if you specify more than one evaluation metric, all of them will be used for early stopping.
-However, you can change this behavior and make LightGBM check only the first metric for early stopping by creating ``early_stopping`` callback with ``first_metric_only=True``.
+However, you can change this behavior and make LightGBM check only the first metric for early stopping by passing ``first_metric_only=True`` in ``param`` or ``early_stopping`` callback constructor.
Prediction
----------
diff --git a/docs/conf.py b/docs/conf.py
index 689f30e4ed85..3b1332e0a9d3 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -226,11 +226,11 @@ def generate_r_docs(app):
conda install -q -y -n r_env -c conda-forge r-pkgdown
source activate r_env
export TAR=/bin/tar
- cd /home/docs/checkouts/readthedocs.org/user_builds/lightgbm/checkouts/docs
+ cd {0}
sed -i'.bak' '/# Build the package (do not touch this line!)/q' build_r.R
Rscript build_r.R
Rscript build_r_site.R
- """
+ """.format(os.path.join(CURR_PATH, os.path.pardir))
try:
# Warning! The following code can cause buffer overflows on RTD.
# Consider suppressing output completely if RTD project silently fails.
@@ -262,10 +262,12 @@ def setup(app):
open(os.path.join(CURR_PATH, '_FIRST_RUN.flag'), 'w').close()
if C_API and (not RTD or first_run):
app.connect("builder-inited", generate_doxygen_xml)
- else:
+ elif not C_API:
app.add_directive('doxygenfile', IgnoredDirective)
if R_API:
if not RTD or first_run:
app.connect("builder-inited", generate_r_docs)
- app.connect("build-finished", lambda app, exception: copy_tree(app.confdir + '/../lightgbm_r/docs', app.outdir + '/R', verbose=0))
+ app.connect("build-finished",
+ lambda app, exception: copy_tree(os.path.join(CURR_PATH, os.path.pardir, "lightgbm_r", "docs"),
+ os.path.join(app.outdir, "R"), verbose=0))
app.add_javascript("js/script.js")
diff --git a/include/LightGBM/config.h b/include/LightGBM/config.h
index 2a6896f82dc0..e1c1427d1760 100644
--- a/include/LightGBM/config.h
+++ b/include/LightGBM/config.h
@@ -102,7 +102,7 @@ struct Config {
// [doc-only]
// type = enum
- // options = regression, regression_l1, huber, fair, poisson, quantile, mape, gammma, tweedie, binary, multiclass, multiclassova, xentropy, xentlambda, lambdarank
+ // options = regression, regression_l1, huber, fair, poisson, quantile, mape, gamma, tweedie, binary, multiclass, multiclassova, xentropy, xentlambda, lambdarank
// alias = objective_type, app, application
// desc = regression application
// descl2 = ``regression_l2``, L2 loss, aliases: ``regression``, ``mean_squared_error``, ``mse``, ``l2_root``, ``root_mean_squared_error``, ``rmse``
@@ -212,7 +212,7 @@ struct Config {
#pragma region Learning Control Parameters
// desc = limit the max depth for tree model. This is used to deal with over-fitting when ``#data`` is small. Tree still grows leaf-wise
- // desc = ``< 0`` means no limit
+ // desc = ``<= 0`` means no limit
int max_depth = -1;
// alias = min_data_per_leaf, min_data, min_child_samples
diff --git a/python-package/lightgbm/engine.py b/python-package/lightgbm/engine.py
index c6bfb70c6460..a04aa30fc69f 100644
--- a/python-package/lightgbm/engine.py
+++ b/python-package/lightgbm/engine.py
@@ -66,8 +66,7 @@ def train(params, train_set, num_boost_round=100,
to continue training.
Requires at least one validation data and one metric.
If there's more than one, will check all of them. But the training data is ignored anyway.
- To check only the first metric you can pass in ``callbacks``
- ``early_stopping`` callback with ``first_metric_only=True``.
+ To check only the first metric, set the ``first_metric_only`` parameter to ``True`` in ``params``.
The index of iteration that has the best performance will be saved in the ``best_iteration`` field
if early stopping logic is enabled by setting ``early_stopping_rounds``.
evals_result: dict or None, optional (default=None)
@@ -116,14 +115,15 @@ def train(params, train_set, num_boost_round=100,
for alias in ["num_iterations", "num_iteration", "n_iter", "num_tree", "num_trees",
"num_round", "num_rounds", "num_boost_round", "n_estimators"]:
if alias in params:
- num_boost_round = int(params.pop(alias))
+ num_boost_round = params.pop(alias)
warnings.warn("Found `{}` in params. Will use it instead of argument".format(alias))
break
for alias in ["early_stopping_round", "early_stopping_rounds", "early_stopping"]:
- if alias in params and params[alias] is not None:
- early_stopping_rounds = int(params.pop(alias))
+ if alias in params:
+ early_stopping_rounds = params.pop(alias)
warnings.warn("Found `{}` in params. Will use it instead of argument".format(alias))
break
+ first_metric_only = params.pop('first_metric_only', False)
if num_boost_round <= 0:
raise ValueError("num_boost_round should be greater than zero.")
@@ -181,7 +181,7 @@ def train(params, train_set, num_boost_round=100,
callbacks.add(callback.print_evaluation(verbose_eval))
if early_stopping_rounds is not None:
- callbacks.add(callback.early_stopping(early_stopping_rounds, verbose=bool(verbose_eval)))
+ callbacks.add(callback.early_stopping(early_stopping_rounds, first_metric_only, verbose=bool(verbose_eval)))
if learning_rates is not None:
callbacks.add(callback.reset_parameter(learning_rate=learning_rates))
@@ -400,8 +400,7 @@ def cv(params, train_set, num_boost_round=100,
CV score needs to improve at least every ``early_stopping_rounds`` round(s)
to continue.
Requires at least one metric. If there's more than one, will check all of them.
- To check only the first metric you can pass in ``callbacks``
- ``early_stopping`` callback with ``first_metric_only=True``.
+ To check only the first metric, set the ``first_metric_only`` parameter to ``True`` in ``params``.
Last entry in evaluation history is the one from the best iteration.
fpreproc : callable or None, optional (default=None)
Preprocessing function that takes (dtrain, dtest, params)
@@ -449,6 +448,7 @@ def cv(params, train_set, num_boost_round=100,
warnings.warn("Found `{}` in params. Will use it instead of argument".format(alias))
early_stopping_rounds = params.pop(alias)
break
+ first_metric_only = params.pop('first_metric_only', False)
if num_boost_round <= 0:
raise ValueError("num_boost_round should be greater than zero.")
@@ -480,7 +480,7 @@ def cv(params, train_set, num_boost_round=100,
cb.__dict__.setdefault('order', i - len(callbacks))
callbacks = set(callbacks)
if early_stopping_rounds is not None:
- callbacks.add(callback.early_stopping(early_stopping_rounds, verbose=False))
+ callbacks.add(callback.early_stopping(early_stopping_rounds, first_metric_only, verbose=False))
if verbose_eval is True:
callbacks.add(callback.print_evaluation(show_stdv=show_stdv))
elif isinstance(verbose_eval, integer_types):
diff --git a/python-package/lightgbm/sklearn.py b/python-package/lightgbm/sklearn.py
index c31f2ff5b646..60ac9bf60f26 100644
--- a/python-package/lightgbm/sklearn.py
+++ b/python-package/lightgbm/sklearn.py
@@ -152,7 +152,7 @@ def __init__(self, boosting_type='gbdt', num_leaves=31, max_depth=-1,
num_leaves : int, optional (default=31)
Maximum tree leaves for base learners.
max_depth : int, optional (default=-1)
- Maximum tree depth for base learners, -1 means no limit.
+ Maximum tree depth for base learners, <=0 means no limit.
learning_rate : float, optional (default=0.1)
Boosting learning rate.
You can use ``callbacks`` parameter of ``fit`` method to shrink/adapt learning rate
@@ -376,8 +376,8 @@ def fit(self, X, y,
to continue training.
Requires at least one validation data and one metric.
If there's more than one, will check all of them. But the training data is ignored anyway.
- To check only the first metric you can pass in ``callbacks``
- ``early_stopping`` callback with ``first_metric_only=True``.
+ To check only the first metric, set the ``first_metric_only`` parameter to ``True``
+ in additional parameters ``**kwargs`` of the model constructor.
verbose : bool or int, optional (default=True)
Requires at least one evaluation data.
If True, the eval metric on the eval set is printed at each boosting stage.
diff --git a/tests/python_package_test/test_consistency.py b/tests/python_package_test/test_consistency.py
index 89e2e5ce0140..27de80e1b1e0 100644
--- a/tests/python_package_test/test_consistency.py
+++ b/tests/python_package_test/test_consistency.py
@@ -21,7 +21,7 @@ def __init__(self, directory, prefix, config_file='train.conf'):
if line and not line.startswith('#'):
key, value = [token.strip() for token in line.split('=')]
if 'early_stopping' not in key: # disable early_stopping
- self.params[key] = value
+ self.params[key] = value if key != 'num_trees' else int(value)
def load_dataset(self, suffix, is_sparse=False):
filename = self.path(suffix)
diff --git a/tests/python_package_test/test_engine.py b/tests/python_package_test/test_engine.py
index 35ac2c2856af..c68f17320008 100644
--- a/tests/python_package_test/test_engine.py
+++ b/tests/python_package_test/test_engine.py
@@ -1379,24 +1379,23 @@ def constant_metric(preds, train_data):
return ('constant_metric', 0.0, False)
# test that all metrics are checked (default behaviour)
- early_stop_callback = lgb.early_stopping(5, verbose=False)
gbm = lgb.train(params, lgb_train, num_boost_round=20, valid_sets=[lgb_eval],
feval=lambda preds, train_data: [decreasing_metric(preds, train_data),
constant_metric(preds, train_data)],
- callbacks=[early_stop_callback])
+ early_stopping_rounds=5, verbose_eval=False)
self.assertEqual(gbm.best_iteration, 1)
# test that only the first metric is checked
- early_stop_callback = lgb.early_stopping(5, first_metric_only=True, verbose=False)
- gbm = lgb.train(params, lgb_train, num_boost_round=20, valid_sets=[lgb_eval],
+ gbm = lgb.train(dict(params, first_metric_only=True), lgb_train,
+ num_boost_round=20, valid_sets=[lgb_eval],
feval=lambda preds, train_data: [decreasing_metric(preds, train_data),
constant_metric(preds, train_data)],
- callbacks=[early_stop_callback])
+ early_stopping_rounds=5, verbose_eval=False)
self.assertEqual(gbm.best_iteration, 20)
# ... change the order of metrics
- early_stop_callback = lgb.early_stopping(5, first_metric_only=True, verbose=False)
- gbm = lgb.train(params, lgb_train, num_boost_round=20, valid_sets=[lgb_eval],
+ gbm = lgb.train(dict(params, first_metric_only=True), lgb_train,
+ num_boost_round=20, valid_sets=[lgb_eval],
feval=lambda preds, train_data: [constant_metric(preds, train_data),
decreasing_metric(preds, train_data)],
- callbacks=[early_stop_callback])
+ early_stopping_rounds=5, verbose_eval=False)
self.assertEqual(gbm.best_iteration, 1)