Learning Objectives
By the end of this chapter, you will be able to:
- Connect data science tools directly to data in Snowflake.
- Leverage GenAI and LLM models in Snowflake.
- Train a data science model.
- Validate a data science model.
- Interpret a model.
Executive Summary
- Connection choice is a function of payload, not preference: the Python connector returns tabular results to the client, Snowpark pushes DataFrame logic down as SQL, the Snowpark ML modeling API wraps scikit-learn and XGBoost estimators into pushdown-aware classes, and the Spark connector exists only as a compatibility shim for existing Spark code.
- Cortex functions split into two families that exam scenarios constantly conflate: task-specific managed functions (SENTIMENT, SUMMARIZE, TRANSLATE, EXTRACT_ANSWER, CLASSIFY_TEXT) which expect specific inputs and outputs, and the open-ended COMPLETE function which takes a model identifier and a prompt and returns whatever the model generates.
- Training surface selection follows a tight hierarchy: Snowpark ML modeling API for sklearn-family algorithms on warehouse compute, Container Runtime for GPU and distributed training, Python stored procedures for custom training scripts that need to call arbitrary libraries, Python UDTFs for partitioned training where one model is fit per group, and external functions only when a third-party SaaS must perform the training.
- Validation and interpretation in Snowflake collapse to two registry-attached capabilities: the Model Registry stores metrics on the model version, and the explainability function on a logged model version computes Shapley values without needing a separate SHAP installation, provided the model was logged with
snowflake-ml-python1.6.2 or newer and a representative background sample.
Assumptions
- All code uses a fictional production account with database
CRESTWOOD_ML, schemaPROD_DS, and warehouseDS_WH(Standard) plusDS_WH_XL(Snowpark-optimized) for memory-intensive operations. Cortex region availability and model allowlist policies follow the account's default configuration. - Cortex LLM model identifiers (such as
mistral-large2,llama3.1-70b,claude-sonnet-4-6) are referenced as documented model names; the actual model available in any region depends on theCORTEX_MODELS_ALLOWLISTaccount parameter. - All preview-stage features are labeled inline. Where a feature has multiple delivery surfaces (SQL, Python, REST), each is described separately.
