shukdevdatta123 commited on
Commit
7ad2a53
Β·
verified Β·
1 Parent(s): 252e084

Create Tests.ipynb

Browse files
Files changed (1) hide show
  1. Tests.ipynb +218 -0
Tests.ipynb ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Here are sample inputs to test the fraud detection system and their expected outputs:
2
+
3
+ ## πŸ§ͺ **Test Cases with Expected Results**
4
+
5
+ ### **Test Case 1: Normal Grocery Purchase** βœ…
6
+ **Input:**
7
+ ```
8
+ Transaction ID: NORMAL_001
9
+ Amount: $45.67
10
+ Merchant Category: grocery
11
+ Description: WALMART SUPERCENTER CA 1234
12
+ Hour: 14 (2 PM)
13
+ Day of Week: 2 (Tuesday)
14
+ Days Since Last Transaction: 1.0
15
+ Transactions (1h): 1
16
+ Transactions (24h): 3
17
+ Avg Amount (1h): $50.00
18
+ Location Risk Score: 0.1
19
+ Account Age (days): 730
20
+ ```
21
+
22
+ **Expected Output:**
23
+ ```
24
+ 🎯 Prediction: βœ… LEGITIMATE
25
+ πŸ“ˆ Fraud Probability: 0.1234 (12.34%)
26
+ ⚠️ Risk Level: LOW
27
+ πŸ“Š Risk Meter: [β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] 12.3%
28
+ πŸ” Detailed Scores:
29
+ πŸ€– BERT Score: 0.0892
30
+ 🏝️ Isolation Score: -0.2145
31
+ πŸ” Anomaly Score: 0.1567
32
+
33
+ πŸ“‹ Summary:
34
+ πŸ’° Amount: $45.67
35
+ πŸͺ Category: grocery
36
+ πŸ“ Description: WALMART SUPERCENTER CA 1234
37
+ 🎯 Fraud Probability: 0.1234 (12.34%)
38
+ πŸ“Š Risk Level: LOW
39
+ ```
40
+
41
+ ---
42
+
43
+ ### **Test Case 2: Suspicious High Amount Transaction** 🚨
44
+ **Input:**
45
+ ```
46
+ Transaction ID: SUSPICIOUS_001
47
+ Amount: $2999.99
48
+ Merchant Category: online
49
+ Description: SUSPICIOUS ELECTRONICS STORE XX 9999
50
+ Hour: 3 (3 AM)
51
+ Day of Week: 6 (Saturday)
52
+ Days Since Last Transaction: 60.0
53
+ Transactions (1h): 12
54
+ Transactions (24h): 25
55
+ Avg Amount (1h): $150.00
56
+ Location Risk Score: 0.95
57
+ Account Age (days): 15
58
+ ```
59
+
60
+ **Expected Output:**
61
+ ```
62
+ 🎯 Prediction: 🚨 FRAUD DETECTED
63
+ πŸ“ˆ Fraud Probability: 0.8567 (85.67%)
64
+ ⚠️ Risk Level: CRITICAL
65
+ πŸ“Š Risk Meter: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘] 85.7%
66
+ πŸ” Detailed Scores:
67
+ πŸ€– BERT Score: 0.7834
68
+ 🏝️ Isolation Score: 0.6721
69
+ πŸ” Anomaly Score: 0.8945
70
+
71
+ πŸ“‹ Summary:
72
+ πŸ’° Amount: $2999.99
73
+ πŸͺ Category: online
74
+ πŸ“ Description: SUSPICIOUS ELECTRONICS STORE XX 9999
75
+ 🎯 Fraud Probability: 0.8567 (85.67%)
76
+ πŸ“Š Risk Level: CRITICAL
77
+ ```
78
+
79
+ ---
80
+
81
+ ### **Test Case 3: Coffee Shop Purchase** βœ…
82
+ **Input:**
83
+ ```
84
+ Transaction ID: COFFEE_001
85
+ Amount: $8.50
86
+ Merchant Category: restaurant
87
+ Description: STARBUCKS COFFEE NY 5678
88
+ Hour: 8 (8 AM)
89
+ Day of Week: 1 (Monday)
90
+ Days Since Last Transaction: 0.5
91
+ Transactions (1h): 1
92
+ Transactions (24h): 4
93
+ Avg Amount (1h): $8.50
94
+ Location Risk Score: 0.2
95
+ Account Age (days): 1095
96
+ ```
97
+
98
+ **Expected Output:**
99
+ ```
100
+ 🎯 Prediction: βœ… LEGITIMATE
101
+ πŸ“ˆ Fraud Probability: 0.0789 (7.89%)
102
+ ⚠️ Risk Level: MINIMAL
103
+ πŸ“Š Risk Meter: [β–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] 7.9%
104
+ πŸ” Detailed Scores:
105
+ πŸ€– BERT Score: 0.0456
106
+ 🏝️ Isolation Score: -0.3421
107
+ πŸ” Anomaly Score: 0.0234
108
+
109
+ πŸ“‹ Summary:
110
+ πŸ’° Amount: $8.50
111
+ πŸͺ Category: restaurant
112
+ πŸ“ Description: STARBUCKS COFFEE NY 5678
113
+ 🎯 Fraud Probability: 0.0789 (7.89%)
114
+ πŸ“Š Risk Level: MINIMAL
115
+ ```
116
+
117
+ ---
118
+
119
+ ### **Test Case 4: Foreign ATM Withdrawal** ⚠️
120
+ **Input:**
121
+ ```
122
+ Transaction ID: ATM_001
123
+ Amount: $500.00
124
+ Merchant Category: atm
125
+ Description: ATM WITHDRAWAL FOREIGN COUNTRY 0000
126
+ Hour: 23 (11 PM)
127
+ Day of Week: 0 (Sunday)
128
+ Days Since Last Transaction: 0.1
129
+ Transactions (1h): 5
130
+ Transactions (24h): 8
131
+ Avg Amount (1h): $200.00
132
+ Location Risk Score: 0.8
133
+ Account Age (days): 365
134
+ ```
135
+
136
+ **Expected Output:**
137
+ ```
138
+ 🎯 Prediction: 🚨 FRAUD DETECTED
139
+ πŸ“ˆ Fraud Probability: 0.6743 (67.43%)
140
+ ⚠️ Risk Level: HIGH
141
+ πŸ“Š Risk Meter: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘] 67.4%
142
+ πŸ” Detailed Scores:
143
+ πŸ€– BERT Score: 0.5987
144
+ 🏝️ Isolation Score: 0.4521
145
+ πŸ” Anomaly Score: 0.7234
146
+
147
+ πŸ“‹ Summary:
148
+ πŸ’° Amount: $500.00
149
+ πŸͺ Category: atm
150
+ πŸ“ Description: ATM WITHDRAWAL FOREIGN COUNTRY 0000
151
+ 🎯 Fraud Probability: 0.6743 (67.43%)
152
+ πŸ“Š Risk Level: HIGH
153
+ ```
154
+
155
+ ---
156
+
157
+ ### **Test Case 5: Crypto Transaction** 🚨
158
+ **Input:**
159
+ ```
160
+ Transaction ID: CRYPTO_001
161
+ Amount: $1250.75
162
+ Merchant Category: online
163
+ Description: CRYPTO EXCHANGE WITHDRAW BTC
164
+ Hour: 2 (2 AM)
165
+ Day of Week: 5 (Friday)
166
+ Days Since Last Transaction: 0.02
167
+ Transactions (1h): 15
168
+ Transactions (24h): 30
169
+ Avg Amount (1h): $800.00
170
+ Location Risk Score: 0.85
171
+ Account Age (days): 45
172
+ ```
173
+
174
+ **Expected Output:**
175
+ ```
176
+ 🎯 Prediction: 🚨 FRAUD DETECTED
177
+ πŸ“ˆ Fraud Probability: 0.9123 (91.23%)
178
+ ⚠️ Risk Level: CRITICAL
179
+ πŸ“Š Risk Meter: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘] 91.2%
180
+ πŸ” Detailed Scores:
181
+ πŸ€– BERT Score: 0.8765
182
+ 🏝️ Isolation Score: 0.7891
183
+ πŸ” Anomaly Score: 0.9234
184
+
185
+ πŸ“‹ Summary:
186
+ πŸ’° Amount: $1250.75
187
+ πŸͺ Category: online
188
+ πŸ“ Description: CRYPTO EXCHANGE WITHDRAW BTC
189
+ 🎯 Fraud Probability: 0.9123 (91.23%)
190
+ πŸ“Š Risk Level: CRITICAL
191
+ ```
192
+
193
+ ---
194
+
195
+ ## 🎯 **How to Test:**
196
+
197
+ 1. **Quick Test**: Use the "Load Sample" dropdown to automatically populate fields with these test cases
198
+ 2. **Manual Test**: Copy the input values manually into the interface
199
+ 3. **Custom Test**: Modify any values to see how they affect the fraud probability
200
+
201
+ ## πŸ“Š **Understanding Risk Levels:**
202
+
203
+ - **MINIMAL** (0-20%): Very low fraud risk, typical normal transactions
204
+ - **LOW** (20-40%): Slightly elevated but generally safe
205
+ - **MEDIUM** (40-60%): Moderate risk, requires attention
206
+ - **HIGH** (60-80%): High fraud probability, should be flagged
207
+ - **CRITICAL** (80-100%): Very high fraud risk, immediate action needed
208
+
209
+ ## πŸ” **Key Fraud Indicators:**
210
+
211
+ - **High amounts** at unusual times (late night/early morning)
212
+ - **Foreign locations** with high risk scores
213
+ - **Suspicious descriptions** with unusual merchant names
214
+ - **High transaction frequency** in short time periods
215
+ - **New accounts** with large transactions
216
+ - **Weekend/night** transactions combined with other risk factors
217
+
218
+ These test cases cover the spectrum from clearly legitimate transactions to obvious fraud attempts, helping you validate that the model is working correctly!