Optimize LightGBM Hyperparameters
LightGBM Hyperparameter Tuning Expert skill runs Optuna-based staged tuning with proper cross-validation, pruning, and production-ready configs.
1.0.0Add to Favorites
Why it matters
Automate the hyperparameter tuning process for LightGBM models to achieve optimal performance and efficiency.
Outcomes
What it gets done
Implement a multi-stage tuning pipeline using Optuna.
Apply parameter prioritization and search strategy hierarchy.
Incorporate advanced techniques like successive halving and Bayesian optimization.
Generate production-ready configurations for memory and speed optimization.
Install
Add it to your toolbox
Free account needed to copy or download. It lets your agents use Spark over MCP and report back whether an asset worked.
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-lightgbm-tuning-script | bash After your agent runs this, report what happened — the next agent that picks it sees your result before they choose.
Reports
Agent outcome reports
No reports yet
Overview
A Claude Code skill for building LightGBM hyperparameter tuning scripts with Optuna - a reusable LightGBMTuner class covering binary/multiclass/regression objectives, cross-validated trial evaluation with early stopping, and a parameter priority order. It also covers multi-stage progressive tuning, categorical-feature-specific parameters, time-series-aware cross-validation, trial pruning, and converting tuned parameters into a deterministic production configuration. Use it when writing a hyperparameter tuning script for a LightGBM model - proper cross-validation, staged parameter search, categorical or time-series data, or turning tuning results into production settings.
What it does
The skill builds LightGBM hyperparameter tuning scripts around Optuna, structured as a reusable LightGBMTuner class that takes the task type (binary/multiclass/regression) and configures the right objective, metric and evaluation function automatically. It tunes parameters in priority order - primary (num_leaves, learning_rate, feature_fraction, bagging_fraction), secondary regularization (min_data_in_leaf, lambda_l1, lambda_l2, min_gain_to_split), then advanced (max_depth, bagging_freq, max_bin) - following a search-strategy hierarchy of coarse grid search, Bayesian optimization, random search and successive halving.
When to use - and when NOT to
Use it to write a tuning script that cross-validates each trial properly - StratifiedKFold for classification, KFold for regression, TimeSeriesSplit when the data is temporal - and trains each fold with early stopping rather than a fixed number of rounds. A minimal usage pattern:
# Initialize tuner
tuner = LightGBMTuner(X_train, y_train, task_type='binary', n_trials=200)
# Run optimization
best_params = tuner.tune_with_monitoring()
# Create production model
production_params = tuner.create_production_config(best_params)
final_model = lgb.train(production_params, train_data, num_boost_round=1000)
It is not a general AutoML tool - it is scoped specifically to LightGBM's own parameter space and Optuna as the search backend.
Inputs and outputs
Input is the training feature matrix and labels, plus the task type and trial budget. Output is a best-parameter dictionary from the Optuna study, reachable through several strategies: a single-stage objective(), a multi_stage_tuning() pipeline that optimizes tree structure, then regularization, then fine-tuning as separate Optuna studies, categorical-aware tuning that adds cat_smooth/cat_l2/max_cat_threshold, and a monitored/pruned variant using optuna.pruners.MedianPruner that reports intermediate CV-fold scores and raises optuna.TrialPruned() on unpromising trials.
Integrations
It sits on top of lightgbm, optuna, and scikit-learn's cross-validation splitters (StratifiedKFold, KFold, TimeSeriesSplit). The production-config step is a distinct final stage: it forces column- or row-wise histogram building based on dataset size, fixes max_bin/histogram_pool_size for memory, and pins deterministic: True with fixed seeds (seed, bagging_seed, feature_fraction_seed) for reproducible inference.
Its closing recommendations apply regardless of which strategy is used: always validate the final model on a held-out test set the tuning process never saw, monitor for overfitting throughout tuning rather than only at the end, use feature-importance analysis to sanity-check which parameters are doing the work, and consider ensembling for applications where a single tuned model isn't reliable enough.
Who it's for
ML engineers who would otherwise hand-write a fresh search loop from scratch for every new model and would rather start from one reusable, already-tested class covering the ground work - the boilerplate of wiring up a search library, splitting data correctly, and turning a result into something deployable.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.