Blog

Snowflake knows, Nussknacker acts: real-time decisions with your Snowflake features and ML models

Your features and your models live in Snowflake. The decision has to be made on each event, as it arrives. Nussknacker now reads the Snowflake Online Feature Store and calls models from the Snowflake Model Registry inside a scenario, so data scientists keep working in Snowflake and the business team owns the decision.

ML and AIFraud detectionUse cases
Isometric model block beside the title 'Snowflake knows, Nussknacker acts: real-time decisions with your Snowflake features and ML models'

Snowflake knows, Nussknacker acts: real-time card fraud decisions with Snowflake ML

This is part one of two. Part two, coming soon, turns these decisions into a tool for AI agents over MCP.

The gap between knowing and acting

Snowflake is where a company learns about its customers. The history is there, the features are computed there, and the models are trained and registered there.

Acting on that knowledge is a different job. A card payment has to be approved, stepped up or blocked when it happens, not in tomorrow's report. At that moment you need three things:

  • What just happened. How many payments this card made in the last ten minutes, and in how many countries in the last hour.
  • What you already know. The customer's usual spending, the merchant's fraud rate.
  • A policy. Something that turns a score into an action, and that someone other than a developer can change.

The first one is stream processing. The second one, and the model, already exist in Snowflake. This post shows how we put them together in one Nussknacker scenario, on a card fraud example you can watch in the two-minute video above.

One caveat: this demo publishes its decisions to Kafka, and end-to-end authorisation latency has not been benchmarked.

What is new

The ML Enricher in Nussknacker already calls models from MLflow, from Databricks managed MLflow and from the Databricks Unity Catalog. Snowflake was already there too, as a database: you could enrich Kafka events with Snowflake tables over SQL.

Now the same Snowflake integration adds two components:

  • ML Enricher for the Snowflake Model Registry. It lists the models of a schema and the versions served in Snowpark Container Services. The node's inputs come from the model's signature, so you fill in typed fields, one per input, and Nussknacker checks the types.
  • Feature Store Enricher. It reads the latest features of an entity, such as a customer or a merchant, from the Snowflake Online Feature Store. You pick a feature view and give the key. The result is a typed record of the view's features.

Once the models, their services, the role and the network policy exist on the Snowflake side, the Nussknacker side is two optional fields in the Snowflake form of the Integrations view. Fill in the Model Registry schema to get the ML Enricher, the feature store schema to get the Feature Store Enricher, or both, with a programmatic access token. Test connection checks the SQL connection and, for each schema you filled in, lists the models or asks for the feature store's online service. Save, and the enrichers for those schemas are in the palette.

The Snowflake integration form in Nussknacker with the Model Registry schema and the feature store schema filled in

The example: card fraud

What the data scientist does in Snowflake

One notebook builds everything Nussknacker needs: a history of card payments, a feature store and a fraud model.

The data is synthetic. The notebook generates about 200,000 card payments of 2,000 customers over 90 days, with a fixed seed, and injects fraud into roughly 3% of them as a few patterns: a burst of fast purchases on one card, purchases in several countries within an hour, and unusually large purchases.

That's why the features look the way they do. Here is fraud by the number of countries a customer paid in during the one-hour window ending at and including the current payment:

Countries in the last hour Payments Fraud
1 194,028 2.7%
2 1,729 20.1%
3 or more 554 96.4%

The fraud patterns were put into the synthetic data on purpose, so these numbers explain the feature and are not a measure of model quality.

Snowflake notebook result: fraud share by the number of countries a card paid in within one hour

The feature store keeps what is known about each customer and merchant and serves it online. An XGBoost model learns from those features together with three aggregates of the card's recent activity: the count and the sum of its payments in the last ten minutes, and the number of countries in the last hour. The running scenario computes them live. For training, the notebook recomputes them in batch for every historical payment, with the same window lengths and the current payment included. The keys differ: the notebook groups by customer and the scenario by card. In the demo data every customer has exactly one card, so both count the same payments. That is a simplification of the demo. In production, use the same key in training and at inference; otherwise a customer with two cards gets different counts, sums and countries in the two places. The model is logged to the Model Registry in two versions, each with its own inference service.

Snowflake notebook output listing the customer and merchant feature views served by the online feature store

What the scenario does in Nussknacker

The scenario reads card payments from Kafka and does five things with each one:

  1. Live aggregates. Two sliding windows per card: payments and their sum over ten minutes, distinct countries over one hour.
  2. Snowflake features. Two Feature Store Enricher nodes, one keyed by the customer and one by the merchant.
  3. Fraud score. The ML Enricher calls the Snowflake model with the amount, the hour, the three aggregates and the features. The answer is a fraud probability.
  4. Fraud policy. A Decision Table turns the score and the amount into APPROVE, STEP_UP or BLOCK.
  5. Routes. Each decision goes to its own Kafka topic, and every decision is logged.

Part of the Nussknacker scenario: the fraud score node calling the Snowflake model with live aggregates and features

Open the fraud score node and you can see where the model comes from. The model and its version are picked from lists that the registry fills, and each input of the model is a field of the node. Here it is on a live payment, with the values that went in and the score that came back:

The ML Enricher node on a live payment: the model's typed inputs and the returned fraud score

The fraud team owns the policy

The model gives a number. What to do with that number is a business decision, and in the scenario it's a table:

Minimum score Minimum amount Decision Reason
0.00 0.00 APPROVE Low fraud score
0.25 40.00 STEP_UP Ask for extra verification
0.85 0.00 BLOCK High fraud score

A payment can match more than one row: a score of 0.90 on a payment of 100 matches all three. The Decision Table returns every matching row, and the next two nodes pick one. The row with the highest minimum score wins, so that payment is blocked. If no row matches, for example because there is no score, or if two rows tie, the scenario asks for extra verification.

The fraud policy node in the scenario with its decision table

In the video, the fraud team decides that a burst of payments should be blocked earlier. They change 0.85 to 0.60 in the table, save and deploy.

Editing the Decision Table: the block threshold changes from a score of 0.85 to 0.60

Then the same burst is sent again: seven payments of one card, a minute apart. Each run uses a new card id, so its windows start empty and nothing is left over from the run before. The model version is the same, V1. Only the table changed. In the video's run the third payment is 45 with a fraud score of 0.72:

Policy Blocks from Payment 3: amount 45, score 0.72
Before 0.85 STEP_UP
After 0.60 BLOCK

The same burst under the new policy: payment 3 is now blocked instead of stepped up

Nobody retrained the model and no data scientist was involved. It's the same division of work we described for credit scoring in telecoms: the model stays where data scientists work, and the policy belongs to the people who answer for it.

What the scenario adds

Snowflake can do a lot of this by itself. Its quickstart, Build Real-Time ML Inference with Feature Store, serves a fraud model from features in a table: a client sends a transaction id, the inference service looks the features up and returns the prediction. The Online Feature Store also has stream feature views and time-windowed aggregations. In our example the windows are computed in the scenario, on Apache Flink; they could come from Snowflake instead, and the rest would stay the same.

What the scenario gives you is the whole decision in one visual process: the state of the stream, features from outside, the model call, the policy and the action that follows. Each step is a node you can open, and you can see live payments going in and results coming out.

The policy is where that helps most. The fraud team edits the table in its node. Nussknacker validates the column types and the match expression before anything is saved. Deploying the change is one action. It's a short path from "we should block earlier" to a policy that is running.

When something is missing

A customer or merchant the feature store doesn't know gives a record with empty features. This scenario passes them to the model as nulls and substitutes no defaults. If the model returns no score, no row of the table matches and the decision is STEP_UP with the reason "Score unavailable". We didn't exercise this path in the demo.

A lookup or a model call that fails, because of a timeout, a busy service, an expired token or an input the model's service rejects, fails that event: no decision is published for it and the scenario reports an error.

What you need

  • Models served in Snowpark Container Services with a public endpoint (create_service(..., ingress_enabled=True)), as described in Snowflake's guide to real-time inference. Binary classification and regression models are supported today.
  • Feature views with the online store enabled and a running online service, which needs a paid Snowflake account.
  • A programmatic access token for the integration's user, under a network policy that allows the Designer and the Nussknacker runtime.

Coming in part two

The stream decides on every payment. In the next post, the same decisions become a tool for AI agents: a blocked payment and the signals behind it, published over MCP, so an agent can answer "why was my card blocked?" with what the stream actually decided. If you want a head start, serving real-time Kafka data to AI agents through MCP covers the building blocks.

Watch the whole example: real-time card fraud decisions with Snowflake ML in Nussknacker

The visual Flink interface for real-time decision logic.

Enrich, decide, and act on every event.