Snowflake ML Overview
What Is Snowflake ML?
Snowflake ML is a suite of built-in machine learning functions that run natively inside Snowflake. Models are trained and predictions are generated using SQL — no external tools, Python environments, or data movement required. All computation happens within the Snowflake compute layer, governed by the same access controls as the rest of your data.
Supported Algorithms
Snowflake ML provides purpose-built functions for common ML tasks:
| Function | Use Case | SQL Object |
|---|---|---|
| Classification | Predict categorical outcomes (yes/no, categories) | SNOWFLAKE.ML.CLASSIFICATION |
| Regression | Predict continuous numeric values | SNOWFLAKE.ML.REGRESSION |
| Forecasting | Predict future values from time series data | SNOWFLAKE.ML.FORECAST |
| Anomaly Detection | Identify unusual data points | SNOWFLAKE.ML.ANOMALY_DETECTION |
| Contribution Explorer | Find dimensions driving metric changes | SNOWFLAKE.ML.CONTRIBUTION_EXPLORER |
| Top Insights | Automated root cause analysis | SNOWFLAKE.ML.TOP_INSIGHTS |
Architecture Overview
Snowflake ML models are first-class schema-level objects. The lifecycle follows three stages:
- Create — Train a model by referencing a table or query as input data.
- Predict — Call the model to generate predictions on new data.
- Manage — Drop, replace, or grant access to models like any other Snowflake object.
-- Step 1: Train a model
CREATE OR REPLACE SNOWFLAKE.ML.CLASSIFICATION my_model(
INPUT_DATA => SYSTEM$REFERENCE('TABLE', 'TRAINING_DATA'),
TARGET_COLNAME => 'LABEL'
);
-- Step 2: Generate predictions
SELECT my_model!PREDICT(INPUT_DATA => SYSTEM$REFERENCE('TABLE', 'NEW_DATA'));
-- Step 3: Manage the model
DROP SNOWFLAKE.ML.CLASSIFICATION my_model;
When to Use Built-In ML
Built-in ML is the right choice when:
- The problem maps to a supported algorithm (classification, regression, forecasting, anomaly detection).
- The team works primarily in SQL and does not maintain a Python ML stack.
- Speed to production matters more than fine-tuning hyperparameters.
- Data cannot leave Snowflake due to governance or compliance constraints.
Advantages of Built-In ML
| Advantage | Detail |
|---|---|
| SQL-first | Train and predict with standard SQL statements |
| No infrastructure | No Spark clusters, notebooks, or package management |
| Auto-tuning | Hyperparameters are selected automatically |
| Governed | Models respect RBAC, row access policies, and masking policies |
| Scalable | Training runs on Snowflake warehouses and scales with warehouse size |
| No data movement | Data stays in Snowflake throughout the entire workflow |
Built-In ML vs Other Approaches
| Criteria | Built-in ML | Snowpark ML | External (SageMaker, Vertex AI) |
|---|---|---|---|
| Language | SQL | Python | Python / various |
| Setup complexity | None | Moderate | High |
| Algorithm flexibility | Fixed set | Full scikit-learn, XGBoost, etc. | Unlimited |
| Data movement | None | None (runs in Snowflake) | Data must be exported |
| Hyperparameter control | Automatic | Full control | Full control |
| Governance | Native RBAC | Native RBAC | External IAM + Snowflake |
Prerequisites
Before using Snowflake ML functions, verify:
-- Check that your role has the required privileges
GRANT CREATE SNOWFLAKE.ML.CLASSIFICATION ON SCHEMA my_db.my_schema TO ROLE analyst;
GRANT CREATE SNOWFLAKE.ML.FORECAST ON SCHEMA my_db.my_schema TO ROLE analyst;
GRANT CREATE SNOWFLAKE.ML.ANOMALY_DETECTION ON SCHEMA my_db.my_schema TO ROLE analyst;
-- Confirm the warehouse is active
ALTER WAREHOUSE ml_wh RESUME IF SUSPENDED;
USE WAREHOUSE ml_wh;
Key Concepts
- SYSTEM$REFERENCE — A secure reference to a table or view passed as input. This ensures the model respects access control on the source data.
- Model object — A schema-level object stored in the Snowflake metadata layer. It persists until explicitly dropped.
- !PREDICT — A method invoked on the model object to generate predictions against new data.
Best Practices
- Start with built-in ML before investing in custom model pipelines. Many business problems are well served by classification or forecasting.
- Use dedicated warehouses for training to avoid contention with query workloads.
- Version your training data using clones or time travel so results are reproducible.
- Monitor model freshness — retrain periodically as source data evolves.
- Grant minimal privileges — only the roles that need predictions should have USAGE on the model.
Next Steps
The following lessons cover each built-in ML function in detail: