What you will be able to do
- Automate feature preparation with dynamic tables, and recognise what a dynamic table definition cannot contain
- Choose between a scalar Python UDF, a vectorized UDF, a UDTF and a stored procedure for a given training or transformation step
- Train one model per segment with a partition-aware Python UDTF called with OVER (PARTITION BY ...)
- Size a Snowpark-optimized warehouse for a stored procedure that trains a model, and weigh training outside Snowflake through external functions
- Split data into training and hold-out sets or cross-validation folds, and rebalance skewed classes without leaking into evaluation
- Configure a hyperparameter search with one optimization metric and the right direction to optimize it
Key concept
Matching the training construct to its output shape — A Python UDF returns one value per row, a UDTF returns rows and can keep state for each partition, and a stored procedure runs the whole training job through a session. Picking the right one comes down to how many rows a step has to see before it can produce its result.
1.Automating feature preparation with dynamic tables
A model can be no more current than the table it trains on. A churn feature table kept up to date by hand-written scheduling code is one more thing that can break. A dynamic table replaces that code with a declaration. You write the SELECT that produces the features and a TARGET_LAG that says how stale the result is allowed to get, and Snowflake decides when to refresh. When the table is created, Snowflake parses the query, identifies its base tables and registers the table for refresh. From then on it watches those base tables for changes.
CREATE OR ALTER DYNAMIC TABLE dt_orders
TARGET_LAG = '10 minutes'
WAREHOUSE = transform_wh
REFRESH_MODE = INCREMENTAL
AS
SELECT
order_id,
customer_id,
order_date,
TRIM(UPPER(product_name)) AS product_name,
quantity,
unit_price,
quantity * unit_price AS line_total,
order_status
FROM raw_orders
WHERE order_status != 'returned';You build a multi-step pipeline by chaining tables. Suppose a second dynamic table selects from the first, for example hourly aggregates computed from cleaned events. That second table becomes a downstream node, and Snowflake infers the dependency graph from the queries themselves. Nobody declares dependencies or scripts an execution order. Snowflake picks one consistent snapshot timestamp and refreshes upstream tables before downstream ones. Each table keeps its own target lag. An intermediate table can set TARGET_LAG = DOWNSTREAM, so it refreshes only when a table that depends on it needs fresh data.
The refresh mode sets how much work each refresh does. INCREMENTAL processes only the rows that changed since the last refresh. FULL recomputes the whole result. AUTO lets Snowflake choose when the table is created, based on whether the query supports incremental refresh. Either way, the new results are applied atomically, so a training job that reads the table mid-refresh never sees a partial update. Each refresh runs on the named warehouse, and a shorter lag adds more scheduling work in Cloud Services.
Dynamic tables have limits that determine where training can live. The minimum lag is 60 seconds, and actual lag can exceed the target when a refresh runs longer than expected. The definition has to be expressible as a SQL SELECT. Stored procedures and external functions are not supported in it, and UDTFs are allowed only in lateral joins. Model training therefore does not go inside a dynamic table. The dynamic table prepares the data, and a stored procedure trains on it. Refreshes are automatic by default. Manual control is something you opt into with SCHEDULER = DISABLE, for example when dbt or Airflow drives the refreshes.
Checkpoint 1 of 10· Fill the gap
This feature table must be refreshed automatically, and each refresh should process only the rows that changed in raw_orders since the last refresh instead of recomputing the whole result. Which value completes the definition?
CREATE OR ALTER DYNAMIC TABLE dt_orders
TARGET_LAG = '10 minutes'
WAREHOUSE = transform_wh
REFRESH_MODE = ?
AS
SELECT
order_id,
customer_id,
order_date,
TRIM(UPPER(product_name)) AS product_name,
quantity,
unit_price,
quantity * unit_price AS line_total,
order_status
FROM raw_orders
WHERE order_status != 'returned';INCREMENTAL processes only the rows that changed since the last refresh. FULL recomputes the entire result. AUTO lets Snowflake pick a mode when the table is created, so you aren't the one choosing incremental. DOWNSTREAM is a TARGET_LAG setting for intermediate tables, not a refresh mode.
Source: docs.snowflake.comCheckpoint 2 of 10· Exam question
A data scientist maintains a churn feature pipeline that joins raw event tables and aggregates them hourly. They want Snowflake to keep the feature table fresh without hand-written scheduling code. Select TWO statements that correctly describe using dynamic tables for this pipeline.(Select 2)
Correct answers: B, C — Declare the transformation as a query and set TARGET_LAG, and Snowflake schedules refreshes to keep results within that freshness target.; Build a second dynamic table that selects from the first, and Snowflake refreshes upstream tables before downstream ones in the pipeline.
- A. Dynamic tables refresh automatically and can refresh incrementally when the query allows it. Streams plus tasks are an alternative, not a requirement.
- B. Dynamic tables are declarative: you supply the query and a
TARGET_LAG, and Snowflake decides when to refresh. This removes custom scheduling code. - C. Dynamic tables can be chained into a dependency graph, and Snowflake orders refreshes so downstream tables see consistent upstream data.
- D.
TARGET_LAGis a freshness goal with a minimum of about one minute, not a synchronous guarantee. Dynamic tables are not updated in the same transaction as the sources. - E. A dynamic table is defined by a SELECT query, not by procedural code. Training must be started separately, for example from a task.
Sources1
2.Python UDFs: scalar and vectorized
A Python UDF puts row-level logic inside SQL, such as a log transform or a score from a saved model. It is scalar: Snowflake calls the handler for each row and expects exactly one value back. That value's type must be compatible with the RETURNS clause. Arguments are bound by position, not name, so the first SQL argument arrives as the first Python argument.
Registration happens in CREATE FUNCTION. RUNTIME_VERSION picks the Python version. HANDLER links the SQL name to the Python function, and the two names do not need to match. The code can be written in-line between $$ markers, or uploaded to a stage and referenced in IMPORTS. In-line code can also call modules listed in IMPORTS. If someone deletes or renames a staged file, the UDF stops working. Third-party libraries such as pandas are listed in PACKAGES. Before any role other than the owner can call the function, the owner must grant it, for example with GRANT USAGE ON FUNCTION.
On 80 million rows, the per-row calls themselves are the cost. A vectorized UDF removes it. The handler receives a batch of input rows as a pandas DataFrame and returns a pandas Series or array of results. You mark the handler with the vectorized decorator from the _snowflake module. Queries that call the function stay the same, because the UDF framework does all the batching. The speed-up comes when your code handles whole batches efficiently, as pandas column arithmetic does, and when the libraries you call already expect DataFrames. As with scalar UDFs, there is no guarantee which handler instance sees which batch. A z-score should therefore use a mean and standard deviation passed in as arguments, not ones computed from the batch in hand.
CREATE FUNCTION add_one_to_inputs(x NUMBER(10, 0), y NUMBER(10, 0))
RETURNS NUMBER(10, 0)
LANGUAGE PYTHON
RUNTIME_VERSION = 3.12
PACKAGES = ('pandas')
HANDLER = 'add_one_to_inputs'
AS $$
import pandas| Construct | What one call sees and returns | Fits |
|---|---|---|
| Scalar Python UDF | One row in, one value out | Row-level transforms, scoring a saved model |
| Vectorized Python UDF | A batch of rows as a pandas DataFrame in, a Series or array out | The same transforms over many rows, without per-row overhead |
| Python UDTF | Rows in, tabular rows out, with state kept for each partition | Training one model per segment |
| Python stored procedure | A Snowpark session that runs queries and code | Orchestrating a full training job and saving the model |
Checkpoint 3 of 10· Check yourself
A data scientist wants to fit a separate demand model for each store from inside a SQL query. Each model has to see all of its store's rows before it can return a result. Which Python construct fits this step?
A scalar UDF must return one value for each call and sees only the row passed to it, so it can never fit a model over a whole store. A vectorized UDF gets batches with no guarantee about which rows are in them, so a batch is not a store. A UDTF keeps state for each partition and returns rows, which makes it the right fit for training one model per segment.
“Because a Python UDF must be a scalar function, it must return one value each time that it is invoked.”Source: docs.snowflake.com
3.Training one model per partition with a Python UDTF
A scalar UDF cannot train a model. Each call sees one row and returns one value, while a fit needs every row of a segment. A UDTF covers that gap. It returns tabular results, and its handler is a class whose methods follow the life of a partition:
__init__(optional) runs once for each partition, before any row is processed. It takes onlyselfand cannot produce output rows.process(required) runs once for each input row. It yields tuples whose order matches the columns inRETURNS TABLE.end_partition(optional) runs after the partition's last row and can also yield rows.
CREATE OR REPLACE FUNCTION stock_sale_sum(symbol VARCHAR, quantity NUMBER, price NUMBER(10,2))
RETURNS TABLE (symbol VARCHAR, total NUMBER(10,2))
LANGUAGE PYTHON
RUNTIME_VERSION = 3.12
HANDLER = 'StockSaleSum'
AS $$
class StockSaleSum:
def __init__(self):
self._cost_total = 0
self._symbol = ""
def process(self, symbol, quantity, price):
self._symbol = symbol
cost = quantity * price
self._cost_total += cost
yield (symbol, cost)
def end_partition(self):
yield (self._symbol, self._cost_total)To turn this into training, swap the running total for a buffer. process appends each row's features and label to a list held on self. end_partition fits the model on that buffer and yields one row, for example the store key with a serialized model or its metrics. Call it as TABLE(fn(...) OVER (PARTITION BY store_id)) and every store gets its own handler state and its own model from a single query. Any setup that should run only once, such as importing a heavy library, can go outside the class. The class must keep __init__ and end_partition. Without them the handler is partition-unaware: it runs statelessly, ignores partition boundaries, and has nowhere to buffer rows.
If any handler method throws an exception, processing stops and the calling query fails. One store with malformed data can therefore take down the whole run, so check each partition's inputs before fitting. Memory-heavy fits can run on Snowpark-optimized warehouses, which also suit some UDTF workloads. Snowflake ML also offers ManyModelTraining, which partitions a Snowpark DataFrame by a column and saves each model to a stage under run_id/{partition_id}.
Checkpoint 4 of 10· Match them up
Match each part of a per-store training UDTF handler to the job it should do.
Tap a term, then the definition that fits it.
__init__ only sets up per-partition state and cannot produce rows. The full set of rows exists only after the last row, so fitting and yielding the model belongs in end_partition. process collects rows one at a time, and code outside the class runs once before any partition is handled.
“an __init__ method that executes at the start of partition processing and an end_partition method that Snowflake invokes after processing the partition's last row”Source: docs.snowflake.com
4.Training with Python stored procedures on Snowpark-optimized warehouses
When the goal is one model trained on a large dataset, a Python stored procedure orchestrates the job. Its handler receives a Snowpark session. It runs nested queries to load and transform the data, loads the result into the procedure's memory, and then preprocesses and trains. Finally it uploads the trained model to a stage, where it can back a UDF for inference. A task can run the procedure on a schedule. The model can also come from the snowflake.ml.modeling wrappers for scikit-learn, XGBoost and LightGBM, which fit in the warehouse on a Snowpark DataFrame (snowflake-ml-python through a session).
Memory is usually the limit. Snowpark-optimized warehouses are built for workloads that need a lot of memory and compute, and they let a stored procedure run single-node training directly in Snowflake. The guidelines are specific:
- Set
WAREHOUSE_SIZE = MEDIUMso the warehouse consists of one Snowpark-optimized node. - Run nested queries on a separate warehouse, selected with
session.use_warehouse(), so that warehouse can be sized to the dataset on its own. - Keep other workloads off the warehouse that runs training procedures, and make it multi-cluster if several trainings must run at once.
CREATE OR REPLACE WAREHOUSE snowpark_opt_wh WITH
WAREHOUSE_SIZE = 'MEDIUM'
WAREHOUSE_TYPE = 'SNOWPARK-OPTIMIZED'
MAX_CONCURRENCY_LEVEL = 1;
CREATE OR REPLACE PROCEDURE train()
RETURNS VARIANT
LANGUAGE PYTHON
RUNTIME_VERSION = 3.12
PACKAGES = ('snowflake-snowpark-python', 'scikit-learn', 'joblib')
HANDLER = 'main'PACKAGES pulls libraries from the Anaconda channel. Before anyone can use those packages, someone with the ORGADMIN role must acknowledge the External Offerings Terms once for the account. PyPI packages can come through Artifact Repository instead. Keep in mind that a procedure runs on one node. A procedure that loops over 1,200 stores fits them one after another in its own code, which is why the per-store case belongs to the UDTF.
Checkpoint 5 of 10· Check yourself
An ML engineer is setting up single-node training of one large model in a Python stored procedure on a Snowpark-optimized warehouse. Which part of the plan goes against Snowflake's guidelines?
Snowflake advises keeping other workloads off the Snowpark-optimized warehouse that runs ML training procedures, because they compete with training for memory and compute. A MEDIUM size gives one node, a separate warehouse for nested queries can be sized on its own, and multi-cluster supports concurrent trainings. All three follow the guidelines.
“Don’t mix other workloads on the Snowpark-optimized warehouse that is used to run ML training stored procedures.”Source: docs.snowflake.com
5.Training outside Snowflake through external functions
External functions call a remote service from SQL. Training can use them to send rows to an outside service, for example GPU-backed code that Snowflake does not host. That choice has consequences. The data leaves Snowflake. Each call travels through a cloud HTTP proxy, such as Amazon API Gateway, to the remote endpoint. An administrator must configure the proxy and its security on the cloud platform before the first call can run.
The feature is narrower than it looks. Only functions can be external, not stored procedures, so the orchestration still lives in Snowflake. The remote service is opaque to Snowflake, so the optimizer cannot perform some of its usual optimizations. External functions also cannot appear in a dynamic table definition. Moving a slow transform to an external function adds a network hop for every batch. It does not speed the transform up. Use external functions for training only when the framework or hardware you need is unavailable inside Snowflake.
Checkpoint 6 of 10· Check yourself
Your churn model has to train on GPUs that Snowflake does not host, so you plan to send features to a remote training service through an external function. You also want the feature table refreshed automatically. Which design works?
Dynamic table definitions cannot contain external functions or stored procedures, so neither a refresh mode nor a lag setting can bring training into the table. The dynamic table only prepares the features. The call to the remote service runs in a separate step that Snowflake orchestrates, for example a stored procedure scheduled by a task.
“Need stored procedures or external functions in the definition.”Source: docs.snowflake.com
Checkpoint 7 of 10· Exam question
A scalar Python UDF applies a log transform and z-score to 80 million rows and runs slowly because Snowflake invokes it once for every row. Which change most directly reduces this per-row overhead?
Correct answer: A — Rewrite it as a vectorized UDF with the @vectorized decorator so the handler gets row batches as a pandas DataFrame.
- A. Vectorized Python UDFs receive batches of rows as pandas objects, so vectorized pandas operations replace a Python call per row.
- B. Stored procedures do not change how a UDF is invoked inside a query. Ownership mode controls privileges, not per-row execution cost.
- C. External functions send rows in batches over HTTP to a remote service, which adds network latency. They are not a way to avoid per-row calls.
- D. A UDTF's
processmethod is still called per input row, and an empty one would return nothing. It does not remove per-row call overhead.
Checkpoint 8 of 10· Exam question
A retailer has one table holding sales history for 1,200 stores and wants a separate demand model per store, trained in parallel inside Snowflake, with each fitted model serialized for later use. Which approach fits best?
Correct answer: C — Write a Python UDTF that buffers rows in process and fits in end_partition, called with OVER (PARTITION BY store_id).
- A. This works but is sequential, with no parallelism across partitions. A partitioned UDTF spreads the per-store fits across the warehouse.
- B. External functions return one value per input row and are scalar. They cannot return a fitted model per group, and they move data out.
- C. A UDTF called with a partition clause receives each store's rows together, and
end_partitionruns once per store. Different partitions run in parallel. - D. A scalar UDF sees one row at a time and cannot collect a store's rows. Fitting a model on one row is not meaningful.
Sources8
6.Hold-out splits, cross-validation and class rebalancing
A model has to be scored on rows it never trained on. A train/validation hold-out splits the data once. In the training procedure below, test_size=0.2 keeps 20% of rows aside, and the model is fit on the other 80%. It costs one fit. With hundreds of millions of labelled rows, even a small hold-out fraction is a large, stable sample, so a hold-out split is enough when comparing many candidates. Fix random_state so the same rows land in the same split on every run, which keeps candidates comparable.
def main(session):
# Load features
df = session.table('MARKETING_BUDGETS_FEATURES').to_pandas()
X = df.drop('REVENUE', axis = 1)
y = df['REVENUE']
# Split dataset into training and test
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state = 42)k-fold cross-validation rotates the hold-out role. The data is cut into k folds, k models are trained, and each model is scored on the one fold it did not see. Averaging the k scores is a steadier estimate than a single split, at k times the training cost. That trade pays off on small datasets and is rarely worth it on huge ones. Snowflake's built-in FORECAST and ANOMALY_DETECTION classes also train additional models for cross-validation through evaluation_config. That config uses scikit-learn's TimeSeriesSplit, so for time-ordered data each fold trains on the past and tests on what follows.
The same training procedure imports GridSearchCV next to train_test_split, in a single line at the top of its handler code:
from sklearn.model_selection import train_test_split, GridSearchCVGridSearchCV tries every hyperparameter combination in the grid it is given and cross-validates each one. The procedure wraps its pipeline with cv=10, so each candidate is scored over ten folds.
Order matters more than method. Split first, then fit everything else on the training rows only. That includes the scaler and encoders, fitted as steps of the training Pipeline (Snowflake ML preprocessing (scaling, normalization, encoding) in a Pipeline). A scaler fitted on every row has already seen the validation data.
Class rebalancing follows the same rule. When fraud is 1 row in 200, a model can score well by never predicting fraud. Down-sampling removes majority-class rows, and up-sampling duplicates or synthesises minority-class rows. Apply either one after the split, to the training split only. If you oversample the full table before splitting, copies of the same fraud row end up on both sides. Validation then scores the model on rows it has effectively memorised: validation AUC looks excellent and production AUC collapses. Validation and hold-out sets keep the real class ratio, because that ratio is what production will send.
Checkpoint 9 of 10· Fill the gap
The training table has hundreds of millions of labelled rows, and many candidate models need to be compared at the cost of one fit each, with 20% of rows set aside for scoring. Which function completes the split in this procedure?
def main(session):
# Load features
df = session.table('MARKETING_BUDGETS_FEATURES').to_pandas()
X = df.drop('REVENUE', axis = 1)
y = df['REVENUE']
# Split dataset into training and test
X_train, X_test, y_train, y_test = ? (X, y, test_size=0.2, random_state = 42)train_test_split makes a single train/validation hold-out split. Here it keeps 20% of the rows aside, so each candidate costs one fit, and on a very large dataset that split is a big, stable sample. GridSearchCV, KFold and TimeSeriesSplit all cross-validate, which trains k models per candidate and multiplies the training cost.
Source: docs.snowflake.com7.Hyperparameter tuning against one optimization metric
Hyperparameters such as tree depth or learning rate are chosen before training. Tuning searches over them, and each trial still learns its own learned model parameters. The search strategy decides how many trials you pay for.
| Algorithm | How it picks the next trial | When it wins |
|---|---|---|
| GridSearch | Evaluates every combination in a grid you define. Three parameters with two values each give 8 trials | Small, discrete spaces where you need exhaustive coverage |
| RandomSearch | Samples the space at random | Large or mixed continuous and discrete spaces |
| BayesOpt | Uses a probabilistic model built from earlier trials to choose the next configuration | Expensive trials, where each one should be informed by the last |
The HPO API runs from a Snowflake Notebook on the Container Runtime. It spreads trials across the CPU or GPU cores of a node in the compute pool and can scale out to several nodes. Three pieces define a run: a training function, a search space and a TunerConfig. The search space uses sampling functions. uniform covers ranges like dropout, loguniform covers values spanning orders of magnitude such as learning rates, randint covers integers, and choice covers categories. A dataset_map pairs a train and a test DataConnector, so each trial is scored on held-out data. Inside the training function, tuner_context.report(metrics=..., model=...) reports each trial's result. Tuner(train_func, search_space, tuner_config).run(dataset_map=...) returns results, a DataFrame with one row per trial, plus best_result and best_model. Experiment tracking logs each of those trials as a run, so the winning configuration is backed by evidence.
from snowflake.ml.modeling import tune
tuner_config = tune.TunerConfig(
metric="accuracy",
mode="max",
search_alg=BayesOpt(
utility_kwargs={"kind": "ucb", "kappa": 2.5, "xi": 0.0}
),
num_trials=5,
max_concurrent_trials=1,
)The tuner optimizes exactly one metric, so choosing it is a modelling decision, not a default. mode must match the metric's direction. Log loss and RMSE are errors and use "min". Accuracy and AUC are scores and use "max". Log loss is a classification loss that Snowflake's classification reports for the model as a whole, and the objective is to minimize it. AUC is also a classification metric, reported alongside precision, recall and F1. A loss paired with "max" makes the search pick the worst configuration. Log loss rewards well-calibrated probabilities, which is why LightGBM training parameters often set 'metric': 'binary_logloss' for binary classifiers. When errors cost different amounts, for example a missed fraud costing far more than a false alarm, tune on recall, precision or F1 rather than accuracy (Confusion matrix, accuracy, precision and recall). Accuracy stays high on a 1-in-200 problem even when the model catches nothing.
Checkpoint 10 of 10· Fill the gap
With mode fixed at "max", the tuner keeps whichever trial reported the highest value of the named metric. Which metric name, reported by each trial through tuner_context.report, makes this config select the best model rather than the worst?
from snowflake.ml.modeling import tune
tuner_config = tune.TunerConfig(
metric=" ? ",
mode="max",
search_alg=BayesOpt(
utility_kwargs={"kind": "ucb", "kappa": 2.5, "xi": 0.0}
),
num_trials=5,
max_concurrent_trials=1,
)Accuracy is a score, where higher is better, so it pairs with mode="max". Log loss, binary_logloss and RMSE are errors that need mode="min". The tuner does not work out the direction from the metric name, so pairing any of them with "max" makes the search pick the worst configuration.
Source: docs.snowflake.comSources
(13)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“You specify a SELECT query and a target lag, and Snowflake tracks dependencies and refreshes the data on schedule.”
↩︎ Automating feature preparation with dynamic tables“Snowflake refreshes tables in dependency order so that downstream tables always see a consistent view of their upstream inputs.”
↩︎ Automating feature preparation with dynamic tables“actual lag can exceed the target when refreshes take longer than expected”
↩︎ Automating feature preparation with dynamic tables“Need stored procedures or external functions in the definition.”
↩︎ Exam trap 1“INCREMENTAL processes only the rows that changed since the last refresh.”
↩︎ Exam trap 2“Require data fresher than 60 seconds (the minimum target lag) or strictly guaranteed refresh timing.”
↩︎ Prediction“Need stored procedures or external functions in the definition.”
↩︎ Checkpoint - 2.
“The HANDLER clause in the CREATE FUNCTION statement associates the UDF name with the Python function.”
↩︎ Python UDFs: scalar and vectorized“An in-line Python UDF can call code in modules that are included in the IMPORTS clause.”
↩︎ Python UDFs: scalar and vectorized“If you delete or rename the file, you can no longer call the UDF.”
↩︎ Python UDFs: scalar and vectorized“Because a Python UDF must be a scalar function, it must return one value each time that it is invoked.”
↩︎ Exam trap 3“Because a Python UDF must be a scalar function, it must return one value each time that it is invoked.”
↩︎ Checkpoint - 3.
“use the vectorized decorator to specify that your handler expects to receive a Pandas DataFrame”
↩︎ Python UDFs: scalar and vectorized“All batching is handled by the UDF framework rather than your own code.”
↩︎ Python UDFs: scalar and vectorized“The potential for better performance if your Python code operates efficiently on batches of rows.”
↩︎ Python UDFs: scalar and vectorized - 4.
“an end_partition method that Snowflake invokes after processing the partition’s last row”
↩︎ Training one model per partition with a Python UDTF“In partition-unaware processing, the handler executes statelessly, ignoring partition boundaries.”
↩︎ Training one model per partition with a Python UDTF“throwing an exception from any method in the handler class causes processing to stop”
↩︎ Training one model per partition with a Python UDTF“A UDTF is a user-defined function (UDF) that returns tabular results.”
↩︎ Key concept“Cannot produce output rows. Use your process method implementation for that.”
↩︎ Exam trap 4“Is invoked once for each partition, and before the process method is invoked.”
↩︎ Prediction“an __init__ method that executes at the start of partition processing and an end_partition method that Snowflake invokes after processing the partition's last row”
↩︎ Checkpoint - 5.https://docs.snowflake.com/en/developer-guide/snowpark/python/python-snowpark-training-mlOfficial docs
“These optimized warehouses can also benefit some UDF and UDTF scenarios.”
↩︎ Training one model per partition with a Python UDTF“Snowpark-optimized warehouses make it possible to use Snowpark stored procedures to run single-node ML training workloads directly in Snowflake.”
↩︎ Training with Python stored procedures on Snowpark-optimized warehouses“The trained model can be uploaded into a Snowflake stage, and can be used to create UDFs to perform inference.”
↩︎ Training with Python stored procedures on Snowpark-optimized warehouses“Use the session.use_warehouse() API to select the warehouse for the query inside the stored procedure.”
↩︎ Training with Python stored procedures on Snowpark-optimized warehouses“train_test_split(X, y, test_size=0.2, random_state = 42)”
↩︎ Hold-out splits, cross-validation and class rebalancing“from sklearn.model_selection import train_test_split, GridSearchCV”
↩︎ Hold-out splits, cross-validation and class rebalancing“model = GridSearchCV(pipeline, param_grid={}, n_jobs=-1, cv=10)”
↩︎ Hold-out splits, cross-validation and class rebalancing“Don’t mix other workloads on the Snowpark-optimized warehouse that is used to run ML training stored procedures.”
↩︎ Checkpoint - 6.https://docs.snowflake.com/en/developer-guide/snowflake-ml/train-models-across-partitionsOfficial docs
“Each model is trained on data specific to its partition.”
↩︎ Training one model per partition with a Python UDTF - 7.https://docs.snowflake.com/en/developer-guide/stored-procedure/python/procedure-python-overviewOfficial docs
“To schedule the execution of these stored procedures, you use tasks.”
↩︎ Training with Python stored procedures on Snowpark-optimized warehouses“You only need to accept the External Offerings Terms once for your Snowflake account.”
↩︎ Training with Python stored procedures on Snowpark-optimized warehouses - 8.
“Snowflake calls remote services indirectly through a cloud HTTP proxy service (such as the Amazon API Gateway)”
↩︎ Training outside Snowflake through external functions“Only functions, not stored procedures, can be written using the external functions feature.”
↩︎ Training outside Snowflake through external functions“Before an external function can be called the first time, an administrator must do some configuration work.”
↩︎ Training outside Snowflake through external functions“Because the remote service is opaque to Snowflake”
↩︎ Training outside Snowflake through external functions - 9.https://docs.snowflake.com/en/sql-reference/classes/anomaly-detection/commands/create-anomaly-detectionOfficial docs
“If TRUE, additional models are trained for cross-validation using the parameters in the evaluation_config.”
↩︎ Hold-out splits, cross-validation and class rebalancing - 10.
“The evaluation_config object contains key-value pairs that configure cross-validation.”
↩︎ Hold-out splits, cross-validation and class rebalancing - 11.
“The HPO API evaluates every possible combination of hyperparameters.”
↩︎ Hyperparameter tuning against one optimization metric“Uses a probabilistic model to determine the next set of hyperparameters to evaluate.”
↩︎ Hyperparameter tuning against one optimization metric“The dataset_map object is a dictionary that pairs the training or test dataset with its corresponding Snowflake DataConnector object.”
↩︎ Hyperparameter tuning against one optimization metric“best_result: A DataFrame row summarizing the trial with the best performance.”
↩︎ Hyperparameter tuning against one optimization metric“Metric The performance metric, such as accuracy or loss that you’re optimizing.”
↩︎ Hyperparameter tuning against one optimization metric“Determines whether the objective is to maximize or minimize the metric ("max" or "min").”
↩︎ Exam trap 5 - 12.https://docs.snowflake.com/en/developer-guide/snowflake-ml/model-registry/built-in-models/lightgbmOfficial docs
“'metric': 'binary_logloss'”
↩︎ Hyperparameter tuning against one optimization metric - 13.
“Logistic Loss (LogLoss) is calculated for the model as a whole. The objective of prediction is to minimize the loss function.”
↩︎ Hyperparameter tuning against one optimization metric“Currently, macro and weighted averaging is used for the metrics Precision, Recall, F1, AUC.”
↩︎ Hyperparameter tuning against one optimization metric