Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
A minimal LightGBM example performing classification on a small dataset.
import lightgbm as lgb
import numpy as np
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
# Load dataset
data = load_iris()
X_train, X_test, y_train, y_test = train_test_split(data.data, data.target, test_size=0.2, random_state=42)
# Create dataset for LightGBM
train_data = lgb.Dataset(X_train, label=y_train)
# Define parameters
params = {'objective':'multiclass','num_class':3,'metric':'multi_logloss'}
# Train model
model = lgb.train(params, train_data, num_boost_round=100)
# Predict
y_pred = model.predict(X_test)
y_pred_labels = np.argmax(y_pred, axis=1)
print('Accuracy:', accuracy_score(y_test, y_pred_labels))LightGBM (Light Gradient Boosting Machine) is a fast, distributed, high-performance gradient boosting framework based on decision tree algorithms, used for ranking, classification, and many other machine learning tasks.
Origin & Creator
LightGBM was developed by Microsoft’s DMTK team and released in 2016 to provide a faster and more memory-efficient gradient boosting framework compared to existing solutions.
Industrial Note
LightGBM is widely used in Kaggle competitions, finance, advertising, recommendation systems, and any scenario requiring high-speed gradient boosting on large datasets.