File size: 5,668 Bytes
7ad2a53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
Here are sample inputs to test the fraud detection system and their expected outputs:

## πŸ§ͺ **Test Cases with Expected Results**

### **Test Case 1: Normal Grocery Purchase** βœ…
**Input:**
```
Transaction ID: NORMAL_001
Amount: $45.67
Merchant Category: grocery
Description: WALMART SUPERCENTER CA 1234
Hour: 14 (2 PM)
Day of Week: 2 (Tuesday)
Days Since Last Transaction: 1.0
Transactions (1h): 1
Transactions (24h): 3
Avg Amount (1h): $50.00
Location Risk Score: 0.1
Account Age (days): 730
```

**Expected Output:**
```
🎯 Prediction: βœ… LEGITIMATE
πŸ“ˆ Fraud Probability: 0.1234 (12.34%)
⚠️ Risk Level: LOW
πŸ“Š Risk Meter: [β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] 12.3%
πŸ” Detailed Scores:
πŸ€– BERT Score: 0.0892
🏝️ Isolation Score: -0.2145
πŸ” Anomaly Score: 0.1567

πŸ“‹ Summary:
πŸ’° Amount: $45.67
πŸͺ Category: grocery
πŸ“ Description: WALMART SUPERCENTER CA 1234
🎯 Fraud Probability: 0.1234 (12.34%)
πŸ“Š Risk Level: LOW
```

---

### **Test Case 2: Suspicious High Amount Transaction** 🚨
**Input:**
```
Transaction ID: SUSPICIOUS_001
Amount: $2999.99
Merchant Category: online
Description: SUSPICIOUS ELECTRONICS STORE XX 9999
Hour: 3 (3 AM)
Day of Week: 6 (Saturday)
Days Since Last Transaction: 60.0
Transactions (1h): 12
Transactions (24h): 25
Avg Amount (1h): $150.00
Location Risk Score: 0.95
Account Age (days): 15
```

**Expected Output:**
```
🎯 Prediction: 🚨 FRAUD DETECTED
πŸ“ˆ Fraud Probability: 0.8567 (85.67%)
⚠️ Risk Level: CRITICAL
πŸ“Š Risk Meter: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘] 85.7%
πŸ” Detailed Scores:
πŸ€– BERT Score: 0.7834
🏝️ Isolation Score: 0.6721
πŸ” Anomaly Score: 0.8945

πŸ“‹ Summary:
πŸ’° Amount: $2999.99
πŸͺ Category: online
πŸ“ Description: SUSPICIOUS ELECTRONICS STORE XX 9999
🎯 Fraud Probability: 0.8567 (85.67%)
πŸ“Š Risk Level: CRITICAL
```

---

### **Test Case 3: Coffee Shop Purchase** βœ…
**Input:**
```
Transaction ID: COFFEE_001
Amount: $8.50
Merchant Category: restaurant
Description: STARBUCKS COFFEE NY 5678
Hour: 8 (8 AM)
Day of Week: 1 (Monday)
Days Since Last Transaction: 0.5
Transactions (1h): 1
Transactions (24h): 4
Avg Amount (1h): $8.50
Location Risk Score: 0.2
Account Age (days): 1095
```

**Expected Output:**
```
🎯 Prediction: βœ… LEGITIMATE
πŸ“ˆ Fraud Probability: 0.0789 (7.89%)
⚠️ Risk Level: MINIMAL
πŸ“Š Risk Meter: [β–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] 7.9%
πŸ” Detailed Scores:
πŸ€– BERT Score: 0.0456
🏝️ Isolation Score: -0.3421
πŸ” Anomaly Score: 0.0234

πŸ“‹ Summary:
πŸ’° Amount: $8.50
πŸͺ Category: restaurant
πŸ“ Description: STARBUCKS COFFEE NY 5678
🎯 Fraud Probability: 0.0789 (7.89%)
πŸ“Š Risk Level: MINIMAL
```

---

### **Test Case 4: Foreign ATM Withdrawal** ⚠️
**Input:**
```
Transaction ID: ATM_001
Amount: $500.00
Merchant Category: atm
Description: ATM WITHDRAWAL FOREIGN COUNTRY 0000
Hour: 23 (11 PM)
Day of Week: 0 (Sunday)
Days Since Last Transaction: 0.1
Transactions (1h): 5
Transactions (24h): 8
Avg Amount (1h): $200.00
Location Risk Score: 0.8
Account Age (days): 365
```

**Expected Output:**
```
🎯 Prediction: 🚨 FRAUD DETECTED
πŸ“ˆ Fraud Probability: 0.6743 (67.43%)
⚠️ Risk Level: HIGH
πŸ“Š Risk Meter: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘] 67.4%
πŸ” Detailed Scores:
πŸ€– BERT Score: 0.5987
🏝️ Isolation Score: 0.4521
πŸ” Anomaly Score: 0.7234

πŸ“‹ Summary:
πŸ’° Amount: $500.00
πŸͺ Category: atm
πŸ“ Description: ATM WITHDRAWAL FOREIGN COUNTRY 0000
🎯 Fraud Probability: 0.6743 (67.43%)
πŸ“Š Risk Level: HIGH
```

---

### **Test Case 5: Crypto Transaction** 🚨
**Input:**
```
Transaction ID: CRYPTO_001
Amount: $1250.75
Merchant Category: online
Description: CRYPTO EXCHANGE WITHDRAW BTC
Hour: 2 (2 AM)
Day of Week: 5 (Friday)
Days Since Last Transaction: 0.02
Transactions (1h): 15
Transactions (24h): 30
Avg Amount (1h): $800.00
Location Risk Score: 0.85
Account Age (days): 45
```

**Expected Output:**
```
🎯 Prediction: 🚨 FRAUD DETECTED
πŸ“ˆ Fraud Probability: 0.9123 (91.23%)
⚠️ Risk Level: CRITICAL
πŸ“Š Risk Meter: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘] 91.2%
πŸ” Detailed Scores:
πŸ€– BERT Score: 0.8765
🏝️ Isolation Score: 0.7891
πŸ” Anomaly Score: 0.9234

πŸ“‹ Summary:
πŸ’° Amount: $1250.75
πŸͺ Category: online
πŸ“ Description: CRYPTO EXCHANGE WITHDRAW BTC
🎯 Fraud Probability: 0.9123 (91.23%)
πŸ“Š Risk Level: CRITICAL
```

---

## 🎯 **How to Test:**

1. **Quick Test**: Use the "Load Sample" dropdown to automatically populate fields with these test cases
2. **Manual Test**: Copy the input values manually into the interface
3. **Custom Test**: Modify any values to see how they affect the fraud probability

## πŸ“Š **Understanding Risk Levels:**

- **MINIMAL** (0-20%): Very low fraud risk, typical normal transactions
- **LOW** (20-40%): Slightly elevated but generally safe
- **MEDIUM** (40-60%): Moderate risk, requires attention
- **HIGH** (60-80%): High fraud probability, should be flagged
- **CRITICAL** (80-100%): Very high fraud risk, immediate action needed

## πŸ” **Key Fraud Indicators:**

- **High amounts** at unusual times (late night/early morning)
- **Foreign locations** with high risk scores
- **Suspicious descriptions** with unusual merchant names
- **High transaction frequency** in short time periods
- **New accounts** with large transactions
- **Weekend/night** transactions combined with other risk factors

These test cases cover the spectrum from clearly legitimate transactions to obvious fraud attempts, helping you validate that the model is working correctly!