SQL-native histogram GBDT in DuckDB with vendor dump import and plain-SQL export
Compatibility Matrix
This table covers all DuckDB releases that have not reached end-of-life, including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.
| Platform | 1.4.4 | 1.4.5 | 1.5.5 | 1.5.6 | 2.0.0 |
|---|---|---|---|---|---|
| Linux AMD64 | |||||
| Linux ARM64 | |||||
| macOS AMD64 | |||||
| macOS ARM64 | |||||
| Windows AMD64 | |||||
| Windows ARM64 | |||||
| WebAssembly |
Installing and Loading
INSTALL duckboost FROM community;
LOAD duckboost;
Example
LOAD duckboost;
CREATE TABLE penguins AS
SELECT
body_mass_g::DOUBLE AS body_mass_g,
[bill_length_mm, bill_depth_mm, flipper_length_mm, (sex = 'male')::DOUBLE] AS features
FROM read_csv(
'https://raw.githubusercontent.com/allisonhorst/palmerpenguins/master/inst/extdata/penguins.csv',
nullstr = 'NA'
)
WHERE body_mass_g IS NOT NULL
AND bill_length_mm IS NOT NULL
AND sex IS NOT NULL;
CREATE TABLE models AS
SELECT duckboost_train(
body_mass_g, features,
MAP {
'backend': 'native',
'n_estimators': '40',
'max_depth': '3',
'learning_rate': '0.15',
'feature_names': 'bill_length_mm,bill_depth_mm,flipper_length_mm,male'
}
) AS model
FROM penguins;
SELECT
round(body_mass_g, 0) AS body_mass_g,
round(duckboost_predict(model, features), 0) AS pred_g
FROM models, penguins
ORDER BY body_mass_g
LIMIT 5;
About duckboost
duckboost trains a dependency-free histogram GBDT inside DuckDB
(backend = 'native', alias 'reference'), evaluates and inspects models in SQL,
imports XGBoost / LightGBM / CatBoost dumps, and exports orbital-style SQL
(duckboost_to_sql) for inference without the extension.
The Getting Started page walks through the same Palmer penguins first model using the package CSV over HTTPS.
Default community binaries ship the native trainer plus dump import.
Optional in-process XGBoost / LightGBM training requires rebuilding with
DUCKBOOST_WITH_XGBOOST / DUCKBOOST_WITH_LIGHTGBM. CatBoost is import-only.
Added Functions
| function_name | function_type | description | comment | examples |
|---|---|---|---|---|
| duckboost_backends | table | List available GBDT backends and whether this binary can train them in-process | NULL | [SELECT * FROM duckboost_backends();] |
| duckboost_build_info | table | Report compile-time duckboost build flags and linked trainers | NULL | [SELECT * FROM duckboost_build_info();] |
| duckboost_dummy | macro | One-hot or reference-level dummy encode a categorical value against known levels | NULL | [duckboost_dummy(sex, ['female','male'])] |
| duckboost_dummy_names | macro | Column names matching duckboost_dummy output for the given levels | NULL | [duckboost_dummy_names('sex', ['female','male'])] |
| duckboost_evaluate | scalar | Per-row evaluation score for a model prediction vs label | NULL | [duckboost_evaluate(model, y, features)] |
| duckboost_evaluate_agg | aggregate | Aggregate evaluation metric (rmse, auc, brier_score, …) over labeled rows | NULL | [duckboost_evaluate_agg(model, y, features, MAP {'metric': 'rmse'})] |
| duckboost_fit | table_macro | Train a model from a table name (table macro wrapper around duckboost_train) | NULL | [FROM duckboost_fit('penguins', 'body_mass_g', 'features', options := MAP {'backend': 'native'})] |
| duckboost_import | scalar | Import an XGBoost, LightGBM, or CatBoost model dump into duckboost JSON | NULL | [duckboost_import('xgboost', dump_json)] |
| duckboost_importance | table | Feature importance table (gain, cover, frequency) for a trained model | NULL | [SELECT * FROM duckboost_importance(model);] |
| duckboost_initial_split | table_macro | Add a train/test split column by content-hash (optional strata) | NULL | [FROM duckboost_initial_split('penguins', prop := 0.75)] |
| duckboost_initial_validation_split | table_macro | Add train/validation/test split columns by content-hash (optional strata) | NULL | [FROM duckboost_initial_validation_split('penguins', prop := [0.6, 0.2])] |
| duckboost_integer | macro | Map a categorical value to its 1-based position in levels (0 if absent) | NULL | [duckboost_integer(species, ['Adelie','Chinstrap','Gentoo'])] |
| duckboost_levels | macro | Collect distinct categorical levels that appear at least min_count times | NULL | [duckboost_levels(sex, min_count := 1)] |
| duckboost_other | macro | Collapse categorical values outside levels into a single other label | NULL | [duckboost_other(island, ['Biscoe','Dream'], other := 'other')] |
| duckboost_predict | scalar | Score one feature vector with a duckboost model | NULL | [duckboost_predict(model, features)] |
| duckboost_predict_proba | scalar | Class probabilities (or single-element list for regression) | NULL | [duckboost_predict_proba(model, features)] |
| duckboost_score | table_macro | Score every row of a table and append a prediction column | NULL | [FROM duckboost_score(model, 'penguins', 'features')] |
| duckboost_to_sql | scalar | Export a model as plain DuckDB SQL (DOUBLE literals) for inference without the extension | NULL | [duckboost_to_sql(model, 'penguins', ['bill_length_mm','bill_depth_mm'])] |
| duckboost_train | aggregate | Train a histogram GBDT (native) or linked vendor trainer; returns model JSON | NULL | [duckboost_train(y, features, MAP {'backend': 'native', 'n_estimators': '40'})] |
| duckboost_vfold | table_macro | Assign cross-validation fold ids by content-hash (optional strata) | NULL | [FROM duckboost_vfold('penguins', v := 5)] |
Overloaded Functions
This extension does not add any function overloads.
Added Types
This extension does not add any types.
Added Settings
| name | description | input_type | scope | aliases | typed_value |
|---|---|---|---|---|---|
| temp_directory | Set the directory to which temporary files are written. | VARCHAR | GLOBAL | [] | post.db.tmp |