> 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.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/sdgm/_mcp/server.

# Chargeback Fraud Detection

## Solution Background and Business Value

Chargeback fraud occurs when a customer disputes a completed credit card purchase with their bank, claiming it was unauthorized.
If the bank approves the claim, the transaction is reversed and the merchant bears the financial loss.
This is a significant problem for **e-commerce platforms and online retailers**.

**Machine learning models** can detect and prevent chargeback fraud, allowing businesses to:

* **Reduce fraudulent transactions** by identifying high-risk purchases early.

* **Minimize financial losses** by preventing chargebacks before they occur.

## Data Requirements and Schema

Kumo analyzes data in its **raw relational form**: you connect your existing tables directly, without joining them or engineering features in advance.
Kumo uses **Graph Neural Networks (GNNs)** to learn from the relationships between entities (such as users, orders, and chargebacks), which improves fraud detection accuracy compared to single-table models.

**Core Tables**

1. **Accounts Table**

   * Stores user account details.

   * **Key attributes:**

     * `account_id`: Unique identifier.

     * **Optional:** Creation date, location, age, account type.

2. **Orders Table**

   * Stores details of each order.

   * **Key attributes:**

     * `order_id`: Unique order identifier.

     * `account_id`: Links the order to a user.

     * `timestamp`: Time of purchase.

     * **Optional:** Order value, payment method, shipping details.

3. **Chargebacks Table**

   * Stores information about chargeback claims.

   * **Key attributes:**

     * `chargeback_id`: Unique identifier.

     * `order_id`: Links the chargeback to an order.

     * `timestamp`: Time of chargeback request.

     * `label`: Indicates whether the chargeback was fraudulent (1) or legitimate (0).

**Additional Tables (Optional)**

* **Items Table:** Stores item-level details within an order.

* **Order-Items Table:** Links orders to specific items purchased.

* **Payment Methods Table:** Stores payment details (for example, card type or account linkage).

* **Merchants Table:** Information on merchants selling products.

* **Account Events Table:** Tracks user account activity.

**Entity Relationship Diagram (ERD)**

```mermaid
erDiagram
    ACCOUNTS {
        INT account_id PK
        STRING location
        TIMESTAMP creation_date
    }
    
    ORDERS {
        INT order_id PK
        INT account_id FK
        TIMESTAMP timestamp
        FLOAT order_value
    }
    
    CHARGEBACKS {
        INT chargeback_id PK
        INT order_id FK
        TIMESTAMP timestamp
        INT label
    }

    ACCOUNTS ||--o{ ORDERS : "places"
    ORDERS ||--o{ CHARGEBACKS : "disputed"
```

## Predictive Queries

Kumo uses Predictive Query Language (PQL) to define what to predict and over which entities.
Choose the query that matches where your fraud labels are most reliably recorded:

**1. Predict Fraudulent Chargebacks**

This model predicts whether a chargeback is fraudulent:

```pql
PREDICT chargebacks.LABEL
FOR EACH chargebacks.chargeback_id
```

* At inference time, leave `LABEL` empty for new chargebacks to generate fraud risk scores.

**2. Predict Fraud Risk at the Order Level**

To anticipate fraud before a chargeback is filed, add a fraud label column to the `orders` table and predict at the order level:

```pql
PREDICT orders.LABEL
FOR EACH orders.order_id
```

**3. Predict Future Chargeback Fraud**

For proactive fraud detection, predict whether an **order or account will experience a fraudulent chargeback** in the next X days:

```pql
-- Predict if an order will receive a fraudulent chargeback
PREDICT FIRST(chargebacks.LABEL = 1, 0, X) > 0
FOR EACH orders.order_id
ASSUMING COUNT(chargebacks.*, 0, X) > 0

-- Predict if an account will be associated with at least one fraudulent chargeback
PREDICT COUNT(chargebacks.LABEL = 1, 0, X) > 0
FOR EACH accounts.account_id
ASSUMING COUNT(orders.*, 0, X) > 0
```

## Deployment Strategy

The right deployment strategy depends on your **fraud detection system's maturity**:

**1. Batch Predictions for Fraud Analysts**

* Fraud teams manually **review and label** chargebacks.

* ML model predictions **prioritize high-risk chargebacks** for faster action.

* Predictions are generated **daily or hourly** in batch mode.
  Add this filter to your batch query to process only recent chargebacks:

```pql
WHERE chargebacks.TIMESTAMP > MIN_TIMESTAMP
```

**2. Real-Time Chargeback Fraud Detection**

* The system generates **real-time risk scores** when an order is placed.

* If a transaction is **high risk**, additional verification or manual review is triggered.

* ML embeddings are used to **enhance rule-based fraud detection**.

## Building Models in Kumo Fine-Tune SDK

**1. Initialize the Kumo Fine-Tune SDK**

```python
import kumoai as kumo

kumo.init(url="https://<customer_id>.kumoai.cloud/api", api_key=API_KEY)
```

**2. Connect data**

```python
connector = kumo.S3Connector("s3://your-dataset-location/")
```

**3. Select tables**

```python
accounts = kumo.Table.from_source_table(
    source_table=connector.table('accounts'),
    primary_key='account_id',
).infer_metadata()

orders = kumo.Table.from_source_table(
    source_table=connector.table('orders'),
    time_column='timestamp',
).infer_metadata()

chargebacks = kumo.Table.from_source_table(
    source_table=connector.table('chargebacks'),
    time_column='timestamp',
).infer_metadata()
```

**4. Create graph schema**

```python
graph = kumo.Graph(
    tables={
        'accounts': accounts,
        'orders': orders,
        'chargebacks': chargebacks,
    },
    edges=[
        dict(src_table='orders', fkey='account_id', dst_table='accounts'),
        dict(src_table='chargebacks', fkey='order_id', dst_table='orders'),
    ],
)

graph.validate(verbose=True)
```

**5. Train the model**

```python
pquery = kumo.PredictiveQuery(
    graph=graph,
    query="PREDICT chargebacks.LABEL FOR EACH chargebacks.chargeback_id"
)
pquery.validate(verbose=True)

model_plan = pquery.suggest_model_plan()
trainer = kumo.Trainer(model_plan)
training_job = trainer.fit(
    graph=graph,
    train_table=pquery.generate_training_table(non_blocking=True),
    non_blocking=False,
)
print(f"Training metrics: {training_job.metrics()}")
```