About this lab
Northpeak Supply, a wholesale distributor, sees a quarter of its invoices paid after the due date and finds out only when the money does not arrive. The collections team wants every new invoice scored on the day it is issued, so they can call the riskiest customers before the due date.
In this lab you develop that model entirely inside Snowflake. You generate 600 customers and 9,000 invoices in SQL with fixed seeds, explore what drives late payment, and catch the column that would leak the answer. In a Snowflake Notebook you engineer 21 features with the Snowpark DataFrame API, including window features over a customer's earlier invoices and a point-in-time payment track record that only uses invoices already paid, then split by time and train an XGBoost classifier.
You evaluate the model on later invoices it never saw, against an always-on-time baseline and the team's own late-before rule, using ROC AUC, precision, recall, F1 and a call-list view of the business impact. Finally you register it as LATE_PAYMENT_MODEL version V1 in the Snowflake Model Registry with its metrics and input signature, and prove the registered model reproduces the notebook's predictions.
Lab details
- Level: Intermediate
- Cloud: Snowflake
- Domain: Data Science & MLOps
- Duration: 75 minutes
What you will learn
- Generate a reproducible, seeded training dataset in SQL with a real signal and real noise
- Spot leakage and engineer leak-free features with Snowpark, including window functions and a point-in-time join
- Split data by time and train an XGBoost classifier inside a Snowflake Notebook
- Evaluate on held-out data with ROC AUC, precision, recall and F1 against naive and rule-based baselines
- Register the model as V1 in the Snowflake Model Registry with metrics, a comment and a sample input
- Prove the registered model reproduces the notebook's predictions
Concepts covered
- Feature engineering
- Data leakage
- Point-in-time correctness
- Time-based train/test split
- Binary classification
- Model evaluation and baselines
- Model Registry
Technologies used
- Snowflake Notebooks
- Snowpark Python
- XGBoost
- scikit-learn
- Snowflake Model Registry
- Snowflake SQL
Prerequisites
- Basic SQL (SELECT, JOIN, GROUP BY)
- Basic Python and pandas
- A Snowflake trial account with the ACCOUNTADMIN role
Topics
- Snowflake
- Snowpark
- Snowpark ML
- Machine Learning
- XGBoost
- Model Registry
- Snowflake Notebooks
- Python
- Classification
- Feature Engineering