Snowflake - SnowPro Advanced Data Scientist Study Guide

    2: Data Preparation and Feature Engineering

    This chapter converts raw Snowflake tables into model-ready feature sets. It covers cleaning operations executed as SQL or Snowpark pushdown, profiling and statistical EDA using native and approximation functions, the transformer classes in `snowflake.ml.modeling.preprocessing`, the Snowpark Feature Store, and how to render results inside Snowsight, Streamlit in Snowflake, and Snowflake Notebooks for a business audience.

    Learning Objectives

    By the end of this chapter, you will be able to:

    • Prepare and clean data in Snowflake.
    • Perform exploratory data analysis in Snowflake.
    • Perform feature engineering on Snowflake data.
    • Visualize and interpret the data to present a business case.

    Executive Summary

    • Cleaning, profiling, and feature work execute inside the warehouse or on Container Runtime, not on a developer laptop. Snowpark DataFrames and SQL both compile to the same pushdown plan; pandas does not.
    • Approximation functions (HyperLogLog for distinct counts, t-Digest for percentiles, Space-Saving for top-K) trade bounded statistical error for orders-of-magnitude lower compute on profiling workloads.
    • The snowflake.ml.modeling.preprocessing transformer family mirrors the scikit-learn API but executes column-wise pushdown and composes with the Feature Store, which enforces point-in-time correctness.
    • Snowsight dashboards, Streamlit in Snowflake, and Snowflake Notebooks provide three rendering surfaces with different runtime, library, and governance trade-offs.

    Assumptions

    • Examples use a fictional ML_LAB database with a RETAIL schema. The primary tables referenced are CUSTOMER_RAW, TRANSACTIONS, PRODUCTS, CUSTOMER_FEATURES, and CHURN_LABELS.
    • Snowpark Python examples assume snowflake-snowpark-python and snowflake-ml-python are installed in a Python 3.9 or later environment.
    • Code blocks omit credentials and session creation boilerplate after the first appearance, except where the boilerplate itself is the subject.

    Sections in this chapter

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