This example is based on the Machine Learning for Credit Card Fraud detection and has been forked from a public Snowflake sample. This sample shows how to use LocalStack's Snowflake emulator to perform feature engineering with Snowpark, preparing data for training a Machine Learning model and finally how to deploy and use a trained model in Snowflake using Python UDF — all on your local machine!
This guide assumes you have already cloned the GitHub repository, and have a terminal context within this directory.
- Docker with access to Docker Hub
- Python 3.8 installed locally
localstack
CLI withLOCALSTACK_AUTH_TOKEN
environment variable set- LocalStack Snowflake emulator
-
Check that dependencies exist:
make check
-
To load tables into LocalStack for Snowflake, run:
make load-tables
-
Then, to run feature engineering via LocalStack for Snowflake, run:
make feature-engineering
-
Then, to train the ML model via LocalStack for Snowflake, run:
make train-model
In order to run the sample application against Snowflake Cloud:
-
To run feature engineering against Snowflake Cloud, run:
make sf-feature-engineering
-
To train the ML model against Snowflake Cloud, run:
make sf-train-model
To update a Python dependency, make the required change in requirements.in
,
then run:
make update-deps
To autoformat the directory, run:
make autoformat