Credit Card Fraud Detection Solution

View as Markdown

Solution Background and Business Value

Credit card fraud causes significant losses for financial institutions, businesses, and consumers. Fraud occurs when a malicious actor gains unauthorized access to a customer’s credit card and makes fraudulent transactions.

Machine learning models can detect fraud in real-time, enabling teams to:

  • Identify suspicious transactions early and intervene before money is lost.
  • Reduce false positives, so legitimate transactions are not blocked.
  • Improve detection accuracy by learning from graph-based patterns in transaction networks.

Data Requirements and Schema

Kumo AI processes relational data as interconnected tables using Graph Neural Networks (GNNs). This approach allows the model to learn from transaction patterns, account behavior, and merchant interactions without extensive feature engineering.

Entity relationship diagram showing connections between the credit cards, transactions, and fraud reports tables

Core Tables

  1. Transactions Table
    • Stores all recorded transactions.
    • Key attributes:
      • transaction_id: Unique identifier for each transaction.
      • timestamp: When the transaction occurred.
      • credit_card_id: Links transaction to a credit card.
      • merchant_id: Links transaction to a merchant.
      • Optional: Location, currency, amount, transaction type.
  2. Credit Cards Table
    • Represents unique credit cards in the system.
    • Key attributes:
      • credit_card_id: Unique identifier.
      • cc_open_date: Date when the card was issued.
      • cc_close_date: Date when the card was closed (if applicable).
      • Optional: Credit limit, APR, fraud risk score.
  3. Fraud Reports Table
    • Stores fraud labels for transactions.
    • Key attributes:
      • transaction_id: Links to the transaction flagged as fraudulent.
      • timestamp: When the fraud report was filed.
      • label: 1 if fraudulent, 0 if legitimate.

Additional Tables (Optional)

  • Users Table: Links credit cards to customers.
  • User Stats Table: Stores aggregated stats like transaction count and total spend.
  • Merchants Table: Stores merchant details (for example, category, location, or risk rating).

Entity Relationship Diagram (ERD)

Predictive Query for Credit Card Fraud Detection

A predictive query (PQL) tells Kumo what to predict and for which entity. The examples below cover three common fraud detection targets.

1. Transaction-Level Fraud Detection

Predict whether a transaction is fraudulent based on past fraud reports:

PREDICT transactions.LABEL
FOR EACH transactions.transaction_id
  • When scoring new transactions, leave LABEL empty: Kumo generates a fraud risk score for each.

2. Time-Based Fraud Prediction

Predict whether a fraud report will be linked to a transaction in the next 30 days. The ASSUMING clause filters predictions to transactions that already have at least one associated fraud report in that window, keeping the training set focused:

PREDICT SUM(fraud_reports.LABEL, 0, 30, days) > 0
FOR EACH transactions.transaction_id
ASSUMING COUNT(fraud_reports.*, 0, 30, days) >= 1

3. Credit Card Risk Prediction

Predict whether a credit card will be associated with fraudulent transactions in the next 7 days:

PREDICT COUNT(transactions.LABEL, 0, 7, days) >= 1
FOR EACH credit_cards.credit_card_id
ASSUMING COUNT(transactions.LABEL, 0, 7, days) >= 1

Deployment Strategy

1. Batch Predictions for Fraud Analysts

  • Fraud teams review high-risk transactions flagged by the model.
  • Predictions are generated hourly or daily in batch mode.
  • Fraud analysts label new fraudulent transactions, which can be fed back to improve the model over time.

To limit batch predictions to recent transactions, add a timestamp filter to your predictive query:

WHERE transactions.TIMESTAMP > MIN_TIMESTAMP

2. Real-Time Fraud Detection

  • The system generates instant fraud risk scores when a transaction occurs.
  • High-risk transactions can trigger manual review or two-factor authentication.
  • Model embeddings can also enhance existing rule-based fraud detection pipelines.

Building Models with the Kumo Fine-Tune SDK

1. Initialize the Kumo Fine-Tune SDK

1import kumoai as kumo
2
3kumo.init(url="https://<customer_id>.kumoai.cloud/api", api_key=API_KEY)

2. Connect data

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

3. Select tables

1credit_cards = kumo.Table.from_source_table(
2 source_table=connector.table('credit_cards'),
3 primary_key='credit_card_id',
4).infer_metadata()
5
6transactions = kumo.Table.from_source_table(
7 source_table=connector.table('transactions'),
8 time_column='timestamp',
9).infer_metadata()
10
11fraud_reports = kumo.Table.from_source_table(
12 source_table=connector.table('fraud_reports'),
13 time_column='timestamp',
14).infer_metadata()

4. Create graph schema

1graph = kumo.Graph(
2 tables={
3 'credit_cards': credit_cards,
4 'transactions': transactions,
5 'fraud_reports': fraud_reports,
6 },
7 edges=[
8 dict(src_table='transactions', fkey='credit_card_id', dst_table='credit_cards'),
9 dict(src_table='fraud_reports', fkey='transaction_id', dst_table='transactions'),
10 ],
11)
12
13graph.validate(verbose=True)

5. Train the model

The training table is generated asynchronously (non_blocking=True), while trainer.fit waits for training to complete before returning (non_blocking=False).

1pquery = kumo.PredictiveQuery(
2 graph=graph,
3 query="PREDICT transactions.LABEL FOR EACH transactions.transaction_id"
4)
5pquery.validate(verbose=True)
6
7model_plan = pquery.suggest_model_plan()
8trainer = kumo.Trainer(model_plan)
9training_job = trainer.fit(
10 graph=graph,
11 train_table=pquery.generate_training_table(non_blocking=True),
12 non_blocking=False,
13)
14print(f"Training metrics: {training_job.metrics()}")