Fix: comprehensive 18-page paper with detailed descriptions + fixed non-overlapping figures
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- figures/amount_analysis.pdf +2 -2
- figures/amount_analysis.png +2 -2
- figures/architecture_diagram.pdf +0 -0
- figures/architecture_diagram.png +2 -2
- figures/class_distribution.pdf +0 -0
- figures/class_distribution.png +2 -2
- figures/confusion_matrices.pdf +0 -0
- figures/confusion_matrices.png +2 -2
- figures/correlation_heatmap.pdf +0 -0
- figures/correlation_heatmap.png +2 -2
- figures/error_analysis.pdf +0 -0
- figures/error_analysis.png +2 -2
- figures/feature_distributions.pdf +0 -0
- figures/feature_distributions.png +2 -2
- figures/feature_importance.pdf +0 -0
- figures/feature_importance.png +2 -2
- figures/lime_explanation.pdf +0 -0
- figures/lime_explanation.png +2 -2
- figures/pr_curves.pdf +0 -0
- figures/pr_curves.png +2 -2
- figures/roc_curves.pdf +0 -0
- figures/roc_curves.png +2 -2
- figures/shap_summary.pdf +2 -2
- figures/shap_summary.png +2 -2
- figures/shap_top10.pdf +0 -0
- figures/shap_top10.png +2 -2
- figures/threshold_analysis.pdf +0 -0
- figures/threshold_analysis.png +2 -2
- figures/time_analysis.pdf +0 -0
- figures/time_analysis.png +2 -2
- generate_pdf.py +663 -307
- paper/figures/amount_analysis.pdf +2 -2
- paper/figures/amount_analysis.png +2 -2
- paper/figures/architecture_diagram.pdf +0 -0
- paper/figures/architecture_diagram.png +2 -2
- paper/figures/class_distribution.pdf +0 -0
- paper/figures/class_distribution.png +2 -2
- paper/figures/confusion_matrices.pdf +0 -0
- paper/figures/confusion_matrices.png +2 -2
- paper/figures/correlation_heatmap.pdf +0 -0
- paper/figures/correlation_heatmap.png +2 -2
- paper/figures/error_analysis.pdf +0 -0
- paper/figures/error_analysis.png +2 -2
- paper/figures/feature_distributions.pdf +0 -0
- paper/figures/feature_distributions.png +2 -2
- paper/figures/feature_importance.pdf +0 -0
- paper/figures/feature_importance.png +2 -2
- paper/figures/lime_explanation.pdf +0 -0
- paper/figures/lime_explanation.png +2 -2
- paper/figures/pr_curves.pdf +0 -0
figures/amount_analysis.pdf
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0b26a10e4d1972c4e9ffe27982f43efaec36bdbf4458ac75b9fe7491a9cbfa09
|
| 3 |
+
size 198161
|
figures/amount_analysis.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
figures/architecture_diagram.pdf
CHANGED
|
Binary files a/figures/architecture_diagram.pdf and b/figures/architecture_diagram.pdf differ
|
|
|
figures/architecture_diagram.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
figures/class_distribution.pdf
CHANGED
|
Binary files a/figures/class_distribution.pdf and b/figures/class_distribution.pdf differ
|
|
|
figures/class_distribution.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
figures/confusion_matrices.pdf
CHANGED
|
Binary files a/figures/confusion_matrices.pdf and b/figures/confusion_matrices.pdf differ
|
|
|
figures/confusion_matrices.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
figures/correlation_heatmap.pdf
CHANGED
|
Binary files a/figures/correlation_heatmap.pdf and b/figures/correlation_heatmap.pdf differ
|
|
|
figures/correlation_heatmap.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
figures/error_analysis.pdf
CHANGED
|
Binary files a/figures/error_analysis.pdf and b/figures/error_analysis.pdf differ
|
|
|
figures/error_analysis.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
figures/feature_distributions.pdf
CHANGED
|
Binary files a/figures/feature_distributions.pdf and b/figures/feature_distributions.pdf differ
|
|
|
figures/feature_distributions.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
figures/feature_importance.pdf
CHANGED
|
Binary files a/figures/feature_importance.pdf and b/figures/feature_importance.pdf differ
|
|
|
figures/feature_importance.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
figures/lime_explanation.pdf
CHANGED
|
Binary files a/figures/lime_explanation.pdf and b/figures/lime_explanation.pdf differ
|
|
|
figures/lime_explanation.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
figures/pr_curves.pdf
CHANGED
|
Binary files a/figures/pr_curves.pdf and b/figures/pr_curves.pdf differ
|
|
|
figures/pr_curves.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
figures/roc_curves.pdf
CHANGED
|
Binary files a/figures/roc_curves.pdf and b/figures/roc_curves.pdf differ
|
|
|
figures/roc_curves.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
figures/shap_summary.pdf
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e8a7b6bb9c0877d663b473567d1db2b0c593a55685daf7b9e44ee43d8b42a86f
|
| 3 |
+
size 334449
|
figures/shap_summary.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
figures/shap_top10.pdf
CHANGED
|
Binary files a/figures/shap_top10.pdf and b/figures/shap_top10.pdf differ
|
|
|
figures/shap_top10.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
figures/threshold_analysis.pdf
CHANGED
|
Binary files a/figures/threshold_analysis.pdf and b/figures/threshold_analysis.pdf differ
|
|
|
figures/threshold_analysis.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
figures/time_analysis.pdf
CHANGED
|
Binary files a/figures/time_analysis.pdf and b/figures/time_analysis.pdf differ
|
|
|
figures/time_analysis.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
generate_pdf.py
CHANGED
|
@@ -1,353 +1,709 @@
|
|
| 1 |
-
"""
|
|
|
|
|
|
|
|
|
|
| 2 |
import os, sys
|
| 3 |
sys.path.insert(0, '/app/fraud_detection')
|
| 4 |
from fpdf import FPDF
|
| 5 |
|
| 6 |
FIGURES_DIR = '/app/fraud_detection/figures'
|
| 7 |
PAPER_DIR = '/app/fraud_detection/paper'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
class IEEEPaper(FPDF):
|
| 11 |
def __init__(self):
|
| 12 |
super().__init__('P', 'mm', 'letter')
|
| 13 |
-
self.
|
| 14 |
-
|
|
|
|
| 15 |
def header(self):
|
| 16 |
if self.page_no() > 1:
|
| 17 |
-
self.set_font('Helvetica', 'I',
|
| 18 |
-
self.cell(0,
|
| 19 |
-
self.ln(
|
| 20 |
-
|
| 21 |
def footer(self):
|
| 22 |
-
self.set_y(-
|
| 23 |
-
self.set_font('Helvetica', 'I',
|
| 24 |
-
self.cell(0, 10, f'
|
| 25 |
-
|
| 26 |
-
def
|
| 27 |
-
self.ln(
|
| 28 |
self.set_font('Helvetica', 'B', 11)
|
| 29 |
-
self.cell(0, 6, f'{num}.
|
| 30 |
-
self.ln(2)
|
| 31 |
-
|
| 32 |
-
def subsection_title(self, label, title):
|
| 33 |
self.ln(2)
|
|
|
|
|
|
|
|
|
|
| 34 |
self.set_font('Helvetica', 'B', 10)
|
| 35 |
self.cell(0, 5, f'{label} {title}', ln=True)
|
| 36 |
self.ln(1)
|
| 37 |
-
|
| 38 |
-
def
|
| 39 |
-
|
| 40 |
-
self.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
self.ln(1)
|
| 42 |
-
|
| 43 |
-
def
|
| 44 |
-
if os.path.exists(
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
| 54 |
if caption:
|
| 55 |
-
self.set_font('Helvetica', 'I', 8)
|
| 56 |
-
self.multi_cell(0, 4, caption, align='C')
|
| 57 |
self.ln(2)
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
self.set_font('Helvetica', 'B',
|
| 63 |
-
for h in
|
| 64 |
-
self.cell(
|
| 65 |
self.ln()
|
| 66 |
-
|
| 67 |
-
# Rows
|
| 68 |
-
self.set_font('Times', '', 8)
|
| 69 |
for row in rows:
|
| 70 |
-
for
|
| 71 |
-
self.cell(
|
| 72 |
self.ln()
|
| 73 |
-
self.ln(
|
| 74 |
|
| 75 |
|
| 76 |
-
def
|
| 77 |
pdf = IEEEPaper()
|
| 78 |
-
|
| 79 |
-
#
|
| 80 |
pdf.add_page()
|
| 81 |
-
pdf.ln(
|
| 82 |
-
pdf.set_font('Helvetica', 'B',
|
| 83 |
-
pdf.multi_cell(0,
|
| 84 |
-
pdf.ln(
|
| 85 |
pdf.set_font('Helvetica', '', 11)
|
| 86 |
pdf.cell(0, 6, 'Raj Vivan', align='C', ln=True)
|
| 87 |
-
pdf.set_font('Helvetica', 'I',
|
| 88 |
-
pdf.cell(0, 5, 'Department of Computer Science
|
| 89 |
-
pdf.ln(
|
| 90 |
-
|
| 91 |
-
#
|
| 92 |
pdf.set_font('Helvetica', 'B', 10)
|
| 93 |
pdf.cell(0, 5, 'Abstract', align='C', ln=True)
|
| 94 |
pdf.ln(2)
|
| 95 |
-
pdf.
|
| 96 |
-
'Credit card fraud poses a significant threat to the global financial ecosystem, with estimated losses exceeding $32 billion
|
| 97 |
-
'
|
| 98 |
-
'
|
| 99 |
-
'
|
| 100 |
-
'
|
| 101 |
-
'with
|
| 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 |
-
pdf.
|
| 179 |
-
|
| 180 |
-
'
|
| 181 |
-
'
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
pdf.
|
| 186 |
-
'
|
| 187 |
-
'
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
'
|
| 194 |
-
'
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
pdf.
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
'
|
| 205 |
-
'
|
| 206 |
-
'
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
pdf.
|
| 213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
[
|
| 215 |
-
['XGBoost', '0.
|
| 216 |
-
['Voting Ens.', '0.
|
| 217 |
-
['LGBM Tuned', '0.
|
| 218 |
-
['XGB Tuned', '0.
|
| 219 |
-
['RF Tuned', '0.
|
| 220 |
-
['Random Forest', '0.
|
| 221 |
-
['MLP', '0.
|
| 222 |
-
['Logistic Reg.', '0.
|
| 223 |
-
['Autoencoder', '0.
|
| 224 |
],
|
| 225 |
-
'Table
|
| 226 |
-
)
|
| 227 |
-
|
| 228 |
-
pdf.
|
| 229 |
-
'XGBoost achieves the highest PR-AUC (0.
|
| 230 |
-
'
|
| 231 |
-
'
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
pdf.
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
pdf.
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
pdf.
|
| 248 |
-
|
| 249 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
[
|
| 251 |
-
['XGBoost', '6,966', '1,711', '30', '6,936'
|
| 252 |
-
['
|
| 253 |
-
['
|
| 254 |
-
['
|
|
|
|
| 255 |
],
|
| 256 |
-
'Table
|
| 257 |
-
)
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
pdf.
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
'
|
| 276 |
-
'
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
'
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
#
|
| 295 |
-
pdf.
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
'
|
| 300 |
-
'
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
'
|
| 307 |
-
'
|
| 308 |
-
'
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
refs = [
|
| 316 |
-
'[1]
|
| 317 |
-
'[2]
|
| 318 |
-
'[3]
|
| 319 |
-
'[4]
|
| 320 |
-
'[5]
|
| 321 |
-
'[6]
|
| 322 |
-
'[7]
|
| 323 |
-
'[8]
|
| 324 |
-
'[9]
|
| 325 |
-
'[10] L. Grinsztajn
|
| 326 |
-
'[11] T. Akiba
|
| 327 |
-
'[12] R. J. Bolton and D. J. Hand, "Statistical fraud detection: A review," Statistical Science, 2002.',
|
| 328 |
-
'[13] Z. Zhang
|
| 329 |
-
'[14] A. A. Taha and S. J. Malebary, "An intelligent approach to credit card fraud detection," IEEE Access, 2020.',
|
| 330 |
-
'[15] V. Belle and I. Papantonis, "Principles and practice of explainable
|
| 331 |
-
'[16] L. Prokhorenkova
|
| 332 |
-
'[17] S. Xuan
|
| 333 |
-
'[18] T. Saito and M. Rehmsmeier, "The
|
| 334 |
-
'[19] Y. Liu
|
| 335 |
-
'[20] Q. Yang
|
| 336 |
'[21] Nilson Report, "Global card fraud losses," Issue 1209, 2022.',
|
| 337 |
-
'[22] A. Dal Pozzolo
|
| 338 |
]
|
| 339 |
-
|
| 340 |
-
pdf.set_font('Times', '', 8)
|
| 341 |
for ref in refs:
|
| 342 |
pdf.multi_cell(0, 3.5, ref)
|
| 343 |
-
pdf.ln(0.
|
| 344 |
-
|
| 345 |
# Save
|
| 346 |
-
|
| 347 |
-
pdf.output(
|
| 348 |
-
print(f"
|
| 349 |
-
print(f"Pages: {pdf.page_no()}")
|
| 350 |
|
| 351 |
|
| 352 |
-
if __name__ ==
|
| 353 |
-
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Generate a comprehensive IEEE-style PDF paper using fpdf2.
|
| 3 |
+
Full descriptions, observations, analysis in every section.
|
| 4 |
+
"""
|
| 5 |
import os, sys
|
| 6 |
sys.path.insert(0, '/app/fraud_detection')
|
| 7 |
from fpdf import FPDF
|
| 8 |
|
| 9 |
FIGURES_DIR = '/app/fraud_detection/figures'
|
| 10 |
PAPER_DIR = '/app/fraud_detection/paper'
|
| 11 |
+
os.makedirs(PAPER_DIR, exist_ok=True)
|
| 12 |
+
|
| 13 |
+
LM = 15 # left margin
|
| 14 |
+
RM = 15 # right margin
|
| 15 |
+
BW = 215.9 - LM - RM # body width (Letter)
|
| 16 |
|
| 17 |
|
| 18 |
class IEEEPaper(FPDF):
|
| 19 |
def __init__(self):
|
| 20 |
super().__init__('P', 'mm', 'letter')
|
| 21 |
+
self.set_margins(LM, 18, RM)
|
| 22 |
+
self.set_auto_page_break(auto=True, margin=22)
|
| 23 |
+
|
| 24 |
def header(self):
|
| 25 |
if self.page_no() > 1:
|
| 26 |
+
self.set_font('Helvetica', 'I', 7)
|
| 27 |
+
self.cell(0, 4, 'IEEE Transactions -- Comprehensive Fraud Detection Framework', align='C')
|
| 28 |
+
self.ln(6)
|
| 29 |
+
|
| 30 |
def footer(self):
|
| 31 |
+
self.set_y(-14)
|
| 32 |
+
self.set_font('Helvetica', 'I', 7)
|
| 33 |
+
self.cell(0, 10, f'{self.page_no()}', align='C')
|
| 34 |
+
|
| 35 |
+
def section(self, num, title):
|
| 36 |
+
self.ln(5)
|
| 37 |
self.set_font('Helvetica', 'B', 11)
|
| 38 |
+
self.cell(0, 6, f'{num}. {title.upper()}', ln=True)
|
|
|
|
|
|
|
|
|
|
| 39 |
self.ln(2)
|
| 40 |
+
|
| 41 |
+
def subsec(self, label, title):
|
| 42 |
+
self.ln(3)
|
| 43 |
self.set_font('Helvetica', 'B', 10)
|
| 44 |
self.cell(0, 5, f'{label} {title}', ln=True)
|
| 45 |
self.ln(1)
|
| 46 |
+
|
| 47 |
+
def p(self, text):
|
| 48 |
+
"""Body paragraph."""
|
| 49 |
+
self.set_font('Times', '', 9.5)
|
| 50 |
+
self.multi_cell(0, 4.2, text)
|
| 51 |
+
self.ln(1.5)
|
| 52 |
+
|
| 53 |
+
def p_indent(self, text):
|
| 54 |
+
"""Indented body paragraph."""
|
| 55 |
+
self.set_font('Times', '', 9.5)
|
| 56 |
+
self.set_x(LM + 5)
|
| 57 |
+
self.multi_cell(BW - 5, 4.2, text)
|
| 58 |
+
self.ln(1.5)
|
| 59 |
+
|
| 60 |
+
def bullet(self, items):
|
| 61 |
+
self.set_font('Times', '', 9.5)
|
| 62 |
+
for item in items:
|
| 63 |
+
self.set_x(LM + 4)
|
| 64 |
+
self.cell(4, 4.2, '-')
|
| 65 |
+
self.multi_cell(BW - 8, 4.2, item)
|
| 66 |
+
self.ln(0.5)
|
| 67 |
self.ln(1)
|
| 68 |
+
|
| 69 |
+
def fig(self, path, caption, w=155):
|
| 70 |
+
if not os.path.exists(path):
|
| 71 |
+
return
|
| 72 |
+
self.ln(3)
|
| 73 |
+
x = (self.w - w) / 2
|
| 74 |
+
self.image(path, x=x, w=w)
|
| 75 |
+
self.ln(2)
|
| 76 |
+
self.set_font('Helvetica', 'I', 8)
|
| 77 |
+
self.multi_cell(0, 3.8, caption, align='C')
|
| 78 |
+
self.ln(3)
|
| 79 |
+
|
| 80 |
+
def tbl(self, hdrs, rows, caption=''):
|
| 81 |
if caption:
|
|
|
|
|
|
|
| 82 |
self.ln(2)
|
| 83 |
+
self.set_font('Helvetica', 'I', 8)
|
| 84 |
+
self.multi_cell(0, 3.8, caption, align='C')
|
| 85 |
+
self.ln(1)
|
| 86 |
+
cw = BW / len(hdrs)
|
| 87 |
+
self.set_font('Helvetica', 'B', 7.5)
|
| 88 |
+
for h in hdrs:
|
| 89 |
+
self.cell(cw, 4.5, h, border=1, align='C')
|
| 90 |
self.ln()
|
| 91 |
+
self.set_font('Times', '', 7.5)
|
|
|
|
|
|
|
| 92 |
for row in rows:
|
| 93 |
+
for c in row:
|
| 94 |
+
self.cell(cw, 4.5, str(c), border=1, align='C')
|
| 95 |
self.ln()
|
| 96 |
+
self.ln(2)
|
| 97 |
|
| 98 |
|
| 99 |
+
def build():
|
| 100 |
pdf = IEEEPaper()
|
| 101 |
+
|
| 102 |
+
# ===== TITLE PAGE =====
|
| 103 |
pdf.add_page()
|
| 104 |
+
pdf.ln(18)
|
| 105 |
+
pdf.set_font('Helvetica', 'B', 17)
|
| 106 |
+
pdf.multi_cell(0, 9, 'A Comprehensive Ensemble-Based Framework\nfor Credit Card Fraud Detection\nwith Explainable AI', align='C')
|
| 107 |
+
pdf.ln(6)
|
| 108 |
pdf.set_font('Helvetica', '', 11)
|
| 109 |
pdf.cell(0, 6, 'Raj Vivan', align='C', ln=True)
|
| 110 |
+
pdf.set_font('Helvetica', 'I', 9)
|
| 111 |
+
pdf.cell(0, 5, 'Department of Computer Science | Independent Research', align='C', ln=True)
|
| 112 |
+
pdf.ln(10)
|
| 113 |
+
|
| 114 |
+
# --- ABSTRACT ---
|
| 115 |
pdf.set_font('Helvetica', 'B', 10)
|
| 116 |
pdf.cell(0, 5, 'Abstract', align='C', ln=True)
|
| 117 |
pdf.ln(2)
|
| 118 |
+
pdf.p(
|
| 119 |
+
'Credit card fraud poses a significant and growing threat to the global financial ecosystem, with estimated annual losses exceeding $32 billion. '
|
| 120 |
+
'As electronic payment volumes increase, so does the sophistication of fraudulent activities, demanding increasingly advanced detection systems. '
|
| 121 |
+
'This paper presents a comprehensive, end-to-end fraud detection framework that systematically develops, evaluates, and compares seven distinct machine learning approaches: '
|
| 122 |
+
'Logistic Regression (as an interpretable baseline), Random Forest, XGBoost, LightGBM, a Multilayer Perceptron neural network, an Autoencoder-based anomaly detector, '
|
| 123 |
+
'and a soft Voting Ensemble combining the three best-performing tuned models. Using the widely-cited European Cardholder benchmark dataset containing 284,807 transactions '
|
| 124 |
+
'with an extreme class imbalance of 0.173% fraud, we engineer 12 novel features capturing temporal, behavioral, and interaction patterns. We rigorously address class imbalance '
|
| 125 |
+
'through both SMOTE oversampling (applied exclusively after train-test splitting) and cost-sensitive learning via balanced class weights. '
|
| 126 |
+
'Our results demonstrate that XGBoost with cost-sensitive learning achieves the best overall performance with a Precision-Recall AUC of 0.8166, precision of 0.9048, '
|
| 127 |
+
'recall of 0.8028, F1-score of 0.8507, and Matthews Correlation Coefficient of 0.8520 on the held-out test set. Optimizing the decision threshold from the default 0.5 '
|
| 128 |
+
'to 0.55 further improves the F1-score to 0.8636. Comprehensive model explainability through SHAP and LIME analysis identifies PCA components V4, V14, and V12 as the '
|
| 129 |
+
'primary discriminative features driving fraud predictions. Detailed error analysis reveals that the 14 false negatives arise from sophisticated fraud attempts whose '
|
| 130 |
+
'feature distributions closely mimic legitimate transaction behavior. We deploy the final model as a production-ready FastAPI service achieving sub-10ms average inference latency, '
|
| 131 |
+
'and provide concept drift monitoring recommendations for sustained operational performance. All code, trained models, figures, and this paper are publicly available.'
|
| 132 |
+
)
|
| 133 |
+
pdf.set_font('Helvetica', 'I', 8)
|
| 134 |
+
pdf.cell(0, 5, 'Keywords: fraud detection, credit card, XGBoost, ensemble learning, SHAP, LIME, class imbalance, SMOTE, anomaly detection, explainable AI', ln=True)
|
| 135 |
+
|
| 136 |
+
# ===== I. INTRODUCTION =====
|
| 137 |
+
pdf.section('I', 'Introduction')
|
| 138 |
+
pdf.p(
|
| 139 |
+
'Financial fraud detection has emerged as one of the most consequential applications of machine learning in the modern digital economy. '
|
| 140 |
+
'The global shift toward electronic payment systems has created an unprecedented volume of financial transactions, with Visa alone processing '
|
| 141 |
+
'over 200 billion transactions annually. This massive scale, while enabling economic growth, simultaneously creates fertile ground for '
|
| 142 |
+
'increasingly sophisticated fraudulent activities. According to the Nilson Report [21], worldwide payment card fraud losses reached $32.34 billion '
|
| 143 |
+
'in 2021, representing a 14% year-over-year increase. Projections indicate these losses will exceed $43 billion by 2026 unless detection systems '
|
| 144 |
+
'improve significantly.'
|
| 145 |
+
)
|
| 146 |
+
pdf.p(
|
| 147 |
+
'The fundamental challenge in fraud detection lies in the extreme class imbalance inherent in transaction data. In real-world datasets, '
|
| 148 |
+
'fraudulent transactions typically constitute less than 0.5% of all transactions, often as low as 0.1%. This severe imbalance creates a '
|
| 149 |
+
'paradox where a naive classifier that labels every transaction as legitimate achieves over 99.8% accuracy while catching zero fraud. '
|
| 150 |
+
'This renders conventional accuracy metrics entirely misleading and necessitates the use of specialized evaluation criteria including '
|
| 151 |
+
'Precision-Recall Area Under the Curve (PR-AUC), the F1-score, and the Matthews Correlation Coefficient (MCC), which remain informative '
|
| 152 |
+
'even under extreme class skew [18].'
|
| 153 |
+
)
|
| 154 |
+
pdf.p(
|
| 155 |
+
'A second major challenge is the evolving nature of fraud patterns. Fraudsters continuously adapt their techniques to evade detection, '
|
| 156 |
+
'a phenomenon known as concept drift [1]. A model trained on historical data may see its performance degrade rapidly as new attack vectors '
|
| 157 |
+
'emerge. This necessitates continuous monitoring, periodic retraining, and robust model architectures that generalize well to unseen patterns.'
|
| 158 |
+
)
|
| 159 |
+
pdf.p(
|
| 160 |
+
'Previous approaches to fraud detection span a wide spectrum, from early rule-based expert systems [12] that relied on manually defined '
|
| 161 |
+
'thresholds and patterns, to modern deep learning architectures employing recurrent networks [13] and graph neural networks [19]. '
|
| 162 |
+
'However, recent extensive benchmarking by Shwartz-Ziv and Armon [9] and Grinsztajn et al. [10] has demonstrated that well-tuned '
|
| 163 |
+
'gradient-boosted tree methods consistently match or outperform deep learning on tabular data tasks, including fraud detection, '
|
| 164 |
+
'particularly when combined with thoughtful feature engineering and proper handling of class imbalance.'
|
| 165 |
+
)
|
| 166 |
+
pdf.p('This paper makes the following six contributions:')
|
| 167 |
+
pdf.bullet([
|
| 168 |
+
'A systematic, head-to-head comparison of seven diverse machine learning approaches for fraud detection, spanning linear models, tree ensembles, neural networks, and anomaly detection.',
|
| 169 |
+
'Novel feature engineering that produces 12 new features capturing temporal cycles, transaction velocity, amount deviations, and PCA component interactions.',
|
| 170 |
+
'A rigorous evaluation methodology that applies SMOTE only after stratified train-test splitting and fits feature scaling exclusively on training data, preventing all forms of data leakage.',
|
| 171 |
+
'Comprehensive model explainability analysis using both SHAP (global feature attribution) and LIME (local, instance-level interpretation) to provide actionable insights into fraud prediction drivers.',
|
| 172 |
+
'A production-ready FastAPI deployment achieving sub-10ms average inference latency with real-time risk scoring, demonstrating deployment feasibility.',
|
| 173 |
+
'Quantitative business impact analysis translating model performance into dollar-denominated financial outcomes, directly connecting ML metrics to business value.',
|
| 174 |
+
])
|
| 175 |
+
|
| 176 |
+
# ===== II. RELATED WORK =====
|
| 177 |
+
pdf.section('II', 'Related Work')
|
| 178 |
+
pdf.p(
|
| 179 |
+
'The literature on fraud detection is extensive and spans several decades. Bolton and Hand [12] provided one of the earliest comprehensive surveys '
|
| 180 |
+
'of statistical methods for fraud detection, establishing the field and identifying class imbalance as the central technical challenge. '
|
| 181 |
+
'Dal Pozzolo et al. [1] subsequently provided a foundational analysis of how class imbalance and concept drift interact in real-world '
|
| 182 |
+
'credit card fraud detection systems, demonstrating that undersampling strategies could be effective but risked discarding valuable information '
|
| 183 |
+
'from the majority class. Their follow-up work [22] further investigated conditions under which undersampling outperforms other strategies.'
|
| 184 |
+
)
|
| 185 |
+
pdf.p(
|
| 186 |
+
'The class imbalance problem has generated a rich sub-literature. Chawla et al. [2] introduced SMOTE (Synthetic Minority Over-sampling Technique), '
|
| 187 |
+
'which generates synthetic minority class samples by interpolating between existing examples in feature space. SMOTE became the dominant '
|
| 188 |
+
'oversampling method in the field, with numerous variants proposed subsequently (Borderline-SMOTE, ADASYN, etc.). Critically, Fernandez et al. [3] '
|
| 189 |
+
'established through extensive experimentation that SMOTE must be applied exclusively to training data; applying it before the train-test split '
|
| 190 |
+
'introduces a subtle but severe form of data leakage where synthetic test samples carry information derived from training examples, leading to '
|
| 191 |
+
'dramatically over-optimistic performance estimates.'
|
| 192 |
+
)
|
| 193 |
+
pdf.p(
|
| 194 |
+
'Tree-based ensemble methods have emerged as the dominant paradigm for tabular fraud detection. Xuan et al. [17] demonstrated that '
|
| 195 |
+
'Random Forests achieve robust baseline performance through bagging and feature randomization. Chen and Guestrin [4] introduced XGBoost, '
|
| 196 |
+
'a regularized gradient boosting framework that has since become one of the most widely used algorithms for tabular classification, including '
|
| 197 |
+
'fraud detection [14]. Ke et al. [5] proposed LightGBM with leaf-wise tree growth and gradient-based one-side sampling (GOSS), achieving '
|
| 198 |
+
'faster training with comparable or superior accuracy. Prokhorenkova et al. [16] introduced CatBoost with ordered boosting to handle '
|
| 199 |
+
'categorical features natively without target leakage.'
|
| 200 |
+
)
|
| 201 |
+
pdf.p(
|
| 202 |
+
'Deep learning approaches have also been explored for fraud detection. Pumsirirat and Yan [6] employed autoencoders trained exclusively '
|
| 203 |
+
'on legitimate transactions, detecting fraud through elevated reconstruction error. This unsupervised approach has the advantage of not '
|
| 204 |
+
'requiring labeled fraud examples but typically suffers from high false positive rates. Zhang et al. [13] proposed attention-based '
|
| 205 |
+
'recurrent neural networks that capture sequential transaction patterns, though their complexity often does not justify the marginal '
|
| 206 |
+
'improvement over tree-based methods on static feature representations.'
|
| 207 |
+
)
|
| 208 |
+
pdf.p(
|
| 209 |
+
'The growing importance of regulatory compliance has brought model explainability to the forefront. Lundberg and Lee [7] introduced '
|
| 210 |
+
'SHAP (SHapley Additive exPlanations), grounded in cooperative game theory, which provides theoretically consistent and locally accurate '
|
| 211 |
+
'feature attribution values. Ribeiro et al. [8] proposed LIME (Local Interpretable Model-agnostic Explanations) for instance-level '
|
| 212 |
+
'interpretability through local linear approximations. Belle and Papantonis [15] surveyed the broader landscape of explainable AI methods '
|
| 213 |
+
'applicable to financial decision-making, noting the tension between model performance and interpretability.'
|
| 214 |
+
)
|
| 215 |
+
pdf.p(
|
| 216 |
+
'For hyperparameter optimization, Akiba et al. [11] introduced Optuna, a framework using Tree-structured Parzen Estimators (TPE) '
|
| 217 |
+
'that efficiently explores complex search spaces through adaptive sampling, outperforming grid and random search strategies.'
|
| 218 |
+
)
|
| 219 |
+
|
| 220 |
+
# ===== III. DATASET AND EDA =====
|
| 221 |
+
pdf.section('III', 'Dataset and Exploratory Data Analysis')
|
| 222 |
+
|
| 223 |
+
pdf.subsec('A.', 'Dataset Description')
|
| 224 |
+
pdf.p(
|
| 225 |
+
'We use the European Cardholder Credit Card Fraud Detection dataset [1], one of the most widely-cited benchmarks in the fraud detection '
|
| 226 |
+
'literature. The dataset contains 284,807 transactions made by European cardholders over a two-day period in September 2013. Each transaction '
|
| 227 |
+
'is described by 31 features: 28 numerical features (V1 through V28) that are the result of a PCA transformation applied to the original '
|
| 228 |
+
'confidential features, plus the raw Time (seconds elapsed from the first transaction in the dataset), Amount (the transaction dollar value), '
|
| 229 |
+
'and Class (the binary label: 0 for legitimate, 1 for fraud). The PCA transformation was applied by the dataset creators to protect cardholder '
|
| 230 |
+
'privacy, which means the original feature semantics (merchant category, geographic location, card type, etc.) are not available. This places '
|
| 231 |
+
'a constraint on domain-specific feature engineering but ensures the dataset can be shared publicly for research.'
|
| 232 |
+
)
|
| 233 |
+
|
| 234 |
+
pdf.subsec('B.', 'Class Distribution and Imbalance')
|
| 235 |
+
pdf.p(
|
| 236 |
+
'The dataset exhibits extreme class imbalance: only 492 out of 284,807 transactions are labeled as fraudulent, representing merely 0.173% '
|
| 237 |
+
'of the total. This yields an imbalance ratio of approximately 1:577 (one fraud per 577 legitimate transactions). Figure 1 illustrates this '
|
| 238 |
+
'distribution. The severity of this imbalance has profound implications for model training and evaluation: (i) standard cross-entropy loss '
|
| 239 |
+
'will overwhelmingly optimize for the majority class, (ii) accuracy is rendered meaningless (a constant "not fraud" classifier achieves 99.83%), '
|
| 240 |
+
'and (iii) most standard ML algorithms will struggle to learn the minority class boundary without explicit countermeasures.'
|
| 241 |
+
)
|
| 242 |
+
|
| 243 |
+
pdf.tbl(
|
| 244 |
+
['Class', 'Count', 'Percentage', 'Imbalance Ratio'],
|
| 245 |
+
[['Legitimate (0)', '284,315', '99.827%', '---'],
|
| 246 |
+
['Fraud (1)', '492', '0.173%', '1 : 577'],
|
| 247 |
+
['Total', '284,807', '100%', '---']],
|
| 248 |
+
'Table I: Class Distribution in the Credit Card Fraud Dataset'
|
| 249 |
+
)
|
| 250 |
+
pdf.fig(os.path.join(FIGURES_DIR, 'class_distribution.png'),
|
| 251 |
+
'Fig. 1. Class distribution showing the extreme imbalance between legitimate (99.83%) and fraudulent (0.17%) transactions.', w=140)
|
| 252 |
+
|
| 253 |
+
pdf.subsec('C.', 'Transaction Amount Analysis')
|
| 254 |
+
pdf.p(
|
| 255 |
+
'Analysis of transaction amounts reveals distinct behavioral patterns between the two classes. Legitimate transactions have a mean amount of '
|
| 256 |
+
'$88.29 with a median of $22.00, indicating a right-skewed distribution dominated by small everyday purchases with occasional large transactions '
|
| 257 |
+
'(maximum: $25,691.16). Fraudulent transactions, perhaps counter-intuitively, have a higher mean of $122.21 but a lower median of only $9.25. '
|
| 258 |
+
'This bimodal pattern in fraud amounts suggests two distinct fraud strategies: (i) low-value "testing" transactions (often under $5) where '
|
| 259 |
+
'fraudsters verify that a stolen card number is active before attempting larger purchases, and (ii) moderate-to-high value transactions that '
|
| 260 |
+
'represent the actual theft. The low median indicates that the testing strategy is more common. Figure 2 presents the detailed amount distributions.'
|
| 261 |
+
)
|
| 262 |
+
pdf.fig(os.path.join(FIGURES_DIR, 'amount_analysis.png'),
|
| 263 |
+
'Fig. 2. Transaction amount analysis: (a) legitimate amounts, (b) fraud amounts, (c) log-scaled comparison, (d) boxplot.', w=155)
|
| 264 |
+
|
| 265 |
+
pdf.subsec('D.', 'Temporal Patterns')
|
| 266 |
+
pdf.p(
|
| 267 |
+
'Temporal analysis reveals significant differences in the timing of legitimate versus fraudulent transactions. Figure 3 shows that the '
|
| 268 |
+
'fraud rate during nighttime hours (midnight to 6 AM) is 0.518%, nearly four times the daytime rate of 0.137%. This is consistent with '
|
| 269 |
+
'known fraud patterns: fraudsters preferentially operate during off-peak hours when transaction monitoring systems may have reduced staffing, '
|
| 270 |
+
'when cardholders are less likely to notice unauthorized transactions on their accounts, and when automated systems process transactions '
|
| 271 |
+
'with less stringent real-time checks. This temporal signal motivates our cyclic hour-of-day feature engineering, which encodes the hour '
|
| 272 |
+
'as sine and cosine components to preserve the circular nature of time.'
|
| 273 |
+
)
|
| 274 |
+
pdf.fig(os.path.join(FIGURES_DIR, 'time_analysis.png'),
|
| 275 |
+
'Fig. 3. Temporal patterns: (a) transaction density by hour showing fraud concentration at night, (b) fraud rate by hour.', w=145)
|
| 276 |
+
|
| 277 |
+
pdf.subsec('E.', 'Feature Correlations')
|
| 278 |
+
pdf.p(
|
| 279 |
+
'Pearson correlation analysis between each feature and the fraud label identifies the most discriminative PCA components. The features with '
|
| 280 |
+
'the strongest negative correlation with fraud are V17 (r = -0.326), V14 (r = -0.303), and V12 (r = -0.261), meaning that lower values of '
|
| 281 |
+
'these features are associated with higher fraud probability. On the positive side, V11 (r = +0.155) and V4 (r = +0.133) show the strongest '
|
| 282 |
+
'associations. Notably, the raw Amount feature has near-zero correlation (r = 0.006) with fraud, confirming that simple amount-based rules '
|
| 283 |
+
'would be ineffective. The Time feature also shows negligible correlation (r = -0.012). These findings guide both our feature engineering '
|
| 284 |
+
'(creating interaction terms between the top correlated features) and our expectation of which features will dominate model importance.'
|
| 285 |
+
)
|
| 286 |
+
pdf.fig(os.path.join(FIGURES_DIR, 'correlation_heatmap.png'),
|
| 287 |
+
'Fig. 4. Feature correlation with the fraud class. Negative values (red) indicate features whose lower values signal fraud.', w=130)
|
| 288 |
+
|
| 289 |
+
pdf.subsec('F.', 'Feature Distributions by Class')
|
| 290 |
+
pdf.p(
|
| 291 |
+
'Figure 5 visualizes the distributions of the six most discriminative features separated by class. The key observation is that for features '
|
| 292 |
+
'like V14 and V17, the fraud distribution (red) is shifted significantly to the left compared to the legitimate distribution (green), '
|
| 293 |
+
'creating a separable signal that tree-based models can exploit through axis-aligned splits. For V4 and V11, the fraud distribution is shifted '
|
| 294 |
+
'rightward. However, there is substantial overlap between the classes for all features, which explains why no single feature achieves perfect '
|
| 295 |
+
'separation and why ensemble methods that combine weak signals from multiple features outperform univariate approaches.'
|
| 296 |
+
)
|
| 297 |
+
pdf.fig(os.path.join(FIGURES_DIR, 'feature_distributions.png'),
|
| 298 |
+
'Fig. 5. Distribution of the top 6 discriminative features by class, showing partial but informative separation.', w=155)
|
| 299 |
+
|
| 300 |
+
pdf.subsec('G.', 'Five Key Observations')
|
| 301 |
+
pdf.p('Our exploratory analysis yields five principal observations that directly inform the modeling strategy:')
|
| 302 |
+
pdf.bullet([
|
| 303 |
+
'EXTREME CLASS IMBALANCE: With only 0.173% fraud, conventional accuracy is meaningless. All models must employ either oversampling (SMOTE) or cost-sensitive learning, and evaluation must rely on PR-AUC, F1, and MCC rather than accuracy or ROC-AUC alone.',
|
| 304 |
+
'BIMODAL FRAUD AMOUNTS: The bimodal distribution of fraud amounts (small testing transactions + larger theft transactions) means amount-based thresholds will miss most fraud. Feature engineering that captures amount deviations and z-scores is essential.',
|
| 305 |
+
'TEMPORAL EXPLOITATION: The 4x higher nighttime fraud rate provides a usable signal when encoded as cyclic features. Time-based features should improve model discrimination.',
|
| 306 |
+
'PCA FEATURE DOMINANCE: V14, V17, V12, V4, and V11 carry the strongest fraud signal. Interaction features between these variables may capture non-linear relationships that individual features miss.',
|
| 307 |
+
'CLEAN DATA: The absence of missing values and the pre-applied PCA transformation simplify preprocessing but limit domain-specific engineering. The 1,081 duplicate rows are removed to prevent data leakage.',
|
| 308 |
+
])
|
| 309 |
+
|
| 310 |
+
# ===== IV. METHODOLOGY =====
|
| 311 |
+
pdf.section('IV', 'Methodology')
|
| 312 |
+
|
| 313 |
+
pdf.subsec('A.', 'Feature Engineering')
|
| 314 |
+
pdf.p(
|
| 315 |
+
'We augment the original 30 features (Time, V1-V28, Amount) with 12 engineered features designed to capture temporal, behavioral, and '
|
| 316 |
+
'interaction patterns that the raw PCA features may not directly encode. The final feature set contains 42 dimensions.'
|
| 317 |
+
)
|
| 318 |
+
pdf.p(
|
| 319 |
+
'Temporal features: We derive the hour of day from the Time column and encode it cyclically using sine and cosine transformations: '
|
| 320 |
+
'Hour_sin = sin(2*pi*h/24) and Hour_cos = cos(2*pi*h/24), where h = (Time/3600) mod 24. This cyclic encoding ensures that hour 23 '
|
| 321 |
+
'and hour 0 are treated as adjacent rather than maximally distant, which is critical for capturing the nighttime fraud pattern. '
|
| 322 |
+
'We also compute Time_diff as the difference in Time from the previous transaction, approximating the inter-arrival time.'
|
| 323 |
+
)
|
| 324 |
+
pdf.p(
|
| 325 |
+
'Amount features: We compute Amount_log = log(1 + Amount) to compress the heavy-tailed amount distribution, Amount_deviation_mean and '
|
| 326 |
+
'Amount_deviation_median to capture how far each transaction deviates from typical amounts, Amount_zscore for standardized deviation, '
|
| 327 |
+
'and Transaction_velocity = 1/(Time_diff + 1) as a proxy for how rapidly transactions are occurring.'
|
| 328 |
+
)
|
| 329 |
+
pdf.p(
|
| 330 |
+
'Interaction features: We create three pairwise products between the most discriminative PCA components: V14*V17, V12*V14, and V10*V14. '
|
| 331 |
+
'These capture joint effects that axis-aligned tree splits would require multiple levels to approximate. Finally, PCA_magnitude computes '
|
| 332 |
+
'the L2 norm across all 28 PCA features, providing a summary measure of overall transaction "abnormality" in the latent space.'
|
| 333 |
+
)
|
| 334 |
+
|
| 335 |
+
pdf.subsec('B.', 'Class Imbalance Handling')
|
| 336 |
+
pdf.p(
|
| 337 |
+
'We implement and compare two established approaches for handling the 1:577 class imbalance. Both are applied exclusively to the '
|
| 338 |
+
'training data, never to validation or test sets.'
|
| 339 |
+
)
|
| 340 |
+
pdf.p(
|
| 341 |
+
'SMOTE (Synthetic Minority Over-sampling Technique) [2]: We generate synthetic fraud samples by interpolating between existing fraud '
|
| 342 |
+
'examples in the 42-dimensional feature space. We use a sampling_strategy of 0.5, creating enough synthetic fraud to achieve a 1:2 '
|
| 343 |
+
'minority-to-majority ratio (99,138 synthetic fraud samples added to 198,277 legitimate). This ratio was chosen as a compromise between '
|
| 344 |
+
'the extreme original imbalance and full 1:1 balancing, which can introduce too much synthetic noise. SMOTE data is used exclusively '
|
| 345 |
+
'for the MLP neural network, which does not natively support class weighting.'
|
| 346 |
+
)
|
| 347 |
+
pdf.p(
|
| 348 |
+
'Cost-Sensitive Learning: For tree-based models and Logistic Regression, we apply balanced class weights computed as '
|
| 349 |
+
'w_c = N / (2 * N_c), yielding w_0 = 0.501 and w_1 = 300.01. This effectively makes each fraud example 599 times more important '
|
| 350 |
+
'than a legitimate example in the loss function, incentivizing the model to correctly classify fraud even at the cost of some false positives.'
|
| 351 |
+
)
|
| 352 |
+
|
| 353 |
+
pdf.subsec('C.', 'Data Splitting and Scaling')
|
| 354 |
+
pdf.p(
|
| 355 |
+
'After removing 1,081 duplicate rows and engineering features, we perform a stratified 70/15/15 train/validation/test split. '
|
| 356 |
+
'Stratification preserves the original 0.167% fraud ratio in each split: Train (198,608 samples, 331 fraud), Validation (42,559 samples, '
|
| 357 |
+
'71 fraud), Test (42,559 samples, 71 fraud). Feature scaling uses RobustScaler, which normalizes by the interquartile range '
|
| 358 |
+
'x\' = (x - median) / IQR, providing robustness to outliers that are common in financial transaction data. The scaler is fitted exclusively '
|
| 359 |
+
'on the training set and then applied identically to validation and test sets, preventing any information leakage.'
|
| 360 |
+
)
|
| 361 |
+
|
| 362 |
+
pdf.subsec('D.', 'Model Descriptions')
|
| 363 |
+
pdf.p(
|
| 364 |
+
'1) Logistic Regression (Baseline): An L2-regularized linear model with C=0.1 and balanced class weights, serving as an interpretable '
|
| 365 |
+
'baseline. Its coefficients directly indicate feature importance and direction of effect.'
|
| 366 |
+
)
|
| 367 |
+
pdf.p(
|
| 368 |
+
'2) Random Forest: An ensemble of 150 decision trees (max_depth=12, min_samples_split=5) with balanced class weights. '
|
| 369 |
+
'Each tree is trained on a bootstrap sample with random feature subsets, providing variance reduction through averaging.'
|
| 370 |
+
)
|
| 371 |
+
pdf.p(
|
| 372 |
+
'3) XGBoost: Gradient boosted trees with 200 estimators, max_depth=6, learning_rate=0.1, subsample=0.8, colsample_bytree=0.8, '
|
| 373 |
+
'and scale_pos_weight derived from class frequencies. Uses histogram-based splitting for computational efficiency.'
|
| 374 |
+
)
|
| 375 |
+
pdf.p(
|
| 376 |
+
'4) LightGBM: Leaf-wise gradient boosting with 200 estimators, max_depth=8, learning_rate=0.05, and gradient-based one-side sampling. '
|
| 377 |
+
'The leaf-wise growth strategy can produce deeper trees than XGBoost for the same number of leaves, potentially capturing more complex patterns.'
|
| 378 |
+
)
|
| 379 |
+
pdf.p(
|
| 380 |
+
'5) MLP Neural Network: A three-layer perceptron (128-64-32 neurons) with ReLU activation, dropout (implicit via alpha=0.001 L2 '
|
| 381 |
+
'regularization), adaptive learning rate, and early stopping. Trained on SMOTE-augmented data since sklearn MLPClassifier does not '
|
| 382 |
+
'support class weights directly.'
|
| 383 |
+
)
|
| 384 |
+
pdf.p(
|
| 385 |
+
'6) Autoencoder (Anomaly Detection): A symmetric autoencoder with architecture 42-64-32-16-32-64-42, trained for 50 epochs '
|
| 386 |
+
'exclusively on legitimate transactions. The core assumption is that the autoencoder learns to reconstruct normal transaction patterns; '
|
| 387 |
+
'when a fraudulent transaction is presented, the reconstruction error e(x) = (1/d) * sum((x_i - x_hat_i)^2) will be anomalously high. '
|
| 388 |
+
'This approach requires no labeled fraud examples during training, making it potentially useful for zero-day fraud detection.'
|
| 389 |
+
)
|
| 390 |
+
pdf.p(
|
| 391 |
+
'7) Voting Ensemble: Soft voting over the three best-performing tuned models (XGBoost, LightGBM, Random Forest), where the final '
|
| 392 |
+
'fraud probability is the arithmetic mean of the three individual model probabilities. This leverages the diversity of different '
|
| 393 |
+
'tree-building strategies to reduce variance.'
|
| 394 |
+
)
|
| 395 |
+
|
| 396 |
+
pdf.subsec('E.', 'Hyperparameter Optimization')
|
| 397 |
+
pdf.p(
|
| 398 |
+
'We tune the top three models (XGBoost, LightGBM, Random Forest) using Optuna [11] with the Tree-structured Parzen Estimator (TPE) '
|
| 399 |
+
'sampler. For each model, Optuna explores the hyperparameter space (learning rate, tree depth, regularization, subsampling) over '
|
| 400 |
+
'15-20 trials, optimizing PR-AUC on the validation set. The TPE sampler adaptively focuses trials on promising regions of the search '
|
| 401 |
+
'space, achieving better sample efficiency than grid or random search.'
|
| 402 |
+
)
|
| 403 |
+
|
| 404 |
+
pdf.fig(os.path.join(FIGURES_DIR, 'architecture_diagram.png'),
|
| 405 |
+
'Fig. 6. End-to-end system architecture: from transaction input through feature engineering, model inference, to API output and monitoring.', w=155)
|
| 406 |
+
|
| 407 |
+
# ===== V. EXPERIMENTAL SETUP =====
|
| 408 |
+
pdf.section('V', 'Experimental Setup')
|
| 409 |
+
pdf.p(
|
| 410 |
+
'All experiments were conducted using Python 3.12 on CPU infrastructure. The primary libraries and their versions are: '
|
| 411 |
+
'scikit-learn 1.8.0 (Logistic Regression, Random Forest, MLP, preprocessing), XGBoost 3.2.0, LightGBM 4.6.0, PyTorch 2.11.0 (Autoencoder), '
|
| 412 |
+
'Optuna 4.8.0 (hyperparameter optimization), SHAP 0.51.0, and LIME 0.2.0.1. Total training time for all models including Optuna tuning '
|
| 413 |
+
'was approximately 25 minutes on a 2-core CPU.'
|
| 414 |
+
)
|
| 415 |
+
pdf.p(
|
| 416 |
+
'We report six evaluation metrics on the held-out test set: (1) Precision = TP/(TP+FP), measuring the fraction of flagged transactions '
|
| 417 |
+
'that are actually fraudulent; (2) Recall = TP/(TP+FN), measuring the fraction of actual fraud that is caught; (3) F1-score, the harmonic '
|
| 418 |
+
'mean of precision and recall; (4) ROC-AUC, the area under the Receiver Operating Characteristic curve; (5) PR-AUC (Average Precision), '
|
| 419 |
+
'the area under the Precision-Recall curve, which is our primary metric as it is more informative than ROC-AUC under extreme class imbalance [18]; '
|
| 420 |
+
'and (6) Matthews Correlation Coefficient (MCC), which provides a balanced measure that accounts for all four confusion matrix quadrants '
|
| 421 |
+
'and returns values between -1 and +1.'
|
| 422 |
+
)
|
| 423 |
+
|
| 424 |
+
# ===== VI. RESULTS AND DISCUSSION =====
|
| 425 |
+
pdf.section('VI', 'Results and Discussion')
|
| 426 |
+
|
| 427 |
+
pdf.subsec('A.', 'Model Comparison')
|
| 428 |
+
pdf.p(
|
| 429 |
+
'Table II presents the comprehensive evaluation of all models on the test set using a default threshold of 0.5. The results reveal '
|
| 430 |
+
'a clear hierarchy with important nuances.'
|
| 431 |
+
)
|
| 432 |
+
pdf.tbl(
|
| 433 |
+
['Model', 'Prec.', 'Recall', 'F1', 'ROC-AUC', 'PR-AUC', 'MCC'],
|
| 434 |
[
|
| 435 |
+
['XGBoost', '0.905', '0.803', '0.851', '0.974', '0.817', '0.852'],
|
| 436 |
+
['Voting Ens.', '0.864', '0.803', '0.832', '0.978', '0.801', '0.832'],
|
| 437 |
+
['LGBM Tuned', '0.707', '0.817', '0.758', '0.932', '0.796', '0.760'],
|
| 438 |
+
['XGB Tuned', '0.838', '0.803', '0.820', '0.970', '0.793', '0.820'],
|
| 439 |
+
['RF Tuned', '0.873', '0.775', '0.821', '0.968', '0.793', '0.822'],
|
| 440 |
+
['Random Forest', '0.833', '0.775', '0.803', '0.953', '0.771', '0.803'],
|
| 441 |
+
['MLP', '0.691', '0.789', '0.737', '0.943', '0.752', '0.738'],
|
| 442 |
+
['Logistic Reg.', '0.049', '0.887', '0.092', '0.962', '0.735', '0.204'],
|
| 443 |
+
['Autoencoder', '0.003', '1.000', '0.007', '0.960', '0.044', '0.041'],
|
| 444 |
],
|
| 445 |
+
'Table II: Comprehensive Model Comparison on Test Set (threshold = 0.5)'
|
| 446 |
+
)
|
| 447 |
+
|
| 448 |
+
pdf.p(
|
| 449 |
+
'Key Observation 1 - Tree-based models dominate: XGBoost achieves the highest PR-AUC (0.817), F1-score (0.851), and MCC (0.852), '
|
| 450 |
+
'confirming the findings of Shwartz-Ziv and Armon [9] that gradient-boosted trees remain the strongest approach for tabular data. '
|
| 451 |
+
'The Voting Ensemble achieves a marginally higher ROC-AUC (0.978) through model averaging but does not improve upon the single XGBoost '
|
| 452 |
+
'on the more informative PR-AUC metric, suggesting that the three ensemble members are not sufficiently diverse to benefit from averaging.'
|
| 453 |
+
)
|
| 454 |
+
pdf.p(
|
| 455 |
+
'Key Observation 2 - The precision-recall tradeoff is stark: Logistic Regression achieves high recall (0.887) but catastrophically '
|
| 456 |
+
'low precision (0.049), flagging over 1,200 legitimate transactions as fraud for every 63 true fraud caught. This linear model '
|
| 457 |
+
'creates an extremely aggressive decision boundary due to the large class weight (300x), resulting in a flood of false alarms that '
|
| 458 |
+
'would overwhelm any operational fraud investigation team.'
|
| 459 |
+
)
|
| 460 |
+
pdf.p(
|
| 461 |
+
'Key Observation 3 - Autoencoder anomaly detection fails in this setting: While the autoencoder achieves perfect recall (1.0) by '
|
| 462 |
+
'construction (all fraud has higher reconstruction error than the median), its precision is only 0.003, flagging over 21,000 '
|
| 463 |
+
'legitimate transactions. The PR-AUC of 0.044 is near-random. This failure is likely attributable to the PCA-transformed feature '
|
| 464 |
+
'space: the autoencoder learns to reconstruct the dominant variance directions, but the fraud signal may reside in minor PCA components '
|
| 465 |
+
'whose reconstruction error is similar to legitimate noise, making discrimination unreliable.'
|
| 466 |
+
)
|
| 467 |
+
pdf.p(
|
| 468 |
+
'Key Observation 4 - Optuna tuning shows mixed results: Tuning improved LightGBM dramatically (PR-AUC from 0.012 to 0.796) by '
|
| 469 |
+
'correcting an initial configuration where scale_pos_weight was too aggressive. However, the tuned XGBoost (0.793) slightly underperformed '
|
| 470 |
+
'the base XGBoost (0.817), suggesting the base configuration was already near-optimal and the tuning search space introduced suboptimal regions.'
|
| 471 |
+
)
|
| 472 |
+
|
| 473 |
+
pdf.fig(os.path.join(FIGURES_DIR, 'roc_curves.png'),
|
| 474 |
+
'Fig. 7. ROC curves for the top 5 models. All achieve ROC-AUC > 0.93, but ROC-AUC alone is insufficient for evaluation under extreme imbalance.', w=125)
|
| 475 |
+
pdf.fig(os.path.join(FIGURES_DIR, 'pr_curves.png'),
|
| 476 |
+
'Fig. 8. Precision-Recall curves -- the primary evaluation metric. XGBoost achieves the largest area under the curve (0.817).', w=125)
|
| 477 |
+
pdf.fig(os.path.join(FIGURES_DIR, 'confusion_matrices.png'),
|
| 478 |
+
'Fig. 9. Confusion matrices for six selected models. XGBoost achieves the best balance: 57 true positives with only 6 false positives.', w=160)
|
| 479 |
+
|
| 480 |
+
pdf.subsec('B.', 'Threshold Optimization')
|
| 481 |
+
pdf.p(
|
| 482 |
+
'The default classification threshold of 0.5 is a common but arbitrary choice that is rarely optimal, especially for imbalanced problems. '
|
| 483 |
+
'We perform a systematic sweep of thresholds from 0.05 to 0.95 for the best model (XGBoost) and evaluate Precision, Recall, F1, and MCC '
|
| 484 |
+
'at each threshold. Figure 10 visualizes the tradeoff. The optimal threshold by F1 is 0.55, which improves F1 from 0.851 to 0.864 and '
|
| 485 |
+
'precision from 0.905 to 0.934 while maintaining the same recall of 0.803. This means raising the threshold by 0.05 eliminates some '
|
| 486 |
+
'borderline false positives without losing any true positives, a Pareto improvement. At higher thresholds (>0.85), recall begins to drop '
|
| 487 |
+
'as the model becomes overly conservative. In practice, the operational threshold should be set based on the specific cost ratio between '
|
| 488 |
+
'missed fraud and false alarm investigation costs.'
|
| 489 |
+
)
|
| 490 |
+
pdf.fig(os.path.join(FIGURES_DIR, 'threshold_analysis.png'),
|
| 491 |
+
'Fig. 10. Threshold sensitivity analysis: (a) precision/recall/F1 vs. threshold, (b) MCC vs. threshold. Optimal F1 at threshold = 0.55.', w=145)
|
| 492 |
+
|
| 493 |
+
pdf.subsec('C.', 'Business Impact Analysis')
|
| 494 |
+
pdf.p(
|
| 495 |
+
'To translate ML metrics into actionable financial outcomes, we estimate the business impact using the average fraud transaction amount '
|
| 496 |
+
'of $122.21 and an estimated $5 per false alarm investigation cost. Table III shows that XGBoost provides the highest net savings ($6,936 '
|
| 497 |
+
'on the 42,559-transaction test set) by catching 57 of 71 fraudulent transactions (80.3% catch rate) while generating only 6 false alarms '
|
| 498 |
+
'($30 investigation cost). By contrast, Logistic Regression catches more fraud (63 of 71, 88.7%) but generates 1,229 false alarms at $6,145 '
|
| 499 |
+
'total investigation cost, reducing net savings to only $1,554. The Autoencoder, despite catching all 71 fraud transactions, generates '
|
| 500 |
+
'21,209 false alarms at $106,045 -- a net loss of $97,368.'
|
| 501 |
+
)
|
| 502 |
+
pdf.tbl(
|
| 503 |
+
['Model', 'TP', 'FN', 'FP', 'Caught($)', 'Missed($)', 'FP Cost($)', 'Net($)'],
|
| 504 |
[
|
| 505 |
+
['XGBoost', '57', '14', '6', '6,966', '1,711', '30', '6,936'],
|
| 506 |
+
['Ens.', '57', '14', '9', '6,966', '1,711', '45', '6,921'],
|
| 507 |
+
['LGBM-T', '58', '13', '24', '7,088', '1,589', '120', '6,968'],
|
| 508 |
+
['LR', '63', '8', '1229', '7,699', '978', '6,145', '1,554'],
|
| 509 |
+
['AE', '71', '0', '21209', '8,677', '0', '106,045', '-97,368'],
|
| 510 |
],
|
| 511 |
+
'Table III: Business Impact Analysis on Test Set'
|
| 512 |
+
)
|
| 513 |
+
pdf.p(
|
| 514 |
+
'This analysis underscores a critical insight: maximizing recall without regard for precision is counterproductive in operational settings. '
|
| 515 |
+
'The Autoencoder catches every fraud but would bankrupt the operations team with false alarm investigations. The optimal model balances '
|
| 516 |
+
'fraud catch rate against false alarm volume, and XGBoost achieves this balance most effectively.'
|
| 517 |
+
)
|
| 518 |
+
|
| 519 |
+
# ===== EXPLAINABILITY =====
|
| 520 |
+
pdf.subsec('D.', 'Feature Importance and Explainability')
|
| 521 |
+
pdf.p(
|
| 522 |
+
'Model explainability is critical for operational trust, regulatory compliance, and scientific insight. We employ two complementary methods: '
|
| 523 |
+
'SHAP for global feature attribution and LIME for local, instance-level explanation.'
|
| 524 |
+
)
|
| 525 |
+
pdf.p(
|
| 526 |
+
'SHAP Analysis: Figure 11 shows the SHAP summary plot for XGBoost, computed over 2,000 test samples. The top three features by '
|
| 527 |
+
'mean absolute SHAP value are V4 (1.913), V14 (1.843), and PCA_magnitude (1.113). The SHAP analysis reveals several important patterns: '
|
| 528 |
+
'(i) High values of V4 push predictions toward fraud, while low values push toward legitimate; (ii) Low (more negative) values of V14 '
|
| 529 |
+
'are strongly associated with fraud, consistent with the negative correlation observed in EDA; (iii) High PCA_magnitude indicates '
|
| 530 |
+
'transactions that are far from the centroid in PCA space, which are more likely to be anomalous. Notably, the engineered feature '
|
| 531 |
+
'V10_V14_interaction ranks 9th, validating our hypothesis that interaction terms capture additional signal beyond individual features.'
|
| 532 |
+
)
|
| 533 |
+
pdf.fig(os.path.join(FIGURES_DIR, 'shap_summary.png'),
|
| 534 |
+
'Fig. 11. SHAP summary plot: each dot is one test sample. Color indicates feature value (red=high, blue=low). Horizontal position shows SHAP impact.', w=140)
|
| 535 |
+
pdf.fig(os.path.join(FIGURES_DIR, 'shap_top10.png'),
|
| 536 |
+
'Fig. 12. Top 10 features by mean |SHAP value|. V4, V14, and PCA_magnitude are the dominant fraud predictors.', w=125)
|
| 537 |
+
|
| 538 |
+
pdf.p(
|
| 539 |
+
'LIME Analysis: For instance-level interpretability, we apply LIME to a correctly classified fraud transaction (P(fraud)=1.0000). '
|
| 540 |
+
'Figure 13 shows the contribution of each feature to this specific prediction. All top features push toward the fraud class, with '
|
| 541 |
+
'Time_diff, V4, V12, and V14 being the strongest contributors. This granular explanation could be presented to a human fraud '
|
| 542 |
+
'analyst to justify why a specific transaction was blocked, supporting regulatory requirements for explainable decisions.'
|
| 543 |
+
)
|
| 544 |
+
pdf.fig(os.path.join(FIGURES_DIR, 'lime_explanation.png'),
|
| 545 |
+
'Fig. 13. LIME explanation for a single fraud sample. Red bars increase fraud risk; green bars decrease it.', w=140)
|
| 546 |
+
pdf.fig(os.path.join(FIGURES_DIR, 'feature_importance.png'),
|
| 547 |
+
'Fig. 14. Feature importance comparison across four model types (RF, XGBoost, LightGBM, Logistic Regression).', w=155)
|
| 548 |
+
|
| 549 |
+
# ===== VII. ERROR ANALYSIS =====
|
| 550 |
+
pdf.section('VII', 'Error Analysis')
|
| 551 |
+
|
| 552 |
+
pdf.subsec('A.', 'False Negative Analysis (Missed Fraud)')
|
| 553 |
+
pdf.p(
|
| 554 |
+
'The XGBoost model misses 14 of 71 fraudulent transactions in the test set (19.7% miss rate). Understanding why these transactions '
|
| 555 |
+
'escape detection is critical for improving the system. Analysis of the 14 false negatives reveals that their mean predicted fraud '
|
| 556 |
+
'probability is only 0.013, far below the 0.5 threshold -- the model is highly confident they are legitimate, not merely borderline.'
|
| 557 |
+
)
|
| 558 |
+
pdf.p(
|
| 559 |
+
'Feature comparison provides the explanation: false negatives have V14 averaging -0.97 compared to -8.45 for true positives (a 7.5x '
|
| 560 |
+
'difference), V12 averaging -0.41 vs -7.69, and PCA_magnitude of 1.82 vs 12.25. In other words, missed fraud transactions have feature '
|
| 561 |
+
'values that are dramatically closer to legitimate transactions than to caught fraud. These represent sophisticated fraud attempts that '
|
| 562 |
+
'have been designed (intentionally or coincidentally) to mimic legitimate behavioral patterns. They operate within normal amount ranges, '
|
| 563 |
+
'at normal hours, and produce PCA component values that fall squarely within the legitimate distribution.'
|
| 564 |
+
)
|
| 565 |
+
pdf.p(
|
| 566 |
+
'Implication: These false negatives cannot be eliminated by simply lowering the threshold -- at threshold 0.12, only one additional '
|
| 567 |
+
'FN would be caught while generating many more false alarms. Catching these sophisticated fraud attempts likely requires additional '
|
| 568 |
+
'data sources (transaction sequences, device fingerprints, geographic data) that are not available in the PCA-anonymized dataset.'
|
| 569 |
+
)
|
| 570 |
+
|
| 571 |
+
pdf.subsec('B.', 'False Positive Analysis (False Alarms)')
|
| 572 |
+
pdf.p(
|
| 573 |
+
'The 6 false positives have a mean predicted fraud probability of 0.827, with some reaching 1.0 -- the model is highly confident '
|
| 574 |
+
'these are fraud, yet they are legitimate. Feature analysis shows these transactions have V14 averaging -7.13 (vs -0.04 for true negatives) '
|
| 575 |
+
'and PCA_magnitude of 7.86 (vs 0.28 for true negatives). These legitimate transactions genuinely exhibit the same anomalous feature '
|
| 576 |
+
'patterns as actual fraud, likely representing unusual but lawful spending behavior (e.g., first-time purchases in an unusual category, '
|
| 577 |
+
'international transactions, or large purchases for individuals who typically make small ones). No amount of model tuning can distinguish '
|
| 578 |
+
'these from actual fraud without additional contextual information.'
|
| 579 |
+
)
|
| 580 |
+
|
| 581 |
+
pdf.subsec('C.', 'Concept Drift Assessment and Retraining Recommendations')
|
| 582 |
+
pdf.p(
|
| 583 |
+
'Comparing model confidence between the first and second halves of the test period reveals a drift indicator of +0.115 in mean fraud '
|
| 584 |
+
'probability for actual fraud cases. While this magnitude is modest, it suggests that even within the two-day dataset window, the '
|
| 585 |
+
'statistical properties of fraud are not stationary.'
|
| 586 |
+
)
|
| 587 |
+
pdf.p('Based on this analysis and industry best practices, we recommend the following operational monitoring regime:')
|
| 588 |
+
pdf.bullet([
|
| 589 |
+
'Weekly computation of PR-AUC, F1, and false positive rate on recent labeled data to track model degradation.',
|
| 590 |
+
'Automated retraining trigger when PR-AUC drops below 0.70 or false positive rate exceeds 2x the baseline.',
|
| 591 |
+
'Sliding window training using the most recent 3-6 months of labeled data, rather than static historical training.',
|
| 592 |
+
'Population Stability Index (PSI) monitoring on all input features, with alerts when PSI exceeds 0.25 for any feature.',
|
| 593 |
+
'A/B testing framework for deploying model updates, with gradual traffic ramps from 1% to 100%.',
|
| 594 |
+
'Quarterly fraud pattern reviews with domain experts to identify emerging attack vectors that models may not yet capture.',
|
| 595 |
+
])
|
| 596 |
+
pdf.fig(os.path.join(FIGURES_DIR, 'error_analysis.png'),
|
| 597 |
+
'Fig. 15. Error analysis: (a) FN probability distribution, (b) FP probability distribution, (c) overall score distribution by class.', w=160)
|
| 598 |
+
|
| 599 |
+
# ===== VIII. LIMITATIONS =====
|
| 600 |
+
pdf.section('VIII', 'Limitations')
|
| 601 |
+
pdf.p('We acknowledge several important limitations of this work:')
|
| 602 |
+
pdf.bullet([
|
| 603 |
+
'PCA Anonymization: The V1-V28 features are PCA-transformed, which prevents domain-specific feature engineering (merchant category, geographic location, card type) and limits interpretability. Real-world systems with access to raw features would likely achieve significantly better performance.',
|
| 604 |
+
'Temporal Scope: The dataset covers only two days of transactions, severely limiting assessment of long-term concept drift, seasonal patterns, and fraud evolution over weeks or months.',
|
| 605 |
+
'Single-Institution Data: Results from one European bank may not generalize across different institutions, geographies, payment networks, or regulatory environments.',
|
| 606 |
+
'Static Feature Set: Our feature engineering does not incorporate sequential transaction history (e.g., spending velocity over the past week, unusual merchant for this cardholder). Such features are critical in production systems but require per-customer state management.',
|
| 607 |
+
'Static Threshold: The optimal threshold of 0.55 was determined on the test set and may shift as fraud patterns evolve. A production system should implement dynamic threshold adaptation based on recent performance metrics.',
|
| 608 |
+
'Limited Autoencoder Architecture: Our autoencoder uses a simple symmetric architecture. More advanced anomaly detection methods (Variational Autoencoders, adversarial training) might achieve better performance on this task.',
|
| 609 |
+
])
|
| 610 |
+
|
| 611 |
+
# ===== IX. FUTURE WORK =====
|
| 612 |
+
pdf.section('IX', 'Future Work')
|
| 613 |
+
pdf.p('Several promising research directions emerge from this work:')
|
| 614 |
+
pdf.p(
|
| 615 |
+
'Graph Neural Networks for Fraud Ring Detection [19]: Modeling the transaction network as a graph -- where nodes represent cards, '
|
| 616 |
+
'merchants, and accounts, and edges represent transactions -- would enable detection of coordinated fraud rings that cannot be identified '
|
| 617 |
+
'from individual transaction features alone. Graph convolutional networks can propagate suspicion scores through the network, flagging '
|
| 618 |
+
'accounts that transact heavily with known fraudulent nodes.'
|
| 619 |
+
)
|
| 620 |
+
pdf.p(
|
| 621 |
+
'Real-Time Streaming with Apache Kafka: Production fraud detection requires sub-100ms end-to-end latency from transaction initiation '
|
| 622 |
+
'to decision. Integrating the model with Apache Kafka for event streaming and Apache Flink for real-time feature computation would '
|
| 623 |
+
'enable processing millions of transactions per second with consistent low-latency guarantees.'
|
| 624 |
+
)
|
| 625 |
+
pdf.p(
|
| 626 |
+
'Federated Learning Across Banks [20]: Individual banks have limited fraud data, especially for rare fraud types. Federated learning '
|
| 627 |
+
'allows multiple institutions to collaboratively train a shared model without exchanging raw transaction data, preserving customer '
|
| 628 |
+
'privacy while dramatically expanding the effective training set. This is particularly valuable for detecting cross-institutional '
|
| 629 |
+
'fraud patterns where the same stolen credentials are used across multiple banks.'
|
| 630 |
+
)
|
| 631 |
+
pdf.p(
|
| 632 |
+
'LLM-Generated Compliance Explanations: When a transaction is blocked, regulatory requirements often demand a human-readable justification. '
|
| 633 |
+
'Large language models could translate SHAP values and feature contributions into natural-language narratives '
|
| 634 |
+
'(e.g., "This transaction was blocked because the purchase amount was unusually high for this card, occurring at an unusual time, '
|
| 635 |
+
'with spending patterns inconsistent with the cardholder\'s history"), reducing the burden on human fraud analysts.'
|
| 636 |
+
)
|
| 637 |
+
pdf.p(
|
| 638 |
+
'Temporal Sequence Modeling: Transformers and LSTM networks operating on the sequence of a cardholder\'s recent transactions could capture '
|
| 639 |
+
'behavioral patterns (typical spending days, preferred merchants, usual amounts) and flag departures from established routines. '
|
| 640 |
+
'This approach treats fraud detection as an anomaly in a time series rather than a static classification problem.'
|
| 641 |
+
)
|
| 642 |
+
|
| 643 |
+
# ===== X. CONCLUSION =====
|
| 644 |
+
pdf.section('X', 'Conclusion')
|
| 645 |
+
pdf.p(
|
| 646 |
+
'This paper presents a comprehensive, end-to-end fraud detection framework that systematically evaluates seven diverse machine learning '
|
| 647 |
+
'approaches on the benchmark European Cardholder credit card fraud dataset. Through careful feature engineering (12 new features), '
|
| 648 |
+
'rigorous methodology (SMOTE after splitting, scaler fitted on train only), and thorough evaluation (six metrics including PR-AUC, MCC), '
|
| 649 |
+
'we demonstrate that XGBoost with cost-sensitive learning achieves the best overall performance with a PR-AUC of 0.817, F1-score of 0.851, '
|
| 650 |
+
'and MCC of 0.852.'
|
| 651 |
+
)
|
| 652 |
+
pdf.p(
|
| 653 |
+
'Our threshold optimization analysis reveals that shifting the decision boundary from 0.50 to 0.55 yields a Pareto improvement, '
|
| 654 |
+
'increasing F1 to 0.864 and precision to 0.934 without sacrificing recall. Business impact analysis quantifies that XGBoost catches '
|
| 655 |
+
'80.3% of fraud while generating only 6 false alarms on a 42,559-transaction test set, resulting in estimated net savings of $6,936. '
|
| 656 |
+
'In contrast, the Autoencoder catches all fraud but generates over 21,000 false alarms -- a cautionary tale against optimizing recall alone.'
|
| 657 |
+
)
|
| 658 |
+
pdf.p(
|
| 659 |
+
'SHAP and LIME explainability analysis identifies V4, V14, and PCA_magnitude as the primary fraud discriminators, providing actionable '
|
| 660 |
+
'insights for fraud investigation teams. Error analysis reveals that the 14 missed fraud cases represent sophisticated attacks whose '
|
| 661 |
+
'feature profiles are indistinguishable from legitimate transactions, suggesting that additional data sources beyond PCA-anonymized '
|
| 662 |
+
'features are needed to catch the most evasive fraud.'
|
| 663 |
+
)
|
| 664 |
+
pdf.p(
|
| 665 |
+
'The complete system -- from feature engineering through model training, evaluation, explainability, and FastAPI deployment with sub-10ms '
|
| 666 |
+
'latency -- demonstrates that production-grade fraud detection can be achieved with well-tuned classical ML methods. Tree-based ensemble '
|
| 667 |
+
'methods, particularly XGBoost, remain the state-of-the-art for tabular fraud detection, outperforming both deep learning (MLP, Autoencoder) '
|
| 668 |
+
'and linear (Logistic Regression) alternatives on all metrics that matter for imbalanced classification.'
|
| 669 |
+
)
|
| 670 |
+
|
| 671 |
+
# ===== REFERENCES =====
|
| 672 |
+
pdf.section('', 'References')
|
| 673 |
refs = [
|
| 674 |
+
'[1] A. Dal Pozzolo, O. Caelen, R. A. Johnson, and G. Bontempi, "Calibrating probability with undersampling for unbalanced classification," in Proc. IEEE CIDM, 2015, pp. 159-166.',
|
| 675 |
+
'[2] N. V. Chawla, K. W. Bowyer, L. O. Hall, and W. P. Kegelmeyer, "SMOTE: Synthetic Minority Over-sampling Technique," J. Artificial Intelligence Research, vol. 16, pp. 321-357, 2002.',
|
| 676 |
+
'[3] A. Fernandez, S. Garcia, M. Galar, R. C. Prati, B. Krawczyk, and F. Herrera, Learning from Imbalanced Data Sets. Springer, 2018.',
|
| 677 |
+
'[4] T. Chen and C. Guestrin, "XGBoost: A scalable tree boosting system," in Proc. 22nd ACM SIGKDD, 2016, pp. 785-794.',
|
| 678 |
+
'[5] G. Ke, Q. Meng, T. Finley, et al., "LightGBM: A highly efficient gradient boosting decision tree," in NeurIPS, vol. 30, 2017.',
|
| 679 |
+
'[6] A. Pumsirirat and L. Yan, "Credit card fraud detection using deep learning based on auto-encoder," IJACSA, vol. 9, no. 1, 2018.',
|
| 680 |
+
'[7] S. M. Lundberg and S.-I. Lee, "A unified approach to interpreting model predictions," in NeurIPS, vol. 30, 2017.',
|
| 681 |
+
'[8] M. T. Ribeiro, S. Singh, and C. Guestrin, "Why should I trust you?: Explaining the predictions of any classifier," in Proc. ACM SIGKDD, 2016, pp. 1135-1144.',
|
| 682 |
+
'[9] R. Shwartz-Ziv and A. Armon, "Tabular data: Deep learning is not all you need," Information Fusion, vol. 81, pp. 84-90, 2022.',
|
| 683 |
+
'[10] L. Grinsztajn, E. Oyallon, and G. Varoquaux, "Why do tree-based models still outperform deep learning on tabular data?," in NeurIPS, vol. 35, 2022.',
|
| 684 |
+
'[11] T. Akiba, S. Sano, T. Yanase, T. Ohta, and M. Koyama, "Optuna: A next-generation hyperparameter optimization framework," in Proc. ACM SIGKDD, 2019.',
|
| 685 |
+
'[12] R. J. Bolton and D. J. Hand, "Statistical fraud detection: A review," Statistical Science, vol. 17, no. 3, pp. 235-255, 2002.',
|
| 686 |
+
'[13] Z. Zhang, X. Zhou, X. Zhang, L. Wang, and P. Wang, "A model based on convolutional recurrent neural network for fraud detection," Complexity, 2021.',
|
| 687 |
+
'[14] A. A. Taha and S. J. Malebary, "An intelligent approach to credit card fraud detection using an optimized light gradient boosting machine," IEEE Access, vol. 8, 2020.',
|
| 688 |
+
'[15] V. Belle and I. Papantonis, "Principles and practice of explainable machine learning," Frontiers in Big Data, vol. 4, 2021.',
|
| 689 |
+
'[16] L. Prokhorenkova, G. Gusev, A. Vorobev, A. V. Dorogush, and A. Gulin, "CatBoost: Unbiased boosting with categorical features," in NeurIPS, vol. 31, 2018.',
|
| 690 |
+
'[17] S. Xuan, G. Liu, Z. Li, L. Zheng, S. Wang, and C. Jiang, "Random forest for credit card fraud detection," in Proc. IEEE ICNSC, 2018.',
|
| 691 |
+
'[18] T. Saito and M. Rehmsmeier, "The precision-recall plot is more informative than the ROC plot when evaluating binary classifiers on imbalanced datasets," PLoS ONE, 2015.',
|
| 692 |
+
'[19] Y. Liu, M. Ao, C. Chi, F. Feng, D. Yang, and J. He, "Pick and choose: A GNN-based imbalanced learning approach for fraud detection," in Web Conf., 2021.',
|
| 693 |
+
'[20] Q. Yang, Y. Liu, T. Chen, and Y. Tong, "Federated machine learning: Concept and applications," ACM TIST, vol. 10, no. 2, 2019.',
|
| 694 |
'[21] Nilson Report, "Global card fraud losses," Issue 1209, 2022.',
|
| 695 |
+
'[22] A. Dal Pozzolo, O. Caelen, and G. Bontempi, "When is undersampling effective in unbalanced classification tasks?," in ECML PKDD, 2015.',
|
| 696 |
]
|
| 697 |
+
pdf.set_font('Times', '', 7.5)
|
|
|
|
| 698 |
for ref in refs:
|
| 699 |
pdf.multi_cell(0, 3.5, ref)
|
| 700 |
+
pdf.ln(0.8)
|
| 701 |
+
|
| 702 |
# Save
|
| 703 |
+
out = os.path.join(PAPER_DIR, 'fraud_detection_paper.pdf')
|
| 704 |
+
pdf.output(out)
|
| 705 |
+
print(f"\nPDF saved: {out} ({pdf.page_no()} pages)")
|
|
|
|
| 706 |
|
| 707 |
|
| 708 |
+
if __name__ == '__main__':
|
| 709 |
+
build()
|
paper/figures/amount_analysis.pdf
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0b26a10e4d1972c4e9ffe27982f43efaec36bdbf4458ac75b9fe7491a9cbfa09
|
| 3 |
+
size 198161
|
paper/figures/amount_analysis.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
paper/figures/architecture_diagram.pdf
CHANGED
|
Binary files a/paper/figures/architecture_diagram.pdf and b/paper/figures/architecture_diagram.pdf differ
|
|
|
paper/figures/architecture_diagram.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
paper/figures/class_distribution.pdf
CHANGED
|
Binary files a/paper/figures/class_distribution.pdf and b/paper/figures/class_distribution.pdf differ
|
|
|
paper/figures/class_distribution.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
paper/figures/confusion_matrices.pdf
CHANGED
|
Binary files a/paper/figures/confusion_matrices.pdf and b/paper/figures/confusion_matrices.pdf differ
|
|
|
paper/figures/confusion_matrices.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
paper/figures/correlation_heatmap.pdf
CHANGED
|
Binary files a/paper/figures/correlation_heatmap.pdf and b/paper/figures/correlation_heatmap.pdf differ
|
|
|
paper/figures/correlation_heatmap.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
paper/figures/error_analysis.pdf
CHANGED
|
Binary files a/paper/figures/error_analysis.pdf and b/paper/figures/error_analysis.pdf differ
|
|
|
paper/figures/error_analysis.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
paper/figures/feature_distributions.pdf
CHANGED
|
Binary files a/paper/figures/feature_distributions.pdf and b/paper/figures/feature_distributions.pdf differ
|
|
|
paper/figures/feature_distributions.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
paper/figures/feature_importance.pdf
CHANGED
|
Binary files a/paper/figures/feature_importance.pdf and b/paper/figures/feature_importance.pdf differ
|
|
|
paper/figures/feature_importance.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
paper/figures/lime_explanation.pdf
CHANGED
|
Binary files a/paper/figures/lime_explanation.pdf and b/paper/figures/lime_explanation.pdf differ
|
|
|
paper/figures/lime_explanation.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
paper/figures/pr_curves.pdf
CHANGED
|
Binary files a/paper/figures/pr_curves.pdf and b/paper/figures/pr_curves.pdf differ
|
|
|