Kossisoroyce commited on
Commit
e5b9453
Β·
verified Β·
1 Parent(s): 6e8e794

Update README.md (#2)

Browse files

- Update README.md (a422c819d86a6d921c2da1ccc1e94c3c7c0afe28)

Files changed (1) hide show
  1. README.md +334 -46
README.md CHANGED
@@ -7,49 +7,337 @@ tags:
7
  size_categories:
8
  - 1M<n<10M
9
  ---
10
- # Nigerian Financial Fraud Detection Dataset
11
-
12
- ## Dataset Description
13
-
14
- This is a high-quality, synthetic, 5 Million row dataset designed to simulate financial transactions within the Nigerian market. It is specifically contextualized to reflect realistic Nigerian transaction patterns, user behaviors, and common fraud typologies. The dataset provides a rich and nuanced resource for training and evaluating machine learning models aimed at combating financial fraud in Nigeria.
15
-
16
- ## Features / Columns
17
-
18
- The dataset contains the following columns:
19
-
20
- - **transaction_id**: A unique identifier for each transaction.
21
- - **timestamp**: The date and time of the transaction, simulating realistic Nigerian patterns (e.g., business hours, end-of-month salary periods).
22
- - **sender_account**: An anonymized, 10-digit Nigerian-style account number for the transaction originator.
23
- - **receiver_account**: An anonymized, 10-digit Nigerian-style account number for the transaction recipient.
24
- - **transaction_type**: The type of transaction (e.g., `deposit`, `withdrawal`).
25
- - **merchant_category**: A localized category for the transaction, featuring popular Nigerian merchants and services (e.g., `Jumia Purchase`, `Airtime Top-up (MTN)`, `Bet9ja Stake`).
26
- - **location**: The Nigerian city where the transaction took place.
27
- - **device_used**: The type of device used for the transaction (e.g., `mobile`, `pos`, `atm`).
28
- - **is_fraud**: A boolean flag indicating if the transaction is fraudulent (`True`) or legitimate (`False`).
29
- - **fraud_type**: The specific type of fraud, if applicable, including scenarios like `Account Takeover`, `Identity Fraud`, and `Impossible Travel Fraud`.
30
- - **time_since_last_transaction**: Time elapsed since the last transaction from the same sender.
31
- - **spending_deviation_score**: A score indicating how much a transaction deviates from the user's typical spending pattern.
32
- - **velocity_score**: A score related to the frequency of transactions.
33
- - **geo_anomaly_score**: A score indicating if the transaction's location is unusual for the user.
34
- - **payment_channel**: The localized payment channel used (e.g., `USSD`, `Bank Transfer`, `Card`).
35
- - **ip_address**: A randomized IP address from a Nigerian IP range.
36
- - **device_hash**: A unique hash representing the device used for the transaction.
37
- - **amount_ngn**: The transaction amount in Nigerian Naira (NGN).
38
- - **bvn_linked**: A boolean flag indicating if the sender's account is linked to a Bank Verification Number (BVN). A `False` value is a significant risk factor.
39
- - **new_device_transaction**: A boolean flag that is `True` if the transaction was made from a device not previously associated with the sender's account.
40
- - **sender_persona**: A behavioral profile assigned to the sender (`Salary Earner`, `Student`, `Trader`) to simulate realistic spending patterns.
41
- - **geospatial_velocity_anomaly**: A boolean flag that is `True` if a transaction occurs at a location that would be physically impossible to reach in the time elapsed since the user's last transaction.
42
-
43
- ## Key Design Features
44
-
45
- - **Localized Context**: All data points, including locations, merchants, and payment channels, are tailored to the Nigerian environment.
46
- - **Behavioral Personas**: Sender accounts are assigned personas which influence their transaction amounts and frequencies, creating realistic spending patterns.
47
- - **Advanced Fraud Signals**: Includes engineered features that are critical for modern fraud detection, such as BVN linkage status, new device detection, and geospatial velocity checks.
48
- - **Realistic Timestamps**: Transaction times are biased towards typical business hours and end-of-month salary periods to mimic real-world activity.
49
-
50
- ## Potential Use Cases
51
-
52
- This dataset is ideal for:
53
- - Training and validating fraud detection models for the Nigerian financial ecosystem.
54
- - Researching region-specific fraud patterns.
55
- - Developing and testing new feature engineering techniques for fraud prevention.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  size_categories:
8
  - 1M<n<10M
9
  ---
10
+ Nigerian Financial Fraud Detection Dataset (Enhanced)
11
+
12
+ ## Overview
13
+
14
+ This is a comprehensive synthetic financial fraud detection dataset specifically engineered for the Nigerian fintech ecosystem. The dataset contains **5,000,000 transactions** with **45 advanced features** including sophisticated user behavior analytics, device intelligence, risk scoring, and temporal patterns tailored for Nigerian financial fraud detection.
15
+
16
+ ### Key Highlights
17
+
18
+ - πŸ‡³πŸ‡¬ **Nigerian-Localized**: Currency (NGN), cities, payment channels, IP ranges
19
+ - 🧠 **Advanced Features**: 30 sophisticated fraud detection features
20
+ - πŸ“Š **Production-Ready**: No data leakage, optimized for ML training
21
+ - πŸ” **Behavioral Analytics**: User personas, transaction patterns, device intelligence
22
+ - ⚑ **High-Performance**: Engineered for 5M+ transaction processing
23
+
24
+ ## Dataset Statistics
25
+
26
+ - **Total Transactions**: 5,000,000
27
+ - **Total Features**: 45
28
+ - **Fraud Rate**: ~15% (realistic for emerging markets)
29
+ - **Time Span**: Simulated 12-month period
30
+ - **Unique Users**: ~500,000 sender accounts
31
+ - **Nigerian Cities**: 20 major cities across 6 geo-regions
32
+
33
+ ## Feature Categories
34
+
35
+ ### 🏦 Core Transaction Features (15 features)
36
+
37
+ - `transaction_id`: Unique transaction identifier
38
+ - `sender_account`: Anonymized 10-digit Nigerian account number
39
+ - `receiver_account`: Anonymized 10-digit Nigerian account number
40
+ - `amount_ngn`: Transaction amount in Nigerian Naira (NGN)
41
+ - `timestamp`: Transaction timestamp with Nigerian business patterns
42
+ - `payment_channel`: Nigerian payment methods (USSD, Mobile App, Card, Bank Transfer)
43
+ - `merchant_category`: Localized merchants (Jumia, MTN Airtime, Bet9ja, etc.)
44
+ - `location`: Major Nigerian cities
45
+ - `ip_address`: IP addresses from Nigerian IP ranges
46
+ - `device_hash`: Anonymized device identifier
47
+ - `is_fraud`: Binary fraud label (0=legitimate, 1=fraud)
48
+ - `fraud_type`: Specific fraud categories (Account Takeover, Identity Fraud, etc.)
49
+ - `bvn_linked`: Bank Verification Number linkage status
50
+ - `sender_persona`: Behavioral profile (Salary Earner, Student, Trader)
51
+ - `geospatial_velocity_anomaly`: Impossible travel pattern flag
52
+
53
+ ### πŸ‘€ User Behavior Features (5 features)
54
+
55
+ - `user_avg_txn_amt`: Average transaction amount per user (expanding window)
56
+ - `user_std_txn_amt`: Standard deviation of user's transaction amounts
57
+ - `user_top_category`: Most frequent merchant category per user
58
+ - `user_txn_frequency_24h`: Transaction frequency indicator
59
+ - `user_txn_count_total`: Lifetime transaction count per user
60
+
61
+ ### πŸ“± Device & IP Intelligence (5 features)
62
+
63
+ - `device_seen_count`: Total transactions from each device
64
+ - `is_device_shared`: Flag for devices used by multiple users (0/1)
65
+ - `ip_seen_count`: Total transactions from each IP address
66
+ - `is_ip_shared`: Flag for IPs used by multiple users (0/1)
67
+ - `ip_geo_region`: Nigerian geo-region (South West, North Central, etc.)
68
+
69
+ ### πŸ“ˆ Transaction History/Window Features (4 features)
70
+
71
+ - `txn_count_last_1h`: Recent transaction count (expanding window)
72
+ - `txn_count_last_24h`: 24-hour transaction count (expanding window)
73
+ - `total_amount_last_1h`: Sum of recent transactions (expanding window)
74
+ - `avg_gap_between_txns`: Average time between user transactions (minutes)
75
+
76
+ ### ⚠️ Risk Scoring Fields (4 features)
77
+
78
+ - `merchant_fraud_rate`: Historical fraud rate per merchant category (no leakage)
79
+ - `channel_risk_score`: Risk score by payment channel (USSD=0.8, Mobile=0.6, etc.)
80
+ - `persona_fraud_risk`: Risk by user persona (Trader=0.7, Student=0.5, etc.)
81
+ - `location_fraud_risk`: Historical fraud rate per Nigerian city (no leakage)
82
+
83
+ ### πŸ• Temporal Features (4 features)
84
+
85
+ - `txn_hour`: Transaction hour (0-23)
86
+ - `is_weekend`: Weekend transaction flag (0/1)
87
+ - `is_salary_week`: Last 5 days of month flag (0/1)
88
+ - `is_night_txn`: Night transaction flag 11pm-5am (0/1)
89
+
90
+ ### πŸ”§ Technical Features (8 features)
91
+
92
+ - `new_device_for_sender`: First-time device usage flag
93
+ - `shared_device_hash`: Device used by multiple accounts
94
+ - `time_since_last`: Minutes since user's last transaction
95
+ - Various derived flags and indicators
96
+
97
+ ## Nigerian Localization Details
98
+
99
+ ### πŸ™οΈ Geographic Coverage
100
+
101
+ **6 Nigerian Geo-Regions Represented:**
102
+
103
+ - **South West**: Lagos, Ibadan, Abeokuta, Oyo, Ogbomoso
104
+ - **North Central**: Abuja, Jos, Ilorin, Okene
105
+ - **North West**: Kano, Zaria, Kaduna, Sokoto
106
+ - **South South**: Port Harcourt, Benin City, Warri
107
+ - **South East**: Aba, Enugu, Onitsha
108
+ - **North East**: Maiduguri
109
+
110
+ ### πŸ’³ Payment Channels (Risk-Weighted)
111
+
112
+ - **USSD** (Risk: 0.8) - Most common, highest fraud risk
113
+ - **Mobile App** (Risk: 0.6) - Moderate risk
114
+ - **Card** (Risk: 0.4) - Lower risk
115
+ - **Bank Transfer** (Risk: 0.3) - Lowest risk
116
+
117
+ ### πŸ›’ Merchant Categories (Nigerian Context)
118
+
119
+ - Jumia Purchase, Konga Shopping, MTN Airtime Top-up
120
+ - Airtel Data Bundle, Bet9ja Stake, NairaBet Gaming
121
+ - Uber Ride, Bolt Transport, Flutterwave Payment
122
+ - Paystack Transaction, Opay Transfer, PalmPay Service
123
+ - And 10+ other Nigerian-specific merchants
124
+
125
+ ### πŸ‘₯ User Personas (Behavioral Profiles)
126
+
127
+ - **Salary Earner** (Risk: 0.4): Regular monthly patterns, moderate amounts
128
+ - **Student** (Risk: 0.5): Small frequent transactions, education-related
129
+ - **Trader** (Risk: 0.7): High-volume, irregular patterns, higher risk
130
+
131
+ ## Fraud Types and Scenarios
132
+
133
+ ### 🚨 Fraud Categories Included
134
+
135
+ 1. **Account Takeover**: Compromised accounts with unusual patterns
136
+ 2. **Identity Fraud**: Fake accounts, unlinked BVN
137
+ 3. **Impossible Travel Fraud**: Geospatial velocity anomalies
138
+ 4. **SIM Swap Fraud**: Device changes with suspicious activity
139
+ 5. **Card-Not-Present**: Online fraud without physical card
140
+ 6. **Deposit Fraud**: Fake deposit schemes
141
+ 7. **Money Laundering**: Structured transactions, unusual patterns
142
+
143
+ ### 🎯 Fraud Detection Signals
144
+
145
+ - BVN linkage status (unlinked = higher risk)
146
+ - New device usage patterns
147
+ - Shared device/IP indicators
148
+ - Geospatial velocity anomalies
149
+ - Off-hours transaction patterns
150
+ - Unusual merchant category combinations
151
+ - Rapid transaction sequences
152
+
153
+ ## Technical Implementation
154
+
155
+ ### πŸ”’ Data Privacy & Security
156
+
157
+ - All account numbers are randomly generated (no real accounts)
158
+ - Device hashes are anonymized identifiers
159
+ - IP addresses are from public Nigerian ranges
160
+ - No personally identifiable information (PII) included
161
+
162
+ ### πŸ“Š Feature Engineering Methodology
163
+
164
+ - **No Data Leakage**: Risk scores use expanding windows with `.shift(1)`
165
+ - **Temporal Consistency**: Features computed chronologically
166
+ - **Performance Optimized**: Efficient groupby operations for 5M+ rows
167
+ - **Realistic Patterns**: Based on Nigerian fintech transaction behaviors
168
+
169
+ ### πŸ”„ Rolling Window Logic
170
+
171
+ ```python
172
+ # Example: Merchant fraud rate without leakage
173
+ merchant_fraud_rate = df.groupby('merchant_category')['is_fraud']
174
+ .transform(lambda x: x.expanding().mean().shift(1).fillna(0.1))
175
+ ```
176
+
177
+ ## Use Cases & Applications
178
+
179
+ ### 🎯 Primary Use Cases
180
+
181
+ 1. **Fraud Detection Model Training**: Supervised learning with rich feature set
182
+ 2. **Risk Scoring System Development**: Real-time transaction scoring
183
+ 3. **Behavioral Analytics**: User pattern analysis and segmentation
184
+ 4. **Anomaly Detection**: Unsupervised fraud detection research
185
+ 5. **Nigerian Fintech Research**: Emerging market fraud patterns
186
+
187
+ ### 🏒 Target Industries
188
+
189
+ - Nigerian fintech companies (Flutterwave, Paystack, Opay, etc.)
190
+ - Traditional banks expanding digital services
191
+ - Fraud detection technology vendors
192
+ - Academic research institutions
193
+ - Regulatory bodies and compliance teams
194
+
195
+ ### πŸ“ˆ Model Performance Expectations
196
+
197
+ - **Baseline Accuracy**: 85-90% with basic features
198
+ - **Enhanced Accuracy**: 92-95% with advanced features
199
+ - **Precision/Recall**: Optimized for Nigerian fraud patterns
200
+ - **Real-time Scoring**: Features designed for low-latency inference
201
+
202
+ ## Data Quality & Validation
203
+
204
+ ### βœ… Quality Assurance
205
+
206
+ - **Completeness**: No missing values in critical features
207
+ - **Consistency**: Logical relationships maintained across features
208
+ - **Realism**: Patterns based on Nigerian financial behaviors
209
+ - **Balance**: Appropriate fraud/legitimate transaction ratio
210
+
211
+ ### πŸ” Validation Metrics
212
+
213
+ - Transaction amounts follow realistic Nigerian distributions
214
+ - Temporal patterns align with Nigerian business hours
215
+ - Geographic distribution matches Nigerian population centers
216
+ - Fraud patterns consistent with emerging market trends
217
+
218
+ ## Limitations & Considerations
219
+
220
+ ### ⚠️ Important Limitations
221
+
222
+ 1. **Synthetic Data**: Not real transactions, patterns may differ from reality
223
+ 2. **Temporal Scope**: Limited to 12-month simulation period
224
+ 3. **Feature Completeness**: May not capture all real-world fraud signals
225
+ 4. **Regional Focus**: Specific to Nigerian context, may not generalize
226
+ 5. **Fraud Evolution**: Real fraud patterns evolve faster than synthetic data
227
+
228
+ ### 🎯 Recommended Usage
229
+
230
+ - Use as training data supplement, not replacement for real data
231
+ - Validate model performance on real Nigerian transaction data
232
+ - Regular model retraining as fraud patterns evolve
233
+ - Combine with external data sources for production systems
234
+
235
+ ## Technical Specifications
236
+
237
+ ### πŸ“‹ File Details
238
+
239
+ - **Format**: CSV (Comma-separated values)
240
+ - **Size**: ~2.5GB uncompressed
241
+ - **Encoding**: UTF-8
242
+ - **Delimiter**: Comma (,)
243
+ - **Header**: Yes (first row contains column names)
244
+
245
+ ### πŸ”§ System Requirements
246
+
247
+ - **Memory**: 8GB+ RAM recommended for full dataset loading
248
+ - **Storage**: 5GB+ available space
249
+ - **Processing**: Multi-core CPU recommended for feature engineering
250
+ - **Software**: Python 3.7+, pandas 1.3+, numpy 1.20+
251
+
252
+ ## Getting Started
253
+
254
+ ### πŸ“š Quick Start Example
255
+
256
+ ```python
257
+ import pandas as pd
258
+ import numpy as np
259
+ from sklearn.ensemble import RandomForestClassifier
260
+ from sklearn.model_selection import train_test_split
261
+
262
+ # Load the dataset
263
+ df = pd.read_csv('financial_fraud_detection_dataset_nigeria.csv')
264
+
265
+ # Basic exploration
266
+ print(f"Dataset shape: {df.shape}")
267
+ print(f"Fraud rate: {df['is_fraud'].mean():.2%}")
268
+ print(f"Features: {df.columns.tolist()}")
269
+
270
+ # Feature selection for modeling
271
+ feature_cols = [col for col in df.columns if col not in ['transaction_id', 'is_fraud', 'fraud_type']]
272
+ X = df[feature_cols]
273
+ y = df['is_fraud']
274
+
275
+ # Train/test split
276
+ X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
277
+
278
+ # Simple model training
279
+ model = RandomForestClassifier(n_estimators=100, random_state=42)
280
+ model.fit(X_train, y_train)
281
+
282
+ # Evaluate
283
+ accuracy = model.score(X_test, y_test)
284
+ print(f"Model accuracy: {accuracy:.2%}")
285
+ ```
286
+
287
+ ### 🎯 Advanced Analytics Examples
288
+
289
+ ```python
290
+ # Analyze fraud patterns by region
291
+ region_fraud = df.groupby('ip_geo_region')['is_fraud'].agg(['count', 'mean'])
292
+ print("Fraud rates by Nigerian region:")
293
+ print(region_fraud)
294
+
295
+ # User behavior analysis
296
+ user_stats = df.groupby('sender_persona').agg({
297
+ 'amount_ngn': ['mean', 'std'],
298
+ 'is_fraud': 'mean',
299
+ 'user_txn_count_total': 'mean'
300
+ })
301
+ print("\nUser persona analysis:")
302
+ print(user_stats)
303
+
304
+ # Temporal fraud patterns
305
+ temporal_fraud = df.groupby(['txn_hour', 'is_weekend'])['is_fraud'].mean()
306
+ print("\nTemporal fraud patterns:")
307
+ print(temporal_fraud)
308
+ ```
309
+
310
+ ## Citation & Attribution
311
+
312
+ ### πŸ“„ Recommended Citation
313
+
314
+ ```
315
+ Nigerian Financial Fraud Detection Dataset (Enhanced)
316
+ Synthetic dataset for fraud detection research in Nigerian fintech
317
+ Generated: 2024
318
+ Features: 45 advanced fraud detection features
319
+ Transactions: 5,000,000 synthetic transactions
320
+ ```
321
+
322
+ ### 🏷️ Tags
323
+
324
+ `fraud-detection` `nigeria` `fintech` `machine-learning` `synthetic-data` `behavioral-analytics` `risk-scoring` `emerging-markets` `financial-crime` `anomaly-detection`
325
+
326
+ ## Support & Updates
327
+
328
+ ### πŸ“ž Contact Information
329
+
330
+ For questions, issues, or collaboration opportunities regarding this dataset, please refer to the project documentation or contact the development team.
331
+
332
+ ### πŸ”„ Version History
333
+
334
+ - **v2.0** (Current): Enhanced with 30 advanced features, Nigerian localization
335
+ - **v1.0**: Basic fraud detection dataset with core features
336
+
337
+ ### πŸš€ Future Enhancements
338
+
339
+ - Transaction network analysis features
340
+ - Additional Nigerian payment channels
341
+ - Seasonal fraud pattern variations
342
+ - Enhanced merchant category coverage
343
+ - Real-time streaming data simulation