XGBoost
Train, tune, score and explain gradient-boosted tree models on your tables with plain SQL
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available · $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/xgboost/index.md to help me query XGBoost with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
Train a classifier and predict from SQL
Example output · captured
- Connector release
- v0.2.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
SET VARIABLE iris_model = (SELECT model FROM xgboost.main.fit((SELECT * FROM xgboost.main.iris), estimator := 'xgb_classifier', target := 'target', id := 'sample_id'));
SELECT sample_id, prediction FROM xgboost.main.predict((SELECT * FROM xgboost.main.iris), model := getvariable('iris_model'), id := 'sample_id') LIMIT 5;
| sample_id | prediction |
|---|---|
| 0 | 0 |
| 1 | 0 |
| 2 | 0 |
| 3 | 0 |
| 4 | 0 |
Quick start
Choose where to run XGBoost, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach with uv
Needs uv. uv fetches the worker script and its package at the release tag on first attach and reuses the cached environment after that.
ATTACH 'xgboost' AS xgboost (
TYPE vgi,
LOCATION 'uv run --with git+https://github.com/Query-farm/[email protected] https://raw.githubusercontent.com/Query-farm/vgi-xgboost/v0.2.0/xgboost_worker.py'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'xgboost' AS xgboost (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-xgboost:0.2.0'
);
3. Run a query
SET VARIABLE iris_model = (SELECT model FROM xgboost.main.fit((SELECT * FROM xgboost.main.iris), estimator := 'xgb_classifier', target := 'target', id := 'sample_id'));
SELECT sample_id, prediction FROM xgboost.main.predict((SELECT * FROM xgboost.main.iris), model := getvariable('iris_model'), id := 'sample_id') LIMIT 5;
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'xgboost' AS xgboost
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SET VARIABLE iris_model = (SELECT model FROM xgboost.main.fit((SELECT * FROM xgboost.main.iris), estimator := 'xgb_classifier', target := 'target', id := 'sample_id'));
SELECT sample_id, prediction FROM xgboost.main.predict((SELECT * FROM xgboost.main.iris), model := getvariable('iris_model'), id := 'sample_id') LIMIT 5;
Query Farm operates XGBoost for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use xgboost as the catalog alias for the query below.
4. Run a query
SET VARIABLE iris_model = (SELECT model FROM xgboost.main.fit((SELECT * FROM xgboost.main.iris), estimator := 'xgb_classifier', target := 'target', id := 'sample_id'));
SELECT sample_id, prediction FROM xgboost.main.predict((SELECT * FROM xgboost.main.iris), model := getvariable('iris_model'), id := 'sample_id') LIMIT 5;
Technical details
- Verified connector release
- v0.2.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach with uv
Needs uv. uv fetches the worker script and its package at the release tag on first attach and reuses the cached environment after that.
ATTACH 'xgboost' AS xgboost (
TYPE vgi,
LOCATION 'uv run --with git+https://github.com/Query-farm/[email protected] https://raw.githubusercontent.com/Query-farm/vgi-xgboost/v0.2.0/xgboost_worker.py'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'xgboost' AS xgboost (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-xgboost:0.2.0'
);
Overview
XGBoost train/predict model registry, datasets, and interpretation for DuckDB/SQL
Exposes XGBoost to DuckDB/SQL as VGI functions:
- Datasets — toy datasets and generators
- Models —
fit/predict, typedfit_<estimator>, cross-validation, grid/randomized search - Interpretation — feature importance, SHAP
explain, partial dependence, permutation importance
Models are stored as reusable BLOBs in a registry; native UBJSON serialization.
Catalog
Everything xgboost exposes once attached — read straight from the worker's
released build.
main 6 tables · 18 functions
XGBoost train/predict model registry, datasets, and interpretation for SQL
Schema examples (3)
Fit an XGBoost classifier on iris and return the training summary
SELECT estimator, task, n_samples, n_features, train_score
FROM xgboost.main.fit((SELECT * FROM xgboost.main.iris), estimator := 'xgb_classifier', target := 'target', id := 'sample_id');
Out-of-fold confusion matrix for an XGBoost iris classifier: 5-fold cross_val_predict on the species name, joined back to the iris table by sample_id and counted per (actual, predicted) species pair. Only non-empty cells are returned; the off-diagonal rows are the held-out misclassifications, almost all of them versicolor/virginica mix-ups.
SELECT i.target_name AS actual_species, cv.prediction AS predicted_species,
count(*) AS n_flowers
FROM xgboost.main.cross_val_predict((SELECT sample_id, sepal_length_cm, sepal_width_cm, petal_length_cm, petal_width_cm, target_name FROM xgboost.main.iris), estimator := 'xgb_classifier', target := 'target_name', id := 'sample_id', cv := 5) AS cv
JOIN xgboost.main.iris AS i USING (sample_id)
GROUP BY ALL
ORDER BY actual_species, predicted_species;
Where does an XGBoost regressor miss? 5-fold out-of-fold predictions on diabetes joined back to the patients, with the held-out mean absolute error and mean progression score per BMI quartile (1 = lowest BMI).
SELECT d.bmi_quartile, count(*) AS patients,
round(avg(abs(cv.prediction - d.target)), 1) AS oof_mae,
round(avg(d.target), 1) AS mean_progression
FROM xgboost.main.cross_val_predict((SELECT * FROM xgboost.main.diabetes), estimator := 'xgb_regressor', target := 'target', id := 'sample_id', cv := 5) AS cv
JOIN (SELECT sample_id, target, ntile(4) OVER (ORDER BY bmi, sample_id) AS bmi_quartile FROM xgboost.main.diabetes) AS d USING (sample_id)
GROUP BY d.bmi_quartile
ORDER BY d.bmi_quartile;
breast_cancer
569 tumour samples with 30 cell-nucleus measurements and a benign/malignant label.
Class balance
SELECT target_name, count(*)
FROM xgboost.main.breast_cancer
GROUP BY target_name;
SELECT target_name, count(*) AS n,
round(avg(mean_radius), 2) AS avg_mean_radius
FROM xgboost.main.breast_cancer()
GROUP BY target_name
ORDER BY target_name;
california_housing
20640 census block groups with 8 features and the median house value (regression).
Average value by latitude band
SELECT round(latitude) AS lat, round(avg(target), 2)
FROM xgboost.main.california_housing
GROUP BY lat
ORDER BY lat;
SELECT count(*) AS n_districts, round(avg(target), 3) AS mean_value_100k
FROM xgboost.main.california_housing();
diabetes
442 patients with 10 baseline measurements and a one-year disease-progression score.
Target range
SELECT min(target), max(target), round(avg(target), 1)
FROM xgboost.main.diabetes;
SELECT count(*) AS n, round(avg(target), 1) AS mean_progression
FROM xgboost.main.diabetes();
iris
150 iris flowers with four sepal/petal measurements (cm) and their species.
Row count per species
SELECT target_name, count(*) FROM xgboost.main.iris GROUP BY target_name;
SELECT target_name, count(*) AS n
FROM xgboost.main.iris()
GROUP BY ALL
ORDER BY target_name;
SELECT target_name, avg(petal_length_cm)
FROM xgboost.main.iris()
GROUP BY target_name;
list_models
One row per model persisted in the registry, with its estimator, task, shape, and score.
How many models are saved
SELECT count(*) AS model_count FROM xgboost.main.list_models;
SELECT model_name, estimator, train_score
FROM xgboost.main.list_models()
ORDER BY model_name;
wine
178 wines with 13 chemical measurements and their cultivar of origin.
Average alcohol per cultivar
SELECT target_name, round(avg(alcohol), 2)
FROM xgboost.main.wine
GROUP BY target_name;
SELECT target_name, round(avg(alcohol), 2) AS mean_alcohol
FROM xgboost.main.wine()
GROUP BY target_name
ORDER BY target_name;
drop_model (model_name VARCHAR)
Delete a model from the registry
Delete a stored model and report whether it existed
SELECT model_name, dropped FROM xgboost.main.drop_model('iris_clf');
feature_importance (model_name VARCHAR, importance_type := VARCHAR, model := BLOB)
Per-feature importance (weight/gain/cover) for a stored model, ranked
Top three features by gain for a stored model
SELECT feature, importance, rank
FROM xgboost.main.feature_importance('iris_clf', importance_type => 'gain')
WHERE rank <= 3;
make_classification (n_classes := BIGINT, n_features := BIGINT, n_informative := BIGINT, n_samples := BIGINT, random_state := BIGINT)
Generate a synthetic classification dataset
Class balance of 500 generated rows with 5 features and 3 classes
SELECT target, count(*) AS n
FROM xgboost.main.make_classification(n_samples => 500, n_features => 5, n_classes => 3)
GROUP BY target
ORDER BY target;
make_regression (n_features := BIGINT, n_informative := BIGINT, n_samples := BIGINT, noise := DOUBLE, random_state := BIGINT)
Generate a synthetic regression dataset
Size and target spread of 500 generated rows with 4 features
SELECT count(*) AS n, round(stddev(target), 2) AS target_sd
FROM xgboost.main.make_regression(n_samples => 500, n_features => 4, noise => 5.0);
model_info (model_name VARCHAR)
Describe a single stored model (one row, empty if absent)
Show one stored model's training metadata
SELECT estimator, task, target, n_features, train_score
FROM xgboost.main.model_info('iris_clf');
cross_val_predict (data TABLE, cv := BIGINT, estimator := VARCHAR, id := VARCHAR, params := VARCHAR, target := VARCHAR)
Out-of-fold cross-validated predictions (no model is stored)
Out-of-fold confusion matrix for an XGBoost iris classifier: 5-fold cross_val_predict on the species name, joined back to the iris table by sample_id and counted per (actual, predicted) species pair. Only non-empty cells are returned; the off-diagonal rows are the held-out misclassifications, almost all of them versicolor/virginica mix-ups.
SELECT i.target_name AS actual_species, cv.prediction AS predicted_species,
count(*) AS n_flowers
FROM xgboost.main.cross_val_predict((SELECT sample_id, sepal_length_cm, sepal_width_cm, petal_length_cm, petal_width_cm, target_name FROM xgboost.main.iris), estimator := 'xgb_classifier', target := 'target_name', id := 'sample_id', cv := 5) AS cv
JOIN xgboost.main.iris AS i USING (sample_id)
GROUP BY ALL
ORDER BY actual_species, predicted_species;
Where does an XGBoost regressor miss? 5-fold out-of-fold predictions on diabetes joined back to the patients, with the held-out mean absolute error and mean progression score per BMI quartile (1 = lowest BMI).
SELECT d.bmi_quartile, count(*) AS patients,
round(avg(abs(cv.prediction - d.target)), 1) AS oof_mae,
round(avg(d.target), 1) AS mean_progression
FROM xgboost.main.cross_val_predict((SELECT * FROM xgboost.main.diabetes), estimator := 'xgb_regressor', target := 'target', id := 'sample_id', cv := 5) AS cv
JOIN (SELECT sample_id, target, ntile(4) OVER (ORDER BY bmi, sample_id) AS bmi_quartile FROM xgboost.main.diabetes) AS d USING (sample_id)
GROUP BY d.bmi_quartile
ORDER BY d.bmi_quartile;
5-fold out-of-fold predictions on iris
SELECT sample_id, prediction
FROM xgboost.main.cross_val_predict((SELECT sample_id, sepal_length_cm, sepal_width_cm, petal_length_cm, petal_width_cm, target FROM xgboost.main.iris()), estimator => 'xgb_classifier', target => 'target', id => 'sample_id');
cross_val_score (data TABLE, cv := BIGINT, estimator := VARCHAR, id := VARCHAR, params := VARCHAR, scoring := VARCHAR, target := VARCHAR)
Cross-validated held-out scores, one row per fold (no model is stored)
5-fold accuracy of an XGBoost classifier on iris
SELECT fold, score
FROM xgboost.main.cross_val_score((SELECT sepal_length_cm, sepal_width_cm, petal_length_cm, petal_width_cm, target FROM xgboost.main.iris()), estimator => 'xgb_classifier', target => 'target');
explain (data TABLE, id := VARCHAR, model := BLOB, model_name := VARCHAR)
Per-row SHAP feature contributions, long format (row, [class], feature, shap_value, base_value)
Explain each row's prediction with per-feature contributions
SELECT feature, round(avg(abs(shap_value)), 3) AS mean_abs_shap
FROM xgboost.main.explain((SELECT * FROM xgboost.main.diabetes()), model_name => 'diab_reg', id => 'sample_id')
GROUP BY feature
ORDER BY mean_abs_shap DESC;
fit (data TABLE, estimator := VARCHAR, id := VARCHAR, model_name := VARCHAR, params := VARCHAR, target := VARCHAR)
Fit an XGBoost estimator and store it in the model registry
Train an XGBoost classifier on iris and store it as 'iris_clf'
SELECT model_name, task, n_samples, n_features, train_score
FROM xgboost.main.fit((SELECT sample_id, sepal_length_cm, sepal_width_cm, petal_length_cm, petal_width_cm, target FROM xgboost.main.iris()), model_name => 'iris_clf', estimator => 'xgb_classifier', target => 'target', id => 'sample_id');
fit_xgb_classifier (data TABLE, booster := VARCHAR, colsample_bytree := DOUBLE, gamma := DOUBLE, id := VARCHAR, learning_rate := DOUBLE, max_depth := BIGINT, min_child_weight := DOUBLE, model_name := VARCHAR, n_estimators := BIGINT, objective := VARCHAR, random_state := BIGINT, reg_alpha := DOUBLE, reg_lambda := DOUBLE, subsample := DOUBLE, target := VARCHAR, tree_method := VARCHAR)
Fit a xgb_classifier with typed hyperparameters; returns/stores the model
Train a xgb_classifier with named hyperparameters
SELECT n_samples, n_features, train_score
FROM xgboost.main.fit_xgb_classifier((SELECT * FROM xgboost.main.iris()), target := 'target', id := 'sample_id', n_estimators := 200, max_depth := 6);
fit_xgb_regressor (data TABLE, booster := VARCHAR, colsample_bytree := DOUBLE, gamma := DOUBLE, id := VARCHAR, learning_rate := DOUBLE, max_depth := BIGINT, min_child_weight := DOUBLE, model_name := VARCHAR, n_estimators := BIGINT, objective := VARCHAR, random_state := BIGINT, reg_alpha := DOUBLE, reg_lambda := DOUBLE, subsample := DOUBLE, target := VARCHAR, tree_method := VARCHAR)
Fit a xgb_regressor with typed hyperparameters; returns/stores the model
Train a xgb_regressor with named hyperparameters
SELECT n_samples, n_features, train_score
FROM xgboost.main.fit_xgb_regressor((SELECT * FROM xgboost.main.iris()), target := 'target', id := 'sample_id', n_estimators := 200, max_depth := 6);
fit_xgb_rf_classifier (data TABLE, booster := VARCHAR, colsample_bytree := DOUBLE, gamma := DOUBLE, id := VARCHAR, learning_rate := DOUBLE, max_depth := BIGINT, min_child_weight := DOUBLE, model_name := VARCHAR, n_estimators := BIGINT, objective := VARCHAR, random_state := BIGINT, reg_alpha := DOUBLE, reg_lambda := DOUBLE, subsample := DOUBLE, target := VARCHAR, tree_method := VARCHAR)
Fit a xgb_rf_classifier with typed hyperparameters; returns/stores the model
Train a xgb_rf_classifier with named hyperparameters
SELECT n_samples, n_features, train_score
FROM xgboost.main.fit_xgb_rf_classifier((SELECT * FROM xgboost.main.iris()), target := 'target', id := 'sample_id', n_estimators := 200, max_depth := 6);
fit_xgb_rf_regressor (data TABLE, booster := VARCHAR, colsample_bytree := DOUBLE, gamma := DOUBLE, id := VARCHAR, learning_rate := DOUBLE, max_depth := BIGINT, min_child_weight := DOUBLE, model_name := VARCHAR, n_estimators := BIGINT, objective := VARCHAR, random_state := BIGINT, reg_alpha := DOUBLE, reg_lambda := DOUBLE, subsample := DOUBLE, target := VARCHAR, tree_method := VARCHAR)
Fit a xgb_rf_regressor with typed hyperparameters; returns/stores the model
Train a xgb_rf_regressor with named hyperparameters
SELECT n_samples, n_features, train_score
FROM xgboost.main.fit_xgb_rf_regressor((SELECT * FROM xgboost.main.iris()), target := 'target', id := 'sample_id', n_estimators := 200, max_depth := 6);
grid_search (data TABLE, cv := BIGINT, estimator := UNION of 4 branches, id := VARCHAR, model_name := VARCHAR, scoring := VARCHAR, target := VARCHAR)
Cross-validated grid search over an XGBoost estimator's hyperparameters
union_value(<branch> := …)
-
xgb_classifier n_estimators · max_depth · learning_rate · subsample · colsample_bytree · min_child_weight · gamma · reg_alpha · reg_lambda · objective · booster · tree_method · random_state STRUCT
-
xgb_regressor n_estimators · max_depth · learning_rate · subsample · colsample_bytree · min_child_weight · gamma · reg_alpha · reg_lambda · objective · booster · tree_method · random_state STRUCT
-
xgb_rf_classifier n_estimators · max_depth · learning_rate · subsample · colsample_bytree · min_child_weight · gamma · reg_alpha · reg_lambda · objective · booster · tree_method · random_state STRUCT
-
xgb_rf_regressor n_estimators · max_depth · learning_rate · subsample · colsample_bytree · min_child_weight · gamma · reg_alpha · reg_lambda · objective · booster · tree_method · random_state STRUCT
Grid-search an XGBoost classifier on iris
SELECT params, mean_test_score, rank
FROM xgboost.main.grid_search((SELECT * FROM xgboost.main.iris()), target := 'target', id := 'sample_id', estimator := union_value(xgb_classifier := {'n_estimators': [50, 100], 'max_depth': [3, 5]}))
ORDER BY rank;
partial_dependence (data TABLE, feature := VARCHAR, grid_resolution := BIGINT, model := BLOB, model_name := VARCHAR)
How a stored model's average prediction changes as one feature varies over a grid
Partial dependence of 'iris_clf' on petal length
SELECT class, feature_value, partial_dependence
FROM xgboost.main.partial_dependence((SELECT * FROM xgboost.main.iris()), model_name := 'iris_clf', feature := 'petal_length_cm')
ORDER BY feature_value;
permutation_importance (data TABLE, model := BLOB, model_name := VARCHAR, n_repeats := BIGINT, random_state := BIGINT, scoring := VARCHAR, target := VARCHAR)
Model-agnostic feature importance: the drop in score when each feature is shuffled
Rank iris features by permutation importance for a stored model
SELECT feature, importance_mean, rank
FROM xgboost.main.permutation_importance((SELECT * EXCLUDE (target_name) FROM xgboost.main.iris()), model_name := 'iris_clf', target := 'target')
ORDER BY importance_mean DESC;
predict (data TABLE, id := VARCHAR, model := BLOB, model_name := VARCHAR, output_margin := BOOLEAN, pred_leaf := BOOLEAN, with_proba := BOOLEAN)
Score a table through a stored model, emitting predictions
Predict with the stored 'iris_clf' model
SELECT sample_id, prediction
FROM xgboost.main.predict((SELECT * FROM xgboost.main.iris()), model_name => 'iris_clf', id => 'sample_id');
randomized_search (data TABLE, cv := BIGINT, estimator := UNION of 4 branches, id := VARCHAR, model_name := VARCHAR, n_iter := BIGINT, random_state := BIGINT, scoring := VARCHAR, target := VARCHAR)
Cross-validated randomized search: sample n_iter hyperparameter combinations
union_value(<branch> := …)
-
xgb_classifier n_estimators · max_depth · learning_rate · subsample · colsample_bytree · min_child_weight · gamma · reg_alpha · reg_lambda · objective · booster · tree_method · random_state STRUCT
-
xgb_regressor n_estimators · max_depth · learning_rate · subsample · colsample_bytree · min_child_weight · gamma · reg_alpha · reg_lambda · objective · booster · tree_method · random_state STRUCT
-
xgb_rf_classifier n_estimators · max_depth · learning_rate · subsample · colsample_bytree · min_child_weight · gamma · reg_alpha · reg_lambda · objective · booster · tree_method · random_state STRUCT
-
xgb_rf_regressor n_estimators · max_depth · learning_rate · subsample · colsample_bytree · min_child_weight · gamma · reg_alpha · reg_lambda · objective · booster · tree_method · random_state STRUCT
Randomized-search an XGBoost classifier on iris
SELECT params, mean_test_score, rank
FROM xgboost.main.randomized_search((SELECT * FROM xgboost.main.iris()), target := 'target', id := 'sample_id', n_iter := 4, estimator := union_value(xgb_classifier := {'n_estimators': [50, 100, 200], 'max_depth': [3, 5, 8]}))
ORDER BY rank;
Try these queries
Three-fold cross-validated accuracy of an XGBoost classifier on iris.
SELECT fold, score
FROM xgboost.main.cross_val_score((SELECT * EXCLUDE (target_name) FROM xgboost.main.iris), estimator := 'xgb_classifier', target := 'target', cv := 3);
Uses cross_val_scoreiris
Grid-search an XGBoost classifier on iris over a tiny grid (3-fold).
SELECT params, mean_test_score, rank
FROM xgboost.main.grid_search((SELECT * EXCLUDE (target_name) FROM xgboost.main.iris), target := 'target', cv := 3, estimator := union_value(xgb_classifier := {'n_estimators': [25, 50], 'max_depth': [3]}))
ORDER BY rank;
Uses grid_searchiris
Out-of-fold confusion matrix for an XGBoost iris classifier: 5-fold cross_val_predict on the species name, joined back to the iris table by sample_id and counted per (actual, predicted) species pair. Only non-empty cells are returned; the off-diagonal rows are the held-out misclassifications, almost all of them versicolor/virginica mix-ups.
SELECT i.target_name AS actual_species, cv.prediction AS predicted_species,
count(*) AS n_flowers
FROM xgboost.main.cross_val_predict((SELECT sample_id, sepal_length_cm, sepal_width_cm, petal_length_cm, petal_width_cm, target_name FROM xgboost.main.iris), estimator := 'xgb_classifier', target := 'target_name', id := 'sample_id', cv := 5) AS cv
JOIN xgboost.main.iris AS i USING (sample_id)
GROUP BY ALL
ORDER BY actual_species, predicted_species;
Fit an XGBoost classifier on iris and return the training summary
SELECT estimator, task, n_samples, n_features, train_score
FROM xgboost.main.fit((SELECT * FROM xgboost.main.iris), estimator := 'xgb_classifier', target := 'target', id := 'sample_id')
How many models are saved
SELECT count(*) AS model_count FROM xgboost.main.list_models
Uses list_models
31 more examples in the Catalog, each listed under the table or function it uses.
XGBoost is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
LightGBM
Statistics & ML
Train, tune, evaluate, and explain gradient-boosted classifiers and regressors, with a saved-model registry
scikit-learn
Statistics & ML
scikit-learn — datasets, metrics, transforms and a train/predict model registry
Explain
Statistics & ML
Explain scikit-learn and XGBoost model predictions with per-row SHAP values and global feature importance