Snowflake ML Functions
Use Snowflake's built-in ML functions for time-series forecasting, anomaly detection, classification, and contribution analysis — all from SQL with no ML expertise required.
Overview
Snowflake ML Functions are SQL-based machine learning capabilities that let analysts and data engineers build ML models without writing Python code or managing infrastructure. They handle data preprocessing, model training, and prediction automatically.
Available ML Functions
Forecasting
Predict future values for time-series data with automatic seasonality detection and multi-series support.
Anomaly Detection
Identify unusual data points in time-series data using unsupervised or supervised approaches.
Classification
Build binary and multi-class classification models for categorical predictions from tabular data.
Top Insights
Automatically find the dimensions that most contribute to changes in a metric over time.
Forecasting Example
-- Create a forecasting model
CREATE OR REPLACE SNOWFLAKE.ML.FORECAST sales_forecast(
INPUT_DATA => SYSTEM$REFERENCE('TABLE', 'daily_sales'),
TIMESTAMP_COLNAME => 'sale_date',
TARGET_COLNAME => 'revenue',
SERIES_COLNAME => 'region' -- multi-series forecasting
);
-- Generate predictions for the next 30 days
CALL sales_forecast!FORECAST(
FORECASTING_PERIODS => 30,
CONFIG_OBJECT => {'prediction_interval': 0.95}
);
Anomaly Detection Example
-- Create an anomaly detection model
CREATE OR REPLACE SNOWFLAKE.ML.ANOMALY_DETECTION anomaly_model(
INPUT_DATA => SYSTEM$REFERENCE('TABLE', 'server_metrics'),
TIMESTAMP_COLNAME => 'metric_time',
TARGET_COLNAME => 'cpu_usage',
LABEL_COLNAME => '' -- unsupervised (no labels)
);
-- Detect anomalies in new data
CALL anomaly_model!DETECT_ANOMALIES(
INPUT_DATA => SYSTEM$REFERENCE('TABLE', 'latest_metrics'),
TIMESTAMP_COLNAME => 'metric_time',
TARGET_COLNAME => 'cpu_usage'
);
Classification
Build classification models for categorical outcomes:
- Binary classification: Predict yes/no outcomes like churn prediction or fraud detection
- Multi-class: Predict categories such as customer segments or product types
- Automatic feature handling: Snowflake handles missing values, encoding, and feature selection
- Evaluation metrics: Built-in accuracy, precision, recall, and AUC reporting
Lilly Tech Systems