CertSafari
    Snowflake SnowPro Advanced: Data Scientist (DSA-C03)· Lessons

    Domain 3 · Lesson 13/16

    Interpreting Snowflake models with SHAP, feature importance and prediction intervals

    Interpret a model.

    20 min read
    6.2% of exam
    10 sources
    Published 20 Oct 2026
    Docs as of 4 Oct 2026

    What you will be able to do

    • Read a Shapley value explanation and reconstruct a prediction from its base value and feature contributions
    • Log a model to the Snowflake Model Registry with background data so explainability is enabled, and add explainability to a model version logged without it
    • Call the explain method from Python and SQL and say what each output row contains
    • Tell local explanations from global feature importance and choose the right visualization for each
    • Use an influence sensitivity plot to see how one feature's value moves predictions
    • Read the built-in feature importance of ML Functions and the lower and upper bounds a forecast returns

    Key concept

    Shapley value — A Shapley value is one feature's signed contribution to one prediction, measured against an average prediction computed from background data. Add up every feature's contribution, put the average on top, and you get that row's prediction.

    1.SHAP values: attributing one prediction to its features

    A trained model learns how inputs relate to outputs without anyone writing those rules down. That makes it a black box. When it underperforms, it is hard to see why, and it can hide biases. Regulated industries such as finance and healthcare may need evidence that a model reaches the right answer for the right reasons. The Snowflake Model Registry addresses this with an explainability function built on Shapley values.

    A Shapley value measures a feature's average marginal contribution to a prediction, taken over all possible combinations of features. Each feature gets a signed number for each prediction. Because it considers every combination, the method is computationally intensive. In return, importance is attributed fairly even in complex models.

    One explained prediction: a 2000 sq ft beachside house with three bedrooms and no pets
    FeatureValueContribution vs. an average house
    Average house (base)—$100,000
    Size2000+$50,000
    LocationBeachside+$75,000
    Bedrooms3+$50,000
    PetsNo-$25,000
    Model prediction—$250,000

    The arithmetic always runs the same way: base value plus the sum of contributions equals the prediction. In the table, 100,000 + 150,000 = 250,000. A contribution can be negative. Here, not allowing pets pulls the price down by $25,000. Shapley values have no reason to sum to zero across features. They sum to the gap between this prediction and the average. They are also measured in the same units as the model's output, whatever those are. If the base value is a raw score, the contributions are raw scores too, and adding them to the base gives the raw output for that row, not a probability.

    The average comes from background data, a representative sample of the dataset. The algorithm perturbs input features by swapping in background values, so every Shapley value describes a deviation from that background. If you change the background data, the baseline moves too. When you compare explanations across datasets, use the same background data for all of them.

    Checkpoint 1 of 10· Check yourself

    An analyst explains predictions from the same model on two datasets, Q1 and Q2. Each dataset uses its own background sample, and the analyst then compares the SHAP values for the feature Location across the two. What is the problem with this comparison?

    Checkpoint 2 of 10· Exam question

    A data scientist logs an XGBoost churn classifier to the Snowflake Model Registry and inspects SHAP values for one customer. The base value is 0.18 (log-odds) and the per-feature SHAP values sum to +1.02. What does this tell the data scientist about that customer's prediction?

    Sources1

    2.Enabling explainability when logging a model

    Explainability is turned on when a model version is logged, and it is on by default for supported models. The supported Python-native packages are XGBoost, CatBoost, LightGBM and scikit-learn. From snowflake.ml.modeling, the XGBoost, LightGBM and scikit-learn classes are supported. These models get explainability by default when logged with Snowpark ML 1.6.2 or later, and the registry runs the SHAP library itself. You do not need to add shap to conda_dependencies for explanations to work.

    **Background data goes in through sample_input_data, up to 1,000 rows.** It should be a representative sample of the feature inputs, so the explainer knows what an average input looks like. Some tree-based models encode a background in their structure and can do without it. Most models need it, and for those, explainability cannot be enabled at all if it is missing. Every model, including tree-based ones, gets more accurate explanations when you supply it.

    Logging with explicit signatures and background data: the enable_explainability flag is required when both are passedpython
    mv = reg.log_model(
        catboost_model,
        model_name="diamond_catboost_explain_enabled",
        version_name="explain_v0",
        conda_dependencies=["snowflake-ml-python"],
        signatures={"predict": predict_signature, "predict_proba": predict_proba_signature},
        sample_input_data = xs, # xs will be used as background data
        options= {"enable_explainability": True} # you will need to set this flag in order to pass both signatures and background data
    )

    The same option turns explainability off. Pass {"enable_explainability": False} in options when you don't need explanations and want a smaller model with fewer dependencies.

    A model version logged before Snowpark ML 1.6.2 has no explain method, and upgrading the library does not add one. Model versions are immutable. The fix is to load the old version's Python object and log it again as a new version, passing background data as sample_input_data. The Python environment you load into must match the deployment environment exactly, including the Python version and every library version.

    Adding explainability to an existing model by re-logging it as a new versionpython
    mv_old = reg.get_model("model_without_explain_enabled").default
    model = mv_old.load()
    mv_new = reg.log_model(
        model,
        model_name="model_with_explain_enabled",
        version_name="explain_v0",
        conda_dependencies=["snowflake-ml-python"],
        sample_input_data = xs
    )

    Checkpoint 3 of 10· Fill the gap

    This call passes explicit signatures and background data together. Which option key must be set to True so that the model version gets an explain method?

    mv = reg.log_model(
        catboost_model,
        model_name="diamond_catboost_explain_enabled",
        version_name="explain_v0",
        conda_dependencies=["snowflake-ml-python"],
        signatures={"predict": predict_signature, "predict_proba": predict_proba_signature},
        sample_input_data = xs, # xs will be used as background data
        options= {" ? ": True} # you will need to set this flag in order to pass both signatures and background data
    )

    Checkpoint 4 of 10· Exam question

    A team logs a scikit-learn model with reg.log_model(...) and wants accurate Shapley-based explanations later. Which logging step gives the Model Registry the data it needs to compute these explanations most accurately?

    Sources12

    3.Calling explain from Python and SQL

    **A model version with explainability has an explain method, and it needs input rows.** A Shapley value explains a prediction made from specific inputs, so you pass the rows whose predictions you want explained. In Python, call it through ModelVersion.run with function_name="explain", just as you would call predict.

    Retrieving SHAP values in Pythonpython
    reg = Registry(...)
    mv = reg.get_model("diamond_catboost_explain_enabled").default
    explanations = mv.run(input_data, function_name="explain")

    In SQL, bind a model version to an alias with WITH ... AS MODEL ... VERSION ..., then call ALIAS!EXPLAIN(...) as a table function next to the source table. List the feature columns as arguments.

    Retrieving SHAP values in SQL with a model version aliassql
    WITH MV_ALIAS AS MODEL DATABASE.SCHEMA.DIAMOND_CATBOOST_EXPLAIN_ENABLED VERSION EXPLAIN_V0
    SELECT *
          FROM DATABASE.SCHEMA.DIAMOND_DATA,
              TABLE(MV_ALIAS!EXPLAIN(CUT, COLOR, CLARITY, CARAT, DEPTH, TABLE_PCT, X, Y, Z));

    The result is local: every input row gets its own Shapley value for each feature. Each value is that feature's contribution to that row's prediction. explain does not collapse rows into one global summary, and it does not return interval bounds or curves. A whole-model ranking or a picture of a feature's effect is something you build from these per-row values afterwards.

    Checkpoint 5 of 10· Check yourself

    A credit team has a scikit-learn model in the registry with explainability turned on. They want to show reviewers why the model scored each of 500 new loan applications the way it did. Which approach works?

    Checkpoint 6 of 10· Exam question

    An analyst runs the following query against a model version alias mv that was logged with explainability enabled: SELECT * FROM src_table, TABLE(mv!EXPLAIN(age, tenure, plan_type)); What does the result contain for each input row?

    Sources1

    4.Local versus global feature importance

    The same table of SHAP values answers two different questions, depending on whether you read one row or many. A local explanation shows why the model scored one customer or one transaction the way it did. A global ranking shows which features drive the model across a whole scored set. Snowflake's visualization functions in snowflake.ml.monitoring.explain_visualize give each view its own chart.

    Snowflake SHAP visualizations and the question each one answers
    FunctionScopeWhat it answers
    plot_forceOne prediction (local)Which features pushed this prediction above or below the base value, and by how much
    plot_violinMany predictions (global)Which features have the most influence overall, and how widely their SHAP values spread
    plot_influence_sensitivityOne feature across many rowsHow the feature's value relates to its contribution

    A force plot is the local view. It takes shap_row and features_row for one instance. Each contribution is drawn as an arrow from the base value: red pushes the prediction higher, blue pulls it lower, and arrow size shows magnitude. base_value defaults to 0.0, so set it to the model's mean prediction or the arrows start from the wrong place. contribution_threshold (default 0.05) hides features whose share of total absolute SHAP falls below it. If no feature clears the threshold, or the threshold is outside 0 to 1, the call raises a SnowflakeMLException.

    A violin plot is the global view. It takes SHAP values and feature values for many rows and draws one violin per feature. Features are sorted by absolute mean SHAP value, most influential at the top. Ranking by mean absolute SHAP tells you how strongly each feature moves predictions on average across the rows you scored. Taking the absolute value drops the sign, so the ranking doesn't say whether a feature raises or lowers predictions. It also inherits the background data, because every SHAP value is a deviation from it.

    Checkpoint 7 of 10· Match them up

    Match each explain_visualize function to the question it is built to answer from the SHAP values that explain returns.

    Tap a term, then the definition that fits it.

    Sources34

    5.Partial dependence: how a feature's value moves predictions

    Partial dependence asks how predictions respond as one feature's value changes. Global rankings can't answer that. A feature can rank high because it matters only past a threshold, or because its effect reverses in the middle of its range. Snowflake answers the question with plot_influence_sensitivity(), which draws a SHAP dependence scatter plot for a single feature.

    The x-axis carries the feature's values and the y-axis carries that feature's SHAP values, one point per row. A rising band means higher values push predictions up. A flat stretch that suddenly jumps marks a threshold. A curve that bends shows a non-linear effect. Vertical spread at one x-value shows the feature's effect depends on other features. The plot shows trends, the strength and direction of influence, and clusters or patterns in feature interactions.

    The function takes shap_values and feature_values for the same feature, plus an optional figsize, which defaults to (1400, 500). In Snowflake Notebooks you can pass 2D arrays covering many features and pick one from an interactive dropdown. In a local notebook you must pass one feature's SHAP values and feature values.

    Checkpoint 8 of 10· Check yourself

    A violin plot ranks Tenure_Months as the second most influential feature in a churn model. The product owner suspects Tenure_Months only starts to matter after about 24 months. Which output would confirm or rule out that threshold?

    Sources5

    6.Feature impact from ML Functions

    Snowflake's pre-built ML Functions report feature impact through their own methods, not through SHAP. These are SQL classes such as Classification, Forecast and Anomaly Detection, covered under Pre-built ML Functions and stored predictions. None of them has an explain method. Classification models expose <model_name>!SHOW_FEATURE_IMPORTANCE(). Forecast and anomaly detection models expose <model_name>!EXPLAIN_FEATURE_IMPORTANCE(). Neither method takes arguments, and both return a ranked table with one score per feature from 0 to 1.

    Classification importance counts how often the model's trees used each feature to make a decision, then normalizes the counts so they sum to 1. You cannot choose a different technique. The scores give an approximate ranking, so read them as estimates of which features matter for accuracy, not exact measurements. Features with close scores matter about equally. Several near-duplicate features split their importance and can each look weaker than they are. These scores also describe the model as a whole and never explain an individual prediction.

    Columns returned by EXPLAIN_FEATURE_IMPORTANCE on a forecast model
    ColumnMeaning
    SERIESSeries value; NULL for a model trained on a single time series
    RANKImportance rank of the feature for that series
    FEATURE_NAMEFeature name; aggregated_endogenous_features stands for all features derived from the target
    IMPORTANCE_SCOREScore in [0, 1], 1 being the most important
    FEATURE_TYPEuser_provided, derived_from_timestamp or derived_from_endogenous

    FEATURE_TYPE matters more for forecasts than for classification. A forecast builds features of its own, such as day, week or month periodicity from the timestamp and transformations of the target. When derived_from_timestamp ranks first, the model is leaning on seasonality rather than on the columns you supplied.

    Checkpoint 9 of 10· Match them up

    A forecast model's EXPLAIN_FEATURE_IMPORTANCE output tags every ranked feature with a FEATURE_TYPE. Match each FEATURE_TYPE value to what a high rank for it tells you about the forecast.

    Tap a term, then the definition that fits it.

    Sources678

    7.Confidence intervals on individual forecasts

    Each forecast row comes with a range alongside the point value. <model_name>!FORECAST returns FORECAST, LOWER_BOUND and UPPER_BOUND for each timestamp. You set the width with the prediction_interval key in CONFIG_OBJECT. It accepts values from 0.0 up to, but not including, 1.0, and defaults to 0.95.

    With the default 0.95, 95% of future points are expected to fall between the bounds. A confidence interval covers an estimated quantity such as a mean. This interval covers individual future outcomes, which is why it is called a prediction interval and why it is wider than a confidence interval for a mean at the same level. Raising prediction_interval toward 1.0 widens the band. Lowering it narrows the band, and fewer actual values fall inside.

    Checkpoint 10 of 10· Check yourself

    For each week in next quarter's demand forecast, the supply team wants a low and a high estimate as well as the expected value, and they want 90% of actual weeks to land inside that range. Which approach gives them this?

    Sources9

    Practise it for real

    Log a supported model with background data, retrieve its SHAP values from Python and SQL, and draw a force plot for one row.

    1. 1.Log a scikit-learn, XGBoost, LightGBM or CatBoost model with reg.log_model, passing a representative sample of up to 1,000 feature rows as sample_input_data.

      Why: The sample becomes the background data that defines the base value, and supported models get explainability by default.

      You should see: A new model version whose functions include explain.

    2. 2.Call mv.run(input_data, function_name="explain") on a few scoring rows.

      Why: Explanations exist only for the specific inputs you pass.

      You should see: A DataFrame with one row per input row and a SHAP value column for each feature.

    3. 3.Run the same explanation in SQL: bind the version with WITH ... AS MODEL ... VERSION ... and select from TABLE(ALIAS!EXPLAIN(...)) next to the source table, listing the feature columns as the arguments.

      Why: Lets analysts get per-row explanations without Python.

      You should see: Each source row comes back alongside its per-feature SHAP values.

    4. 4.Pass one row's SHAP values and feature values to snowflake.ml.monitoring.explain_visualize.plot_force, setting base_value to the model's mean prediction.

      Why: base_value defaults to 0.0, so the arrows start from the wrong point unless you set it.

      You should see: Red arrows push the prediction up, blue arrows pull it down, and together they end at the model's prediction for that row.

    Stuck? Get a nudge

    If plot_force raises a SnowflakeMLException, check that contribution_threshold is between 0 and 1 and low enough that at least one feature clears it.

    Sources

    (10)

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

    1. 1.
      “Shapley values measure the average marginal contribution of each feature to the model’s prediction”
      ↩︎ SHAP values: attributing one prediction to its features
      “Because it reports deviation from background data, it is important to use consistent background data when comparing Shapley values from multiple data sets.”
      ↩︎ SHAP values: attributing one prediction to its features
      “Explainability is available by default for the above models logged using Snowpark ML 1.6.2 and later. The implementation uses the SHAP library.”
      ↩︎ Enabling explainability when logging a model
      “Since model versions are immutable, you must create a new model version to add explainability to an existing model.”
      ↩︎ Enabling explainability when logging a model
      “Models with explainability have a method named explain that returns the Shapley values for the model’s features.”
      ↩︎ Calling explain from Python and SQL
      “you must pass input data to explain to generate the predictions to be explained”
      ↩︎ Calling explain from Python and SQL
      “Shapley values are a way to attribute the output of a machine learning model to its input features.”
      ↩︎ Key concept
      “Shapley values can affect the final outcome positively or negatively, adding up to a difference of outcomes compared to an average.”
      ↩︎ Exam trap 1
      “You can provide up to 1,000 rows of background data when logging a model by passing it in the sample_input_data parameter”
      ↩︎ Exam trap 2
      “Since model versions are immutable, you must create a new model version to add explainability to an existing model.”
      ↩︎ Exam trap 3
      “you will need to set this flag in order to pass both signatures and background data”
      ↩︎ Exam trap 4
      “Shapley values can affect the final outcome positively or negatively, adding up to a difference of outcomes compared to an average.”
      ↩︎ Prediction
      “Because Shapley values are explanations of predictions made from specific inputs, you must pass input data to explain to generate the predictions to be explained.”
      ↩︎ Checkpoint
    2. 2.
      “If you do not need explainability features, you can disable them during logging to reduce model size and dependencies”
      ↩︎ Enabling explainability when logging a model
    3. 3.
      “A feature’s contribution is represented by an arrow that directs the model’s prediction higher or lower from the base value.”
      ↩︎ Local versus global feature importance
    4. 4.
      “The violin plots are sorted by the absolute mean SHAP value of each feature”
      ↩︎ Local versus global feature importance
      “sorted by the absolute mean SHAP value of each feature, with the features with the most significant influence on the model’s predictions at the top”
      ↩︎ Checkpoint
    5. 5.
      “create a SHAP dependence scatter plot to visualize the relationship between feature values and their SHAP values”
      ↩︎ Partial dependence: how a feature's value moves predictions
      “The function returns a chart that visualizes the feature values along the x-axis and their corresponding SHAP values along the y-axis.”
      ↩︎ Partial dependence: how a feature's value moves predictions
    6. 6.
      “The SHOW_FEATURE_IMPORTANCE method counts the number of times the model’s trees used each feature to make a decision.”
      ↩︎ Feature impact from ML Functions
      “Using multiple features that are very similar to each other may result in reduced importance scores for those features.”
      ↩︎ Feature impact from ML Functions
      “but the actual values should be considered estimates”
      ↩︎ Exam trap 5
    7. 7.
      “aggregated_endogenous_features represents all features derived as transformations of the target variable.”
      ↩︎ Feature impact from ML Functions
      “derived_from_timestamp: Periodic feature (e.g. day, week, or month) derived from timestamp data. derived_from_endogenous: Features derived from a transformation of the target variable.”
      ↩︎ Checkpoint
    8. 8.
      “Returns the relative feature importance for each feature used by the model. This method takes no arguments.”
      ↩︎ Feature impact from ML Functions
    9. 9.
      “The default value of 0.95 means 95% of future points are expected to fall within the interval [lower_bound, upper_bound] from the forecast result.”
      ↩︎ Confidence intervals on individual forecasts

    Also cited

    Ready to test yourself?

    Practise the 22 questions on this subdomain.

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