### Install LightGBM dependencies Source: https://github.com/lightgbm-org/lightgbm/blob/master/examples/python-guide/README.md Install the required libraries for running the provided LightGBM examples. ```bash pip install scikit-learn pandas matplotlib scipy -U ``` -------------------------------- ### Run LightGBM example script Source: https://github.com/lightgbm-org/lightgbm/blob/master/examples/python-guide/README.md Execute a specific Python example script from the LightGBM repository. ```bash python simple_example.py ``` -------------------------------- ### Configure Installation and Build Flags Source: https://github.com/lightgbm-org/lightgbm/blob/master/CMakeLists.txt Handles installation paths for the CLI and sets specific prefixes for Python builds. ```cmake if(BUILD_CLI) install( TARGETS lightgbm RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin ) endif() if(__BUILD_FOR_PYTHON) set(CMAKE_INSTALL_PREFIX "lightgbm") endif() ``` -------------------------------- ### Install LightGBM from PyPI Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Install the LightGBM package from the Python Package Index (PyPI). This is the standard method for most users. ```sh pip install lightgbm ``` -------------------------------- ### Install LightGBM Python Package from GitHub Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Clone the repository and build the Python package. Administrator rights may be needed. Use '--user' for user-specific installation. ```sh git clone --recursive https://github.com/lightgbm-org/LightGBM.git cd LightGBM # export CXX=g++-14 CC=gcc-14 # macOS users, if you decided to compile with gcc, don't forget to specify compilers sh ./build-python.sh install ``` -------------------------------- ### Install LightGBM via pip Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Python-Intro.rst The standard command to install the LightGBM library in a Python environment. ```bash pip install lightgbm ``` -------------------------------- ### Build LightGBM with MinGW-w64 on Windows Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Install LightGBM using MinGW-w64 on Windows. Requires MinGW-w64 to be installed separately. Visual Studio is often recommended for better performance on Windows. ```sh pip install lightgbm --no-binary lightgbm --config-settings=cmake.define.CMAKE_SH=CMAKE_SH-NOTFOUND --config-settings=cmake.args="-GMinGW Makefiles" ``` -------------------------------- ### Resolve 'setup script specifies an absolute path' error Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/FAQ.rst This error occurred in older versions of the LightGBM Python package when installing from GitHub using 'python setup.py install'. It is resolved in newer versions. If the issue persists, try removing the 'lightgbm.egg-info' folder and reinstalling. ```console error: Error: setup script specifies an absolute path: /Users/Microsoft/LightGBM/python-package/lightgbm/../../lib_lightgbm.so setup() arguments must *always* be /-separated paths relative to the setup.py directory, *never* absolute paths. ``` -------------------------------- ### Build MPI Version of LightGBM Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Install LightGBM with MPI support enabled. Requires MPI libraries to be installed. ```sh pip install lightgbm --no-binary lightgbm --config-settings=cmake.define.USE_MPI=ON ``` -------------------------------- ### Build LightGBM from Source Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Install LightGBM by building it directly from the source code. This method is useful for development, custom builds, or when pre-compiled wheels are not suitable. ```sh pip install lightgbm --no-binary lightgbm ``` -------------------------------- ### Build and Install LightGBM CRAN Package Source: https://github.com/lightgbm-org/lightgbm/blob/master/R-package/README.md Commands to initialize submodules, build the source tarball, and install the resulting package into the R environment. ```shell git submodule update --init --recursive sh build-cran-package.sh R CMD install lightgbm_*.tar.gz ``` -------------------------------- ### Install LightGBM with Plotting Capabilities Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Install LightGBM with the necessary dependencies to utilize its plotting functionalities. This enables visualization of model trees and feature importances. ```sh pip install 'lightgbm[plotting]' ``` -------------------------------- ### Install LightGBM with PyArrow Support Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Install LightGBM along with all necessary dependencies to enable integration with PyArrow. This is useful for data processing pipelines that leverage PyArrow. ```sh pip install 'lightgbm[arrow]' ``` -------------------------------- ### Install NVIDIA Drivers and OpenCL Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/GPU-Tutorial.rst Commands to install the necessary NVIDIA drivers and OpenCL development headers on an Ubuntu system to support GPU acceleration. ```bash sudo apt-get update sudo apt-get install --no-install-recommends nvidia-375 sudo apt-get install --no-install-recommends nvidia-opencl-icd-375 nvidia-opencl-dev opencl-headers ``` -------------------------------- ### Build LightGBM from Source using CMake on Linux (Clang) Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Installation-Guide.rst Clone the repository, configure with CMake, and build using Clang. Ensure Clang and OpenMP are installed. Replace version numbers as needed. ```sh git clone --recursive https://github.com/lightgbm-org/LightGBM cd LightGBM export CXX=clang++-14 CC=clang-14 # replace "14" with version of Clang installed on your machine cmake -B build -S . cmake --build build -j4 ``` -------------------------------- ### Install LightGBM using Homebrew on macOS Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Installation-Guide.rst Install LightGBM directly using the Homebrew package manager. Refer to the Homebrew formula for more details. ```sh brew install lightgbm ``` -------------------------------- ### Build LightGBM from Source using CMake on macOS (Apple Clang) Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Installation-Guide.rst Clone the repository, install CMake and libomp via Homebrew, configure with CMake, and build. The executable and .dylib files will be in the LightGBM/ folder. ```sh brew install cmake libomp git clone --recursive https://github.com/lightgbm-org/LightGBM cd LightGBM cmake -B build -S . cmake --build build -j4 ``` -------------------------------- ### Build Docs Without C API Docs (Shell) Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/README.rst Builds the LightGBM documentation without including documentation for the C API. This is useful if Doxygen installation is problematic or C code documentation is not needed. Requires installing Sphinx. ```sh pip install sphinx 'sphinx_rtd_theme>=0.5' export C_API=NO || set C_API=NO make html ``` -------------------------------- ### Install LightGBM with Dask Support Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Install LightGBM with dependencies required for Dask integration. This allows for distributed training and prediction using LightGBM with Dask. ```sh pip install 'lightgbm[dask]' ``` -------------------------------- ### Build GPU Version with OpenCL Paths Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Install LightGBM with GPU support, specifying OpenCL include and library paths for CMake. ```sh pip install lightgbm --no-binary lightgbm --config-settings=cmake.define.USE_GPU=ON --config-settings=cmake.define.OpenCL_INCLUDE_DIR="/usr/local/cuda/include/" --config-settings=cmake.define.OpenCL_LIBRARY="/usr/local/cuda/lib64/libOpenCL.so" ``` -------------------------------- ### Build LightGBM with Time Costs Output Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Install LightGBM with time cost output enabled. Useful for performance investigation and benchmarking internal routines. ```sh pip install lightgbm --no-binary lightgbm --config-settings=cmake.define.USE_TIMETAG=ON ``` -------------------------------- ### Build LightGBM from Source using CMake on macOS (gcc) Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Installation-Guide.rst Clone the repository, install CMake and gcc via Homebrew, configure with CMake, and build. Replace gcc/g++ version numbers as needed. ```sh brew install cmake gcc git clone --recursive https://github.com/lightgbm-org/LightGBM cd LightGBM export CXX=g++-7 CC=gcc-7 # replace "7" with version of gcc installed on your machine cmake -B build -S . cmake --build build -j4 ``` -------------------------------- ### Build LightGBM Dynamic Library with MSBuild Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Compile the dynamic library using MSBuild on Windows. This is an alternative if direct installation fails. After compiling, use '--precompile' to install the Python package. ```sh MSBuild.exe windows/LightGBM.sln /p:Configuration=DLL /p:Platform=x64 /p:PlatformToolset=v143 ``` -------------------------------- ### Install LightGBM Nightly Packages Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Install the latest development version of LightGBM from the nightly build repository. Use this if you need the most recent features or bug fixes. ```sh pip install --no-deps --index-url https://pypi.anaconda.org/lightgbm-packages/simple lightgbm ``` -------------------------------- ### Install LightGBM R-package from CRAN Binaries Source: https://github.com/lightgbm-org/lightgbm/blob/master/R-package/README.md Installs the 'lightgbm' R package using precompiled binaries from CRAN. This method is faster and easier as it does not require compilation. It is available for Mac and Windows. ```r install.packages( "lightgbm" , type = "both" , repos = "https://cran.r-project.org" ) ``` -------------------------------- ### Build Docs Without Docker (Shell) Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/README.rst Builds the LightGBM documentation locally without Docker. Requires installing Python dependencies like Sphinx and Breathe. This method may not build R documentation. ```sh pip install breathe sphinx 'sphinx_rtd_theme>=0.5' make html ``` -------------------------------- ### Configure C/C++ Compilers for R Package Installation Source: https://github.com/lightgbm-org/lightgbm/blob/master/R-package/README.md This is a Makevars file example for Linux/macOS users to specify C and C++ compilers when building R packages from source. It overrides default compiler settings, for instance, to use gcc-14 instead of clang. ```make # ~/.R/Makevars CC=gcc-14 CC17=gcc-14 CXX=g++-14 CXX17=g++-14 ``` -------------------------------- ### Install LightGBM R Package from CRAN Source: https://github.com/lightgbm-org/lightgbm/blob/master/R-package/README.md This R command installs the lightgbm package directly from CRAN. It's the simplest installation method and does not require additional build tools like CMake or Visual Studio. ```r install.packages("lightgbm", repos = "https://cran.r-project.org") ``` -------------------------------- ### Run LightGBM CLI Training Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Quick-Start.rst Demonstrates how to run LightGBM training using the CLI. Parameters can be specified in a configuration file or directly on the command line. Command-line parameters override those in the configuration file. ```bash lightgbm config=your_config_file other_args ... ``` ```bash lightgbm config=train.conf num_trees=10 ``` -------------------------------- ### Build Docs with Docker (Shell) Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/README.rst Builds the LightGBM documentation using Docker, leveraging the same images used by Read the Docs. This method is recommended for reliability and includes C API and R documentation. ```sh docker run \ --rm \ --user=0 \ -v $(pwd):/opt/LightGBM \ --env C_API=true \ --env CONDA=/opt/miniforge \ --env READTHEDOCS=true \ --workdir=/opt/LightGBM/docs \ --entrypoint="" \ readthedocs/build:ubuntu-24.04-2024.06.17 \ /bin/bash build-docs.sh ``` -------------------------------- ### Build LightGBM from Source using CMake on Windows (VS Build Tools) Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Installation-Guide.rst Clone the repository, configure with CMake, and build the release version. The executable and DLL files will be located in the LightGBM/Release folder. ```console git clone --recursive https://github.com/lightgbm-org/LightGBM cd LightGBM cmake -B build -S . -A x64 cmake --build build --target ALL_BUILD --config Release ``` -------------------------------- ### Build LightGBM from Source using CMake on Windows (MinGW-w64) Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Installation-Guide.rst Clone the repository, configure with CMake using MinGW Makefiles, and build. The executable and DLL files will be in the LightGBM/ folder. Addresses potential 'sh.exe' path errors. ```console git clone --recursive https://github.com/lightgbm-org/LightGBM cd LightGBM cmake -B build -S . -G "MinGW Makefiles" cmake --build build -j4 ``` -------------------------------- ### Install CMake on macOS Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Installation-Guide.rst Install CMake using Homebrew on macOS. This is a prerequisite for building LightGBM on macOS using CMake. ```sh brew install cmake ``` -------------------------------- ### Install CMake and GCC on macOS Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Installation-Guide.rst Install CMake and GCC using Homebrew on macOS. This is a prerequisite for building LightGBM with GCC on macOS. ```sh brew install cmake gcc ``` -------------------------------- ### Conda: Install without MKL Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/FAQ.rst This command installs Conda packages without MKL optimizations, offering an alternative workaround for OpenMP conflicts. ```bash conda install nomkl ``` -------------------------------- ### Build LightGBM from Source using CMake on Linux (gcc) Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Installation-Guide.rst Clone the repository, configure with CMake, and build using gcc. The executable and .so files will be in the LightGBM/ folder. ```sh git clone --recursive https://github.com/lightgbm-org/LightGBM cd LightGBM cmake -B build -S . cmake --build build -j4 ``` -------------------------------- ### Train LightGBM Model on GPU and CPU Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/GPU-Tutorial.rst Executes training using the LightGBM command-line interface. The commands demonstrate how to toggle between GPU and CPU devices using the device parameter to compare performance and metric consistency. ```bash ./lightgbm config=lightgbm_gpu.conf data=higgs.train valid=higgs.test objective=binary metric=auc ./lightgbm config=lightgbm_gpu.conf data=higgs.train valid=higgs.test objective=binary metric=auc device=cpu ``` -------------------------------- ### Install LightGBM using MacPorts on macOS Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Installation-Guide.rst Install LightGBM using the MacPorts package manager. Note that the LightGBM port is not maintained by the LightGBM maintainers. ```sh sudo port install LightGBM ``` -------------------------------- ### Install LightGBM from conda-forge Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Install LightGBM using the conda package manager from the conda-forge channel. These packages support CPU, GPU, and CUDA versions. ```sh conda install -c conda-forge lightgbm ``` -------------------------------- ### Build LightGBM Java Wrapper on Windows with VS Build Tools Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Installation-Guide.rst Use these console commands to clone the LightGBM repository, configure the build with CMake for VS Build Tools, and compile the Java wrapper in Release mode. ```console git clone --recursive https://github.com/lightgbm-org/LightGBM cd LightGBM cmake -B build -S . -A x64 -DUSE_SWIG=ON cmake --build build --target ALL_BUILD --config Release ``` -------------------------------- ### Initialize LightGBM Dataset and Training Source: https://github.com/lightgbm-org/lightgbm/blob/master/examples/python-guide/notebooks/interactive_plot_example.ipynb Prepares training and testing datasets from pandas DataFrames and executes the LightGBM training process with metric tracking. ```python lgb_train = lgb.Dataset( X_train, y_train, feature_name=[f"f{i + 1}" for i in range(X_train.shape[-1])], categorical_feature=[21], ) lgb_test = lgb.Dataset(X_test, y_test, reference=lgb_train) params = {"num_leaves": 5, "metric": ["l1", "l2"], "verbose": -1} evals_result = {} gbm = lgb.train( params, lgb_train, num_boost_round=100, valid_sets=[lgb_train, lgb_test], callbacks=[lgb.log_evaluation(10), lgb.record_evaluation(evals_result)], ) ``` -------------------------------- ### Install LightGBM with Pandas Support Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Install LightGBM with dependencies needed for seamless integration with pandas DataFrames. This is common for data manipulation and feature engineering. ```sh pip install 'lightgbm[pandas]' ``` -------------------------------- ### Build LightGBM Java Wrapper on Windows with MinGW-w64 Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Installation-Guide.rst These commands clone the LightGBM repository and configure the build with CMake for MinGW Makefiles, followed by compilation. Includes a note on resolving potential 'sh.exe' errors. ```console git clone --recursive https://github.com/lightgbm-org/LightGBM cd LightGBM cmake -B build -S . -G "MinGW Makefiles" -DUSE_SWIG=ON cmake --build build -j4 ``` -------------------------------- ### Distributed CLI Configuration Files Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Parallel-Learning-Guide.rst Shows the format for machine list files required for socket-based and MPI-based distributed training in the LightGBM CLI. ```text # Socket Version (mlist.txt) machine1_ip 12345 machine2_ip 12345 # MPI Version (mlist.txt) machine1_ip machine2_ip ``` -------------------------------- ### LightGBM Training Configuration Parameters Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/GPU-Performance.rst A sample configuration file used for LightGBM training tasks. It specifies parameters such as tree structure, learning rate, and hardware acceleration settings for GPU execution. ```text max_bin = 63 num_leaves = 255 num_iterations = 500 learning_rate = 0.1 tree_learner = serial task = train is_training_metric = false min_data_in_leaf = 1 min_sum_hessian_in_leaf = 100 ndcg_eval_at = 1,3,5,10 device = gpu gpu_platform_id = 0 gpu_device_id = 0 num_thread = 28 ``` -------------------------------- ### Build LightGBM with MPI using CMake (Windows Command Line) Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Installation-Guide.rst Use this command to clone the LightGBM repository and build the MPI-enabled version using CMake and VS Build Tools on Windows. ```console git clone --recursive https://github.com/lightgbm-org/LightGBM cd LightGBM cmake -B build -S . -A x64 -DUSE_MPI=ON cmake --build build --target ALL_BUILD --config Release ``` -------------------------------- ### Install LightGBM with Scikit-learn Integration Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Install LightGBM with dependencies required for integration with scikit-learn. This allows using LightGBM models within scikit-learn pipelines and workflows. ```sh pip install 'lightgbm[scikit-learn]' ``` -------------------------------- ### LightGBM Documentation Resources Source: https://github.com/lightgbm-org/lightgbm/wiki/Configuration Links to the official LightGBM documentation for parameters, tuning, and Python API. ```APIDOC ## LightGBM Documentation Resources ### Parameters - [Parameters](https://lightgbm.readthedocs.io/en/latest/Parameters.html) - Detailed documentation for parameters in the CLI version of LightGBM. ### Parameters Tuning - [Parameters Tuning](https://lightgbm.readthedocs.io/en/latest/Parameters-Tuning.html) - Comprehensive guide on how to tune LightGBM parameters for optimal performance. ### Python API - [Python-API](https://lightgbm.readthedocs.io/en/latest/Python-API.html) - Reference for the exposed interfaces of the LightGBM Python package. ``` -------------------------------- ### Create LightGBM GPU Configuration File Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/GPU-Tutorial.rst Generates a configuration file for LightGBM that specifies GPU usage and training parameters for the Higgs dataset. ```bash cat > lightgbm_gpu.conf <> lightgbm_gpu.conf ``` -------------------------------- ### Build LightGBM with GPU Support Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/GPU-Tutorial.rst Steps to clone the LightGBM repository and compile the source code with GPU support enabled using CMake. ```bash git clone --recursive https://github.com/lightgbm-org/LightGBM cd LightGBM cmake -B build -S . -DUSE_GPU=1 cmake --build build -j$(nproc) ``` -------------------------------- ### Build C++ Tests with CMake and GCC on macOS Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Installation-Guide.rst Builds C++ unit tests for LightGBM on macOS using CMake and GCC. Ensure to replace '7' with your installed GCC version. Requires Homebrew for installation. ```sh brew install cmake gcc git clone --recursive https://github.com/lightgbm-org/LightGBM cd LightGBM export CXX=g++-7 CC=gcc-7 # replace "7" with version of gcc installed on your machine cmake -B build -S . -DBUILD_CPP_TEST=ON cmake --build build --target testlightgbm -j4 ``` -------------------------------- ### Manually install older Matrix package version Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/FAQ.rst Install an older version of the Matrix package to resolve dependency issues on older R versions. This is a workaround for CRAN's Matrix package requiring R >= 4.4.0. ```R install.packages('https://cran.r-project.org/src/contrib/Archive/Matrix/Matrix_1.6-5.tar.gz', repos = NULL) ``` -------------------------------- ### Load Data into LightGBM Dataset Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Python-Intro.rst Demonstrates creating a LightGBM Dataset object from various data sources including LibSVM files, NumPy arrays, and SciPy sparse matrices. ```python import lightgbm as lgb import numpy as np import scipy.sparse # Load from binary file train_data = lgb.Dataset('train.svm.bin') # Load from numpy array rng = np.random.default_rng() data = rng.uniform(size=(500, 10)) label = rng.integers(low=0, high=2, size=(500, )) train_data = lgb.Dataset(data, label=label) # Load from scipy sparse matrix csr = scipy.sparse.csr_matrix((dat, (row, col))) train_data = lgb.Dataset(csr) ``` -------------------------------- ### Position Bias Treatment Example Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Advanced-Topics.rst Encode positional data for position bias treatment in learning-to-rank. This example shows a binary encoding where 0 indicates a position not requiring scrolling and 1 indicates a position requiring scrolling. ```text 0 0 0 1 1 0 0 0 1 ... ``` -------------------------------- ### Clone and Build LightGBM on Windows with GPU Support Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/Installation-Guide.rst Clone the LightGBM repository and build the GPU-enabled version using CMake on Windows. Ensure Visual C++ and Boost are correctly configured. ```console git clone --recursive https://github.com/lightgbm-org/LightGBM cd LightGBM cmake -B build -S . -A x64 -DUSE_GPU=ON -DBOOST_ROOT=C:/local/boost_1_63_0 -DBOOST_LIBRARYDIR=C:/local/boost_1_63_0/lib64-msvc-14.3 # if you have installed NVIDIA CUDA to a customized location, you should specify paths to OpenCL headers and library like the following: # cmake -B build -S . -A x64 -DUSE_GPU=ON -DBOOST_ROOT=C:/local/boost_1_63_0 -DBOOST_LIBRARYDIR=C:/local/boost_1_63_0/lib64-msvc-14.3 -DOpenCL_LIBRARY="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/lib/x64/OpenCL.lib" -DOpenCL_INCLUDE_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/include" cmake --build build --target ALL_BUILD --config Release ``` -------------------------------- ### Verify LightGBM R Package Installation Source: https://github.com/lightgbm-org/lightgbm/blob/master/R-package/README.md This R code snippet demonstrates how to load the lightgbm package, prepare data using lgb.Dataset, and perform a cross-validation using lgb.cv. It serves as a basic test to ensure the package is installed and functioning correctly. ```r library(lightgbm) data(agaricus.train, package='lightgbm') train <- agaricus.train dtrain <- lgb.Dataset(train$data, label = train$label) model <- lgb.cv( params = list( objective = "regression" , metric = "l2" ) , data = dtrain ) ``` -------------------------------- ### Build Threadless LightGBM Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Install LightGBM without OpenMP support. This is generally not recommended. ```sh pip install lightgbm --no-binary lightgbm --config-settings=cmake.define.USE_OPENMP=OFF ``` -------------------------------- ### Build CUDA Version of LightGBM Source: https://github.com/lightgbm-org/lightgbm/blob/master/python-package/README.rst Install LightGBM with CUDA support enabled. Requires the CUDA library. Not supported on macOS or Windows. ```sh pip install lightgbm --no-binary lightgbm --config-settings=cmake.define.USE_CUDA=ON ``` -------------------------------- ### Configure LightGBM for GPU Training in R Source: https://github.com/lightgbm-org/lightgbm/blob/master/docs/GPU-Targets.rst This snippet demonstrates how to initialize a LightGBM dataset and train a model using GPU acceleration. It highlights the necessity of setting 'gpu_platform_id' and 'gpu_device_id' parameters to correctly target the desired hardware. ```r library(lightgbm) data(agaricus.train, package = "lightgbm") train <- agaricus.train train$data[, 1] <- 1:6513 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) valids <- list(test = dtest) params <- list(objective = "regression", metric = "rmse", device = "gpu", gpu_platform_id = 0, gpu_device_id = 0, nthread = 1, boost_from_average = FALSE, num_tree_per_iteration = 10, max_bin = 32) model <- lgb.train(params, dtrain, 2, valids, min_data = 1, learning_rate = 1, early_stopping_rounds = 10) ```