Repository navigation
v0.1.0
First tagged release of vgi-lightgbm, a VGI worker that brings LightGBM into DuckDB/SQL. Train gradient-boosted models, keep them in a model registry, predict over SQL tables, and interpret them (feature importance, permutation importance, SHAP contributions, partial dependence), all as SQL functions. String columns become native LightGBM categorical splits, so no one-hot encoding is needed.
Functions and tables
- Datasets:
iris,wine,breast_cancer,diabetes,california_housing - Fit:
fit(JSONparams), typedfit_lgbm_classifier/fit_lgbm_regressor, which return the model as a BLOB and persist it whenmodel_nameis given - Registry:
models,model_info - Predict:
predict(bymodel_nameor inlinemodelBLOB;with_proba,output_margin,pred_leaf) - Cross-validation:
cross_val_predict,cross_val_score - Search:
grid_search,randomized_search(typed, list-valued hyperparameter arguments) - Interpretation:
feature_importance,permutation_importance,explain(SHAP),partial_dependence
Composed examples
The worker publishes example queries that combine its own functions:
- an out-of-fold confusion matrix (
cross_val_predictjoined back toiris) - gain importance next to permutation importance (
feature_importance+permutation_importance) - the SHAP drivers for each species (
explainjoined toiris)
Quick start
INSTALL vgi FROM community; LOAD vgi;
ATTACH 'lightgbm' (TYPE vgi, LOCATION 'uv run lightgbm_worker.py'); -- from a clone of this repo at v0.1.0
SELECT model_name, task FROM lightgbm.fit(
(SELECT * EXCLUDE (target_name) FROM lightgbm.iris()),
model_name := 'iris_clf', estimator := 'lgbm_classifier', target := 'target', id := 'sample_id');
SELECT * FROM lightgbm.predict((SELECT * FROM new_flowers), model_name := 'iris_clf', id := 'id');Notes and known limits
- This is a source-only release. Nothing is published to PyPI. Run the worker from a checkout (
uv run lightgbm_worker.py). - It needs VGI protocol 3.2+ (
vgi-python>= 0.50.0) and haybarn 2.0 with the current communityvgiextension. - Models are stored on local disk. Every column of the input relation except
idandtargetis treated as a feature, soSELECTonly the columns you want to use as features. - Only numeric, boolean and string feature columns are supported. Other column types raise an error.
See CHANGELOG.md for the full history.