Skip to content

Guide · Open source

How to use LightGBM: install, train a model and tips

Updated · written with AI from the project's own documentation and checked against our catalogue data

LightGBM is an open-source gradient boosting framework that builds prediction models from decision trees. It is aimed at people who work with tabular data and are comfortable writing code in Python or R. This guide covers what it is, how to install it, where to find the training documentation, and when a different tool may suit you better.

LightGBMlightgbm-org/LightGBM · ★ 18.9k · MIT

Quick start

  1. 1Check your prerequisites. Make sure Python or R is installed, since the README lists these as the requirements.
  2. 2Install the package. Run pip install lightgbm to install it from PyPI.
  3. 3Read the installation guide. Open the installation instructions on lightgbm.readthedocs.io for platform details.
  4. 4Prepare your tabular data. Organise your dataset in rows and columns, the format gradient boosting handles well.
  5. 5Run an example. Start from a matching example in the Examples folder for your task, such as classification or ranking.
  6. 6Tune and scale. Use the Parameters reference, and the distributed or GPU guides if training is slow.

What LightGBM is and what it is good for

LightGBM is a gradient boosting framework that uses tree based learning algorithms. The project says it is designed to be distributed and efficient, with faster training, lower memory use, and better accuracy than existing boosting frameworks in its comparison experiments.

It is used for tasks such as ranking, classification and other prediction problems.

  • Faster training speed and higher efficiency.
  • Lower memory usage.
  • Support of parallel, distributed, and GPU learning.
  • Capable of handling large-scale data.

Who should use LightGBM and who should not

LightGBM suits data scientists working with tabular data, teams training on large datasets that may need distributed or GPU training, and people building ranking or classification models in Python or R.

It is not a good fit for beginners with no programming experience, because it is a developer-oriented library that requires coding. It is also not built for deep learning on images, audio or text, since it is based on decision trees rather than neural networks, and it does not offer a graphical interface.

Install LightGBM with pip

The README points to PyPI, conda and CRAN packages. The install command it lists for PyPI is shown below. You need Python or R installed first. The project's installation guide on the documentation site is the place to check platform-specific steps.

pip install lightgbm

Train your first model

The README does not include a training code sample. It points to the Examples folder, which shows command line usage of common tasks, and to the documentation site for the Python and R interfaces. Start with an example that matches your task, such as classification or ranking, and adapt it to your own data.

Once you have a model working, the Parameters page lists the settings you can customise.

  • Read the installation guide at lightgbm.readthedocs.io.
  • Pick a matching example from the Examples folder.
  • Check the Parameters reference before tuning.

Speed up training with distributed or GPU learning

LightGBM supports parallel, distributed, and GPU training. The README links to a Parallel Learning Guide and a GPU Tutorial that explain these modes. The README also says distributed experiments showed linear speed-up across multiple machines in specific settings, so results will depend on your setup.

For automated tuning, the README lists FLAML and Optuna integrations that provide tuning for LightGBM.

  • Distributed learning: see the Parallel Learning Guide.
  • GPU learning: see the GPU Tutorial.
  • Automated tuning: FLAML or the Optuna Hyperparameter Tuner.

Deploy or explain a trained model

The README lists several unofficial, unmaintained projects that extend LightGBM. Examples include Treelite for compiling models for fast deployment, SHAP for explaining model output, and ONNXMLTools for ONNX conversion. These are not officially endorsed by the LightGBM team, so check each project before relying on it.

  • Treelite: model compiler for efficient deployment.
  • SHAP: model output explainer.
  • ONNXMLTools: ONNX converter.

What people use it for

  • Classification models on tabular business data
  • Ranking models for search or recommendation tasks
  • Training gradient boosted models on large datasets across multiple machines
  • Adding GPU training to speed up model fitting

Frequently asked questions

Is LightGBM free to use?

LightGBM is released under the MIT licence, which is a permissive open-source licence. The source is on GitHub, so you can download and use it. Check the LICENSE file in the repository for the full terms.

How do I install LightGBM?

The README lists pip install lightgbm for the PyPI package. It also mentions conda and CRAN packages. You need Python or R installed first.

What is LightGBM used for?

The project describes it as used for ranking, classification and many other machine learning tasks. It works on tree-based gradient boosting for tabular data.

Is LightGBM better than XGBoost?

The README claims LightGBM can outperform existing boosting frameworks in its comparison experiments on public datasets. Results vary by dataset and setup, so test both tools on your own data. XGBoost, CatBoost and scikit-learn are listed as comparable projects.

Does LightGBM support GPU training?

Yes. The README lists GPU learning as a supported feature and links to a GPU Tutorial in the repository. Your hardware and setup will determine what you need.

Can beginners use LightGBM?

It requires coding, so it is not a good first tool for people with no programming experience. Learning basic Python or R and some machine learning concepts will help before you start.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

LightGBM suits data scientists and teams who work with tabular data in Python or R and want a fast gradient boosting library that can scale to large datasets. If you need deep learning on images, audio or text, or a graphical tool with no coding, pick a different option.

Install options & downloads