CertSafari
    Snowflake SnowPro Advanced: Data Analyst (DAA-C01)· Lessons

    Domain 3 · Lesson 15/19

    Finding Causes with Anomaly Detection and Top Insights

    Perform diagnostic analyses.

    13 min read
    8% of exam
    3 sources
    Published 5 Oct 2026
    Docs as of 4 Oct 2026

    What you will be able to do

    • Explain how Snowflake Anomaly Detection flags outliers against a forecast and prediction interval
    • Train an anomaly detection model and run DETECT_ANOMALIES on later data
    • Set up Top Insights with a Boolean control/test label to find the segments driving a metric change
    • Interpret Top Insights output columns, including negative contributions

    1.Anomaly Detection: finding when something went wrong

    Before you can explain an anomaly, you have to find it reliably. Snowflake's Anomaly Detection ML function trains a model on time-series data and flags outliers, meaning points outside the expected range. According to the documentation, it is useful for pinpointing the origin of problems or deviations in processes when there is no obvious cause. Two of its examples are working out when a logging pipeline started failing and finding the days when compute costs were higher than expected.

    The model works by comparing against a forecast. It forecasts the period you are checking and then compares the actual values with that forecast. Under the hood, a gradient boosting machine uses differencing for non-stationary trends, autoregressive lags, rolling averages and calendar variables (such as day of week) derived from the timestamp. You cannot choose or tune the algorithm. Trend and seasonality are inferred from the data. The input needs a timestamp column and a target column. It can be multi-series, where one model checks each series separately based on an identifier such as the store. It can also include exogenous variables, but if you train with them, you must supply their values for the timestamps you later check.

    The prediction interval is the range expected to contain a given share of the data. The default is 0.99, and the documentation suggests you may want a value very close to 1.0, such as 0.9999. The most important limit for diagnosis is about which data gets checked. The model only finds anomalies in the test data, never in the training data, and every test timestamp must come after the training timestamps. A spike in the training set therefore distorts what the model treats as normal. You can avoid this by training on a typical period with no outliers or by labelling known outliers in a Boolean column, which is called supervised training. Trained models are immutable. To include new data, you drop the model and train a new one.

    How much history the model needs per time series
    Rows per seriesResult
    At least 2Model trains, but 2 to 11 observations give a naive result where every predicted value equals the last observed target value
    At least 12Non-naive results from the main algorithm
    At least 60Non-linear results

    Checkpoint 1 of 6· Check yourself

    Last November's training data includes a known one-day outage that crashed sales. You want the model to judge this November fairly. What does the documentation recommend?

    Sources1

    2.Training a model and reading its verdict

    The workflow has two steps. First you create the model object with CREATE SNOWFLAKE.ML.ANOMALY_DETECTION, which trains it on the input you pass. Then you call the model's DETECT_ANOMALIES method on later data. The function runs with limited privileges, so you pass data as references: the TABLE keyword, SYSTEM$REFERENCE, or SYSTEM$QUERY_REFERENCE for an inline query. Pass an empty string for LABEL_COLNAME when training is unsupervised.

    Training an unsupervised model on a sensor view (30 rows of synthetic readings)sql
    CREATE OR REPLACE SNOWFLAKE.ML.ANOMALY_DETECTION sensor_model(
      INPUT_DATA => SYSTEM$REFERENCE('VIEW', 'sensor_data_view'),
      TIMESTAMP_COLNAME => 'timestamp',
      TARGET_COLNAME => 'temperature',
      LABEL_COLNAME => '');

    Checkpoint 2 of 6· Fill the gap

    Which method completes this call so that the trained model checks the three new readings for outliers?

    CALL sensor_model! ? (
      INPUT_DATA => SYSTEM$REFERENCE('TABLE', 'sensor_data_device3'),
      TIMESTAMP_COLNAME => 'timestamp',
      TARGET_COLNAME => 'temperature'
    );

    For each test row, the output gives the observed value Y, the FORECAST, a LOWER_BOUND and UPPER_BOUND, IS_ANOMALY, a PERCENTILE and a DISTANCE. In the sensor example, the reading at 00:00:30 was 36.0422 against an upper bound of 36.036839539, so IS_ANOMALY is True. The next two readings were nearly as high but stayed inside their bounds. Keep the test data close in time to the training data. If you have per-second timestamps, don't test on data millions of seconds later. To keep the verdicts for further analysis, call the method inside FROM with the TABLE keyword (and no CALL) and save the result with CREATE TABLE … AS SELECT.

    Persisting anomaly results to a table for follow-up analysissql
    CREATE TABLE my_anomalies AS
      SELECT * FROM TABLE(basic_model!DETECT_ANOMALIES(
        INPUT_DATA => TABLE(view_with_data_to_analyze),
        TIMESTAMP_COLNAME =>'date',
        TARGET_COLNAME => 'sales'
      ));

    Diagnose the model as well as the data. In the documentation's jacket-sales example, the results looked inaccurate for two reasons: the training set was tiny, and one day with 30 jackets sold pulled the predictions upward and widened the interval. The fix is more training data or labelled training data.

    Checkpoint 3 of 6· Put it in order

    Put the steps of detecting anomalies for one store's jacket sales in order

    1. 1.Create a view returning the newer data to analyse
    2. 2.Create a view returning the historical date and sales for training
    3. 3.Call the model's DETECT_ANOMALIES method on that view
    4. 4.Run CREATE SNOWFLAKE.ML.ANOMALY_DETECTION, passing the training view as a reference

    Sources12

    3.Top Insights: which segments explain the change

    Anomaly detection tells you when. Top Insights tells you who and where. It is Snowflake's ML function for key driver analysis. A decision tree splits the data into segments that behave differently with respect to a metric and then compares a control group (the baseline) with a test group (the points of interest). This covers two diagnostic questions. Time-series analysis asks what drove this month's change compared with before. Vertical analysis asks what explains the difference between populations, such as which user segments account for different new-user growth in the United States and in EMEA. That makes it the main tool for identifying demographics and relationships in many columns at once. It suits datasets with too many dimensions to search by intuition.

    You create one stateless instance per schema with CREATE SNOWFLAKE.ML.TOP_INSIGHTS, which needs the CREATE SNOWFLAKE.ML.TOP_INSIGHTS privilege. Callers who are not the owner need USAGE on the instance. The input must include a Boolean label column: FALSE for control rows and TRUE for test rows. This label is usually derived, so you build it in a view.

    Time-series labelling: the latest month is the test group (TRUE), everything earlier is control (FALSE)sql
    CREATE VIEW input_table_time_series_label (
      ds, metric, dim_country, dim_vertical, label ) AS
      SELECT
        ds,
        metric,
        dim_country,
        dim_vertical,
        ds >= dateadd(month, -1, current_date) AS label
      FROM input_table;

    For vertical analysis, the label would compare populations instead, for example dim_country <> 'USA' as label. You don't declare dimension types. Numeric columns are treated as continuous and string or Boolean columns as categorical, so a numeric code such as a store number must be cast to a string if you want it treated as a category. You then pass the whole input as one reference to GET_DRIVERS:

    Calling GET_DRIVERS with the label and metric columnssql
    CALL my_insights!get_drivers (
      INPUT_DATA => TABLE(my_table),
      LABEL_COLNAME => 'label',
      METRIC_COLNAMe => 'sales');

    Checkpoint 4 of 6· Check yourself

    In the Top Insights input view, which rows should the label column mark TRUE?

    Sources3

    4.Reading Top Insights results and sizing the run

    Top Insights returns one row per segment of interest, with a plain-English description that can combine several criteria, such as 'COUNTRY = france, not VERTICAL = fashion, not VERTICAL = tech'. Segments are filtered for significance and distinctiveness, so redundant ones don't appear. Each row measures how much that segment contributes to the gap between control and test:

    Top Insights output columns
    ColumnMeaning
    METRIC_CONTROLTotal metric in the control period for the segment
    METRIC_TESTTotal metric in the test period for the segment
    CONTRIBUTIONAbsolute impact of the segment on the change
    RELATIVE_CONTRIBUTIONSegment impact as a proportion of the overall test-versus-control change
    GROWTH_RATESegment change as a proportion of the segment's control metric

    Negative values are not errors. A negative contribution, relative contribution or growth rate means the segment pulled the metric down, which is often exactly the answer to 'why did revenue fall?'. On cost, execution time grows with the number of rows and dimensions. The data must fit in memory, and datasets beyond roughly 1,000,000 rows and 1,000 columns may run out of it. A bigger standard warehouse doesn't generally help. Snowflake recommends a Snowpark-optimized warehouse, which has more memory at the same size.

    Checkpoint 5 of 6· Match them up

    Match each output column to what it tells you

    Tap a term, then the definition that fits it.

    Checkpoint 6 of 6· Exam question

    A TOP_INSIGHTS result shows a segment with a large `RELATIVE_CONTRIBUTION` but a small `CONTRIBUTION`. Which interpretation is correct? Select TWO of the five that apply to reading the output.(Select 2)

    Sources3

    Exam traps

    Each one states something that sounds right. Open it to see what is actually true.

    1. 1.Train the anomaly model on the full history and it will flag the outliers in that history too.Why is that wrong?

      Detection runs only on test data whose timestamps come after the training data. Outliers in the training set aren't flagged, and they skew the model unless labelled.

      Covered in Anomaly Detection: finding when something went wrong

    2. 2.A numeric region or store code will be treated as a category in Top Insights automatically.Why is that wrong?

      Dimension types are inferred from data type. Numbers are treated as continuous, so a numeric code has to be cast to a string to act as a category.

      Covered in Top Insights: which segments explain the change

    3. 3.If Top Insights is slow or runs out of memory, move to a larger standard warehouse.Why is that wrong?

      Performance doesn't generally improve beyond the size needed to hold the data in memory. Snowflake recommends a Snowpark-optimized warehouse instead.

      Covered in Reading Top Insights results and sizing the run

    Practise it for real

    Train an anomaly detection model on synthetic sensor data and confirm it flags a reading above its upper bound

    1. 1.Create table sensor_data_30_rows and fill it with 30 per-second DEVICE3 readings using UNIFORM, RANDOM and GENERATOR(ROWCOUNT => 30), then create sensor_data_view on it.

      Why: The view lets you retrain with different row counts later without touching the source table.

      You should see: A 30-row table with timestamps from 2024-03-01 00:00:00 to 00:00:29.

    2. 2.Run CREATE OR REPLACE SNOWFLAKE.ML.ANOMALY_DETECTION sensor_model with INPUT_DATA => SYSTEM$REFERENCE('VIEW', 'sensor_data_view'), TIMESTAMP_COLNAME 'timestamp', TARGET_COLNAME 'temperature' and LABEL_COLNAME ''.

      Why: Creating the object trains the model. The empty label means unsupervised training.

      You should see: Status 'Instance SENSOR_MODEL successfully created.'

    3. 3.Create table sensor_data_device3 and insert the three readings for 00:00:30, 00:00:31 and 00:00:32.

      Why: Test timestamps must come after the training timestamps, without a large gap.

      You should see: Three rows with temperatures around 36.

    4. 4.CALL sensor_model!DETECT_ANOMALIES with INPUT_DATA => SYSTEM$REFERENCE('TABLE', 'sensor_data_device3') and the same column names.

      Why: This compares each actual reading with the forecast and the prediction interval.

      You should see: Rows with Y, FORECAST, LOWER_BOUND, UPPER_BOUND and IS_ANOMALY. Any row where Y is outside the bounds shows True. Exact values vary because the data is random.

    Stuck? Get a nudge

    If no row is flagged, compare each Y with its UPPER_BOUND. Random training data shifts the interval from run to run.

    Sources

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Detecting outliers can also be useful in pinpointing the origin of problems or deviations in processes when there is no obvious cause.”
      ↩︎ Anomaly Detection: finding when something went wrong
      “then compares the actual data to the forecast to identify outliers.”
      ↩︎ Anomaly Detection: finding when something went wrong
      “You can specify a prediction interval or use the default, which is 0.99.”
      ↩︎ Anomaly Detection: finding when something went wrong
      “You need at least 2 data points to train a model, at least 12 for non-naive results, and at least 60 for non-linear results.”
      ↩︎ Anomaly Detection: finding when something went wrong
      “Anomaly detection models, once trained, are immutable.”
      ↩︎ Anomaly Detection: finding when something went wrong
      “You must therefore pass tables and views as references, which pass along the caller”
      ↩︎ Training a model and reading its verdict
      “This skewed the predictions upward and increased the size of the prediction interval.”
      ↩︎ Training a model and reading its verdict
      “This feature only detects anomalies in the test data; it cannot detect anomalies in the training data.”
      ↩︎ Exam trap 1
      “The anomaly detection model identifies any data that falls outside of the prediction interval as an anomaly.”
      ↩︎ Prediction
      “Ensure that the training data covers a typical period free of actual outliers, or label known outliers in a Boolean column.”
      ↩︎ Checkpoint
      “Creating the anomaly detection object trains the model and stores it in the schema.”
      ↩︎ Checkpoint
    2. 2.
      “there must not be too great a gap in time between the training data and the test data.”
      ↩︎ Training a model and reading its verdict
    3. 3.
      “Top Insights is an ML Function for key driver analysis”
      ↩︎ Top Insights: which segments explain the change
      “The control group consists of the data points the model will use as a baseline.”
      ↩︎ Top Insights: which segments explain the change
      “Numeric values are taken to be continuous dimensions, while string and boolean values are considered categorical.”
      ↩︎ Top Insights: which segments explain the change
      “Top Insights does not return redundant segments.”
      ↩︎ Reading Top Insights results and sizing the run
      “The contribution, relative contribution, and growth rate may be negative, indicating that a segment has a negative impact.”
      ↩︎ Reading Top Insights results and sizing the run
      “To use a numeric value as a categorical dimension, cast it to a string.”
      ↩︎ Exam trap 2
      “Snowflake recommends using a Snowpark-optimized warehouse rather than a larger standard warehouse.”
      ↩︎ Exam trap 3
      “rows that are part of the control group (labeled FALSE) from rows in the test group (labeled TRUE)”
      ↩︎ Checkpoint
      “The impact of the segment as a proportion of the overall change in the metric between test and control.”
      ↩︎ Checkpoint

    Ready to test yourself?

    Practise the 29 questions on this subdomain.

    Spotted a mistake, or was something unclear? Tell us.