Lightgbm Python

Posted onby admin

Data Structure API¶

Lightgbm PythonLightgbm python api

Lightgbm parameter tuning example in python (lightgbm tuning) Finally, after the explanation of all important parameters, it is time to perform some experiments! I will use one of the popular Kaggle competitions: Santander Customer Transaction Prediction. I will use this article which explains how to run hyperparameter tuning in Python on any. Python API Reference Training data format ¶ LightGBM supports input data file with CSV, TSV and LibSVM formats. Label is the data of first column, and there is no header in the file.


Dataset(data[, label, reference, weight, …])

Dataset in LightGBM.

Booster([params, train_set, model_file, …])

Booster in LightGBM.


CVBooster in LightGBM.

Lightgbm load model python

Training API¶

So this is the recipe on how we can use LightGBM Classifier and Regressor. Step 1 - Import the library from sklearn import datasets from sklearn import metrics from sklearn.modelselection import traintestsplit import matplotlib.pyplot as plt import seaborn as sns'ggplot') import lightgbm as ltb. LightGBM is a fast, distributed, high performance gradient boosting framework based on decision tree algorithms, used for ranking, classification and many other machine learning tasks. It has helped Kagglers win data science competitions. So, let's get started. LightGBM is a gradient boosting framework that uses tree-based learning algorithms. LightGBM regressor helps while dealing with regression problems. So this recipe is a short example on How to use LIGHTGBM regressor work in python.

train(params, train_set[, num_boost_round, …])

Perform the training with given parameters.

cv(params, train_set[, num_boost_round, …])

Perform the cross-validation with given parameters.

Scikit-learn API¶

LGBMModel([boosting_type, num_leaves, …])

Implementation of the scikit-learn API for LightGBM.

LGBMClassifier([boosting_type, num_leaves, …])

LightGBM classifier.

LGBMRegressor([boosting_type, num_leaves, …])

LightGBM regressor.

LGBMRanker([boosting_type, num_leaves, …])

LightGBM ranker.

Lightgbm Python Example

Dask API¶

DaskLGBMClassifier([boosting_type, …])

Distributed version of lightgbm.LGBMClassifier.

DaskLGBMRegressor([boosting_type, …])

Distributed version of lightgbm.LGBMRegressor.

DaskLGBMRanker([boosting_type, num_leaves, …])

Distributed version of lightgbm.LGBMRanker.

Lightgbm Python


early_stopping(stopping_rounds[, …])

Create a callback that activates early stopping.

print_evaluation([period, show_stdv])

Create a callback that prints the evaluation results.


Create a callback that records the evaluation history into eval_result.


Create a callback that resets the parameter after the first iteration.


plot_importance(booster[, ax, height, xlim, …])

Plot model’s feature importances.

plot_split_value_histogram(booster, feature)

Plot split value histogram for the specified feature of the model.

plot_metric(booster[, metric, …])

Plot one metric during training.

plot_tree(booster[, ax, tree_index, …])

Plot specified tree.

create_tree_digraph(booster[, tree_index, …])

Create a digraph representation of specified tree.


Lgbm Classifier Cv


Register custom logger.