shukdevdatta123 commited on
Commit
5ed466d
Β·
verified Β·
1 Parent(s): 358b6c4

Upload Tests.ipynb

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