Use Case

February 20, 2024

Online Fraud Analytics Python Use Case

Get to know how to create a data story for Fraud Analytics to reduce fraudulent transactions.

Fraud is a big problem for banks and financial institutions. Every year, billions of dollars are lost to fraudsters who find ways to exploit weaknesses in the system.

Digital fraud is the banking sector's primary challenge, leading to immense losses every year. As per McAfee's reports, cyber fraud currently damages the economy by USD 600 billion of GDP on a global basis.

But, How does this number feel so relevant? Because tons of data flows in daily, and guess whose job it is to track and report it to stakeholders like the Chief Financial Officer? 

It’s us Data Analysts!

Here, Data Analysis is not about just a Number; But a proven business solution which talks about the Charts, real time numbers and data driven insights.

In this python use case, we’ll talk about the Goals, Challenges and Objectives of the  Chief Financial Officer to provide meaningful insights they crave for.

Let’s get started!

About Dataset

Let’s Inspect our Fraud Analytics dataset. This dataset got all the deeds on transaction – transaction IDs, completion dates, types, subtypes, payment service providers (PSP), cities, amounts.

This dataset encompasses a variety of dimensions including temporal, financial, geographical, technical, and behavioral aspects of transactions, making it a potent resource for identifying and understanding fraudulent activities in financial systems. Here are some sample Rows & Columns of the Fraud Analytics Dataset.

Transaction Table
txn_id dt_txn_comp txn_comp_time txn_type txn_subtype initiating_channel_id txn_status error_code payer_psp payee_psp payee_state
1 2021-06-22 8:40:00 PM Fee Transaction Fee 6 Successful Axis Pay Google Pay for Business Uttar Pradesh
2 2023-06-02 8:36:00 AM Payment Peer-to-Peer (P2P) 18 Successful PhonePe PhonePe for Merchants Karnataka
3 2021-12-12 10:26:00 PM Reversal Transaction Error Correction 16 On Hold U66 Amazon Pay HDFC Merchant Services Uttarakhand
4 2023-05-05 8:34:00 AM Withdrawal ATM Withdrawal 16 Successful Apple Pay (for international transactions) ICICI Merchant Services Goa

Payment Details Table
payer_os_type payee_os_type beneficiary_mcc_code remitter_mcc_code custref_transaction_ref cred_type cred_subtype payer_app_id payee_app_id
Others Others 5945 7995 Reference 1 Credit Card Balance Transfer Credit Card BHIM IOB UPI JustDial
iOS Android 5099 7395 Reference 2 Credit Card Balance Credit Card MI Pay Digibank (DBS)
Others MacOS 5996 5598 Reference 3 Home Loan Fixed-Rate Mortgage BHIM Axis Pay UPI App BHIM Baroda PAY
Windows MacOS 7692 5963 Reference 4 Home Loan Adjustable-Rate Mortgage (ARM) BHIM Cent UPI(Central Bank of India) WhatsApp Pay

Banking Transaction Details
beneficiary_bank payer_handle payer_app payee_handle payee_app payee_requested_amount payee_settlement_amount payer_location payer_city
Suryoday Small Finance Bank ANDB Bhim Andhra Bank One- UPI App EQUITAS Equitas UPI 19934 19934 700124 Barasat
Bank of India POCKETS ICICI Pockets YESPAY JusPay Technologies 62332 62332 332001 Sikar
Karur Vysya Bank DNSBANK DNS Pay (Dombivli Nagrik Sahakari Bank Ltd) FINOBANK Fino Bpay(Fino Payments Bank) 56336 56336 332001 Sikar
Cosmos Co-operative Bank YBL PhonePe UCO BHIM UCO UPI 89722 89722 825301 Hazaribagh

Here's a brief overview of the first few columns to set the stage for our analysis:

Transaction Information
Transaction Information
Field Name Data Type Description
txn_id String Unique identifier for each transaction.
dt_txn_comp Date Date when the transaction was completed.
txn_comp_time Time Time when the transaction was completed.
txn_type String Type of transaction (withdrawal, deposit, etc.).
txn_subtype String Further classification of the transaction type.
initiating_channel_id String ID of the channel used to initiate the transaction.
txn_status String Status of the transaction (completed, pending, failed).
error_code String Error codes encountered during the transaction.
payer_psp String Payment Service Provider for the payer.
payee_psp String Payment Service Provider for the payee.
remitter_bank String Bank of the sender.
beneficiary_bank String Bank of the recipient.
payer_handle String Identifier for the payer, potentially anonymized.
payer_app String Application through which the payer initiated the transaction.
payee_handle String Identifier for the payee, potentially anonymized.
payee_app String Application used by the payee.

Check Fraud Analytics Dataset to view all Columns 👉 Click Here

The Fraud Analytics Dataset contains over 50,000 Rows of transactions and 34 Distinct Columns. 30 of our Columns have String Data type, 2 of our Columns have Numeric Data Type and 2 of the columns have Date & Time Data Type.

How to Improve Real-time Fraud Detection & Prevention System?

To start with the analysis of fraud detection & prevention system, it is necessary to follow the 4 factors of Data Analysis and that are : 

  • 1. Identify the users or stakeholders for the dashboard.
  • 2. Design Empathy Map to define Users' Goals and Challenges or pain points.
  • 3. Identify Metrics or KPIs Matter the Most.
  • 4. Understand the Objectives and Goals.
  • 5. Ask Business Questions

In this article, we will explore how to improve such a system through a user-focused approach, taking the Chief Finance Officer (CFO) as a primary stakeholder.

Step 1: Identify the users or stakeholders for the analysis.

Define the User or stakeholder who will use the supply chain data story. In our case, We’ll use a Chief Finance Officer (CFO). Recognizing their diverse needs, challenges, and priorities becomes the cornerstone for tailoring an effective data story. 

User Persona : Chief Finance Officer

  • Ensure the overall financial integrity of the organization & Safeguard financial assets against fraud activities.
  • Make informed and strategic decisions based on accurate financial information.
  • Evaluate risks and opportunities to support the organization's financial goals.
  • Implement policies and procedures to mitigate legal and financial risks.
  • Optimize resource allocation to maximize financial efficiency.
  • Allocate budgets strategically to support business objectives.

  • Access to real-time and accurate financial data for effective decision-making.
  • Intuitive and user-friendly dashboards and tools for efficient monitoring and analysis.
  • Advanced fraud detection systems that provide proactive alerts and mitigation strategies.
  • Insights into emerging financial trends, risks, and opportunities to support strategic planning.

  • Constantly evolving fraud tactics and increasing sophistication of cyber threats.
  • Minimizing false positives in fraud detection to avoid unnecessary disruption to legitimate transactions.
  • Managing financial security within budgetary constraints and ensuring cost-effectiveness.

Since, we have defined the User Persona & have mapped the needs, challenges and responsibilities. Our Next step will be to design an Empathy Map which will map the pain points of the user.

Step 2: Design Empathy Map

Understanding the CFO's perspective is crucial for designing an effective fraud detection system. An empathy map helps us delve into their thoughts and feelings, allowing us to tailor the system to meet their specific needs.

Step 3: Identify the Key Performance Indicators (KPI’s)

Numbers tell a story. To gauge the effectiveness of a system, focus on metrics and Key Performance Indicators (KPIs) that truly matter. For fraud detection and prevention, consider:

KPI/Measure Drill Down Dimensions Purpose
Fraud Loss Value Transaction type, Geographical location, Time period Measure monetary impact, quantify financial losses due to fraud.
Number of Fraud Incidents Transaction Type, Remitter Bank, Geographical location Quantify frequency of fraudulent incidents, assess scale of the problem.
Fraud Transaction Rate Type of transactions Calculate percentage of fraudulent transactions, identify trends.
Geospatial Distribution Payer location (city, state), Payee location (city, state) Analyze geographical spread of fraud, target high-risk areas.
User Behavior Payer OS Type, Time of day, Payer payment service provider (PSP) Monitor patterns in user behavior, detect anomalies for improved security.

Step 4: Understand the Goals & Objectives of User

Now, on the basis of Empathy Map and KPI’s, we need to define our goals and objectives of the Users. So, that it will align with the data story functionalities to ensure decision making. Here are the Key Objectives & Goals : 

Objective :

To enhance the security of financial transactions by employing advanced data analysis techniques. This includes real-time monitoring, anomaly detection, and proactive measures to identify, investigate, and mitigate potential instances of credit card fraud, thereby safeguarding the financial system's integrity.

Goals :

To optimize resource utilization for enhanced operational efficiency and profitability, support strategic initiatives by planning finance and investment decisions, minimize financial, fraud, and operational risks to safeguard assets and reputation.

Step 5 : Ask Business Questions

Beyond KPI’s, organizations must engage in business-driven inquiry. This involves asking strategic questions that directly align with overarching business objectives. 

Ask the following questions:

1. How have fraud incidents fluctuated over the years?

Python Code : 

Metrics : Time Period, Volume Metric

Actionable Insight : 

  • The graph shows a clear pattern of fraud incidents with constant spikes in July and August. This suggests the need for increased vigilance and preventive measures during these months. 
  • The sharp decline after June may indicate effective countermeasures, which could be replicated to mitigate future spikes.

2. Which types of Credit fraud are causing the most financial damage?

Python : 

Metrics : Credit Type, Total Amount of Fraudulent Transactions

Actionable Insight : 

  • Credit card and Personal Loan fraud represent the highest total amounts, indicating these areas are particularly high-risk.
  • Given the high amount of fraud in credit cards, there could be an opportunity to educate customers on safe credit card practices.

3. Are there certain regions more prone to fraud incidents than others?

Python : 
Visualization : 

Metrics :Total Fraudulent Transaction Amount, Payer State

Actionable Insight : 

  • States with higher fraudulent transaction amounts like Punjab, Bihar, and West Bengal may benefit from state-specific fraud prevention initiatives.
  • Punjab, showing the highest total fraudulent transaction amount, should be subjected to more rigorous monitoring and investigative activities.

4. What is the financial impact of fraud across different regions?

Python Code : 
Visualization : 

Metrics : Total Fraudulent Transaction Amount, Payer State

Actionable Insight : 

  • Haryana, Tamil Nadu, and Odisha are the top states for fraudulent transactions, indicating the need for targeted anti-fraud initiatives in these regions.

5. How does user behavior vary by time of day in terms of number of fraudulent transactions and fraudulent transaction amount?

Python Code : 
Visualization : 

Metrics : Time of Day, Percentage of Total Fraudulent Transaction Amount

Actionable Insight : 

  • The largest share of fraudulent transactions occurs at night (31.0%), suggesting that fraudsters may prefer times when oversight may be lower and victims less vigilant.


Enhancing our real-time fraud detection and prevention system transcends the realm of technical challenges—it's a collaborative effort.

We need to understand what the CFO worries about and ask the right questions. This way, we can create a system that not only meets but beats the CFO's expectations. That's how we keep our organization's finances safe in today's digital world.

Ready to get started?

Join Data Analysts who use Super AI to build world‑class real‑time data experiences.

Request Early Access