Snowflake - SnowPro Advanced Data Scientist Study Guide

    3: Model Development

    This chapter walks through how data science models are built on Snowflake compute without exporting data. It covers the connection surfaces that bring Python and Spark workloads into the account, the Cortex LLM and embedding functions that bring generative AI into SQL, and the training, validation, and interpretation patterns that produce a registered model version ready for deployment.

    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-python 1.6.2 or newer and a representative background sample.

    Assumptions

    • All code uses a fictional production account with database CRESTWOOD_ML, schema PROD_DS, and warehouse DS_WH (Standard) plus DS_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 the CORTEX_MODELS_ALLOWLIST account parameter.
    • All preview-stage features are labeled inline. Where a feature has multiple delivery surfaces (SQL, Python, REST), each is described separately.

    Sections in this chapter

    1. Free
    2. Free with account
    3. Free with account
    4. Free with account
    5. Free with account
    6. Free with account