Search Shortcut cmd + k | ctrl + k

Machine learning in SQL - 188 scikit-learn-compatible estimators (trees, boosting, linear models, GLMs, SVMs, kNN, naive Bayes, MLPs, clustering, decomposition, preprocessing, text vectorizers, meta-estimators, conformal prediction), fitted per group with an aggregate and stored as BLOBs, plus metrics, cross-validation, tuning and drift detection.

Maintainer(s): sipemu

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 anofox_ml FROM community;
LOAD anofox_ml;

Example

CREATE TABLE train AS
  SELECT (i % 2)::DOUBLE AS y, [i::DOUBLE, (i % 2) * 3.0 + (i % 5) * 0.1] AS x
  FROM range(100) t(i);
-- fit a model in an aggregate; it is an ordinary BLOB value
CREATE TABLE models AS
  SELECT ml_fit_agg('RandomForestClassifier', y, x, '{"n_estimators": 50, "seed": 42}') AS model
  FROM train;
SELECT ml_predict(model, [7.0, 3.2]) AS label,
       ml_predict_proba(model, [7.0, 3.2]) AS proba
FROM models;

About anofox_ml

anofox_ml brings the anofox-ml Rust library into SQL. ml_fit_agg(kind, y, x [, params]) fits any of 188 estimators (see ml_estimators()), one model per GROUP BY group in parallel; the result is a versioned, compressed BLOB you can keep in a table or Parquet file and use with ml_predict, ml_predict_proba, ml_transform, ml_predict_interval and the other model functions in any later query. It also has metric aggregates, cross-validation splitters, grid / random / halving search (ml_tune_agg), permutation importance, recursive feature elimination and drift detection. Documentation: https://github.com/DataZooDE/anofox-ml

Added Functions

function_name function_type description comment examples
ml_accuracy aggregate NULL NULL  
ml_adjusted_rand aggregate NULL NULL  
ml_average_precision aggregate NULL NULL  
ml_balanced_accuracy aggregate NULL NULL  
ml_brier_score aggregate NULL NULL  
ml_cluster_agg aggregate NULL NULL  
ml_cluster_by table_macro NULL NULL  
ml_cluster_centers scalar NULL NULL  
ml_coefficients scalar NULL NULL  
ml_cohen_kappa aggregate NULL NULL  
ml_conformal_margin aggregate NULL NULL  
ml_conformalize_agg aggregate NULL NULL  
ml_covariance scalar NULL NULL  
ml_covariance_agg aggregate NULL NULL  
ml_coverage aggregate NULL NULL  
ml_cross_val_predict_by table_macro NULL NULL  
ml_cv_splits_agg aggregate NULL NULL  
ml_decision_function scalar NULL NULL  
ml_dle_estimate_by table_macro NULL NULL  
ml_domain_classifier_drift_by table_macro NULL NULL  
ml_estimate_bandwidth_agg aggregate NULL NULL  
ml_estimators table NULL NULL  
ml_explained_variance aggregate NULL NULL  
ml_explained_variance_ratio scalar NULL NULL  
ml_f1 aggregate NULL NULL  
ml_fbeta aggregate NULL NULL  
ml_feature_importances scalar NULL NULL  
ml_fit_agg aggregate NULL NULL  
ml_fit_predict_by table_macro NULL NULL  
ml_fit_predict_proba_by table_macro NULL NULL  
ml_fit_transform_agg aggregate NULL NULL  
ml_fit_transform_by table_macro NULL NULL  
ml_fit_with_offset_agg aggregate NULL NULL  
ml_fit_with_validation_agg aggregate NULL NULL  
ml_hashing_vectorize scalar NULL NULL  
ml_hashing_vectorize_sparse scalar NULL NULL  
ml_interval_score aggregate NULL NULL  
ml_inverse_transform scalar NULL NULL  
ml_kneighbors scalar NULL NULL  
ml_log_loss aggregate NULL NULL  
ml_mae aggregate NULL NULL  
ml_mahalanobis macro NULL NULL  
ml_mape aggregate NULL NULL  
ml_matthews_corrcoef aggregate NULL NULL  
ml_max_error aggregate NULL NULL  
ml_mean_pinball_loss aggregate NULL NULL  
ml_mean_set_size macro NULL NULL  
ml_mean_squared_log_error aggregate NULL NULL  
ml_median_absolute_error aggregate NULL NULL  
ml_model_fitted scalar NULL NULL  
ml_model_info scalar NULL NULL  
ml_model_kind scalar NULL NULL  
ml_mse aggregate NULL NULL  
ml_multiple_impute_agg aggregate NULL NULL  
ml_mutual_info_agg aggregate NULL NULL  
ml_normalized_mutual_info aggregate NULL NULL  
ml_outlier_score_agg aggregate NULL NULL  
ml_outlier_score_by table_macro NULL NULL  
ml_partial_fit_agg aggregate NULL NULL  
ml_permutation_importance_agg aggregate NULL NULL  
ml_precision aggregate NULL NULL  
ml_predict scalar NULL NULL  
ml_predict_interval scalar NULL NULL  
ml_predict_label scalar NULL NULL  
ml_predict_log_proba scalar NULL NULL  
ml_predict_proba scalar NULL NULL  
ml_predict_set scalar NULL NULL  
ml_predict_std scalar NULL NULL  
ml_predict_targets scalar NULL NULL  
ml_purged_cv_splits_agg aggregate NULL NULL  
ml_r2 aggregate NULL NULL  
ml_recall aggregate NULL NULL  
ml_rfe_agg aggregate NULL NULL  
ml_rmse aggregate NULL NULL  
ml_roc_auc aggregate NULL NULL  
ml_score_samples scalar NULL NULL  
ml_set_coverage macro NULL NULL  
ml_silhouette aggregate NULL NULL  
ml_spatial_cv_splits_agg aggregate NULL NULL  
ml_spectral_embedding_agg aggregate NULL NULL  
ml_staged_predict scalar NULL NULL  
ml_transform scalar NULL NULL  
ml_transform_y scalar NULL NULL  
ml_tune_agg aggregate NULL NULL  
ml_version scalar NULL NULL  
ml_warm_start_agg aggregate NULL NULL  

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
anofox_ml_max_fit_values Largest training set (rows x features) one fitting aggregate may hold in memory per group; 0 = unlimited UBIGINT GLOBAL [] 100000000
anofox_ml_threads Threads a single fit may use (forests, ensembles, …); 0 = DuckDB's threads, 1 = sequential UBIGINT GLOBAL [] 0
anofox_telemetry_enabled Enable or disable anonymous usage telemetry BOOLEAN GLOBAL [] true
anofox_telemetry_key PostHog API key for telemetry VARCHAR GLOBAL [] phc_t3wwRLtpyEmLHYaZCSszG0MqVr74J6wnCrj9D41zk2t
temp_directory Set the directory to which temporary files are written. VARCHAR GLOBAL [] post.db.tmp
© 2026 DuckDB Foundation, Amsterdam NL
DuckDB Home Code of Conduct Trademark Use Blog