> This page is for Kumo Engine.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/sdgm/llms.txt.

# Chargeback Fraud Detection

Chargeback fraud happens when a customer disputes a completed purchase with their bank and the merchant absorbs the reversed payment.
This example scores existing chargebacks for fraud and predicts which orders are most likely to receive a chargeback in the coming weeks.
Kumo Engine learns from each chargeback or order's details and from the account and order history connected to it in the graph.

## Data and relationships

The example assumes a prepared Kumo Engine `graph`, a matching `snapshot`, and these tables:

![Chargeback fraud detection schema. Chargebacks link to orders through order\_id, and orders link to accounts through account\_id. Chargebacks and orders have time columns.](/sdgm/_fern-files/nvidia-sdgm.docs.buildwithfern.com/1dcd6222cf5fcecb93d4c3bb3cc38c88d68963702588ca5dd91d574292c13546/_dot_dot_/images/diagrams/workflow-chargeback-fraud-detection-schema.svg)

| Table         | Required columns                                                  | Purpose                                                                                                                  |
| ------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `chargebacks` | `chargeback_id`, `order_id`, `chargeback_date`, `label`           | Chargeback claims; `label` records how a resolved claim turned out, where `1` means fraudulent and `0` means legitimate. |
| `orders`      | `order_id` as the primary key, plus `account_id` and `order_date` | The order each chargeback disputes, and the entity the forward-looking queries score.                                    |
| `accounts`    | `account_id` as the primary key                                   | The account each order belongs to, for account-level context.                                                            |

The time columns place every row in time, so each prediction is trained and scored using only information recorded before its prediction point.

`label` is the value the scoring query predicts, so it is the label rather than a feature.
There is no direct foreign key from `chargebacks` to `accounts`, so the forward-looking queries below run over orders.

## Score each chargeback for fraud

This query predicts whether each chargeback is fraudulent.
The target `chargebacks.label = 1` turns the recorded outcome into a yes or no label, and `FOR EACH chargebacks.chargeback_id` produces one prediction per chargeback.

Because the chargebacks table is anchored at `chargeback_date`, the model learns from the account and order history that exists when the claim is filed.
Predict the comparison `label = 1` rather than the raw `label` column, which Kumo Engine reads as a numeric target and scores as a regression.

```python
from kumo.engine import PredictiveQuery

query_text = (
    "PREDICT chargebacks.label = 1 "
    "FOR EACH chargebacks.chargeback_id"
)
query = PredictiveQuery(graph, query_text)
query.validate()
print(query.get_task_type())  # binary_classification
```

## Predict future chargeback fraud for an order

Scoring a claim only helps once it has been filed.
To act earlier, use this query to predict whether each order will receive a fraudulent chargeback in the next 30 days.

`SUM(chargebacks.label, 0, 30, days)` adds up the fraud labels of the chargebacks linked to the order over the 30 days that follow the scoring time, and `> 0` turns that into a yes or no label.
Because legitimate chargebacks carry a label of `0`, only a fraudulent one moves the sum above zero, so this flags future fraud specifically rather than any dispute.

```python
query_text = (
    "PREDICT SUM(chargebacks.label, 0, 30, days) > 0 "
    "FOR EACH orders.order_id"
)
query = PredictiveQuery(graph, query_text)
query.validate()
print(query.get_task_type())  # binary_classification
```

## Predict future dispute risk for an order

Predicting all disputes, including legitimate ones, helps teams staff support and hold higher-risk orders for review.
This query predicts whether an order will receive any chargeback in the next 30 days.
`COUNT(chargebacks.*, 0, 30, days)` counts every chargeback linked to the order over the same 30-day window regardless of its label, and `> 0` turns that into a yes or no label.

```python
query_text = (
    "PREDICT COUNT(chargebacks.*, 0, 30, days) > 0 "
    "FOR EACH orders.order_id"
)
query = PredictiveQuery(graph, query_text)
query.validate()
print(query.get_task_type())  # binary_classification
```

## Reading the predictions

The scoring query returns a probability that a filed chargeback is fraudulent, so a fraud team can rank open claims by risk.
The two forward-looking queries return a probability that an order will receive a fraudulent chargeback, or any chargeback, within the next 30 days.
These predictions support action before a claim exists, such as holding a high-risk order for verification or routing it to manual review.

All three are estimates from past behavior, not guarantees.
The chargeback score is anchored at the moment each claim is filed, and the two forward-looking queries are anchored at the time you run them.
In every case, the model uses only information recorded before that anchor and never sees the outcome it predicts.

The 30-day window on the forward-looking queries is a starting point; widen or narrow the number of days to match how far ahead your team needs to act.
Refresh the predictions as new orders and chargebacks arrive so each decision reflects the latest history.