This project investigates the application of unsupervised machine learning techniques for detecting anomalous transactions in financial datasets. Since real-world financial data often lack labelled examples of fraudulent or abnormal activities, unsupervised approaches provide an effective solution for identifying unusual behavioural patterns.
The study combines mathematical concepts and experimental analysis to evaluate different anomaly detection techniques and compare their ability to identify abnormal transaction behaviour.
Financial institutions process millions of transactions every day, making manual monitoring impractical. Detecting unusual transactions at an early stage can help identify potential fraud, system misuse, or abnormal customer behaviour.
The primary objective of this project is to explore how different unsupervised learning algorithms identify anomalies in financial transaction data and to compare their behaviour using a common dataset.
Source: Kaggle Financial Transactions Dataset
-
Total Records: 50,000
-
Multiple numerical and categorical features
-
Examples of features:
- TransactionAmount
- TransactionDuration
- LoginAttempts
- AccountBalance
- Customer-related attributes
The following preprocessing steps were performed:
- Missing value inspection
- Date and time feature engineering
- Categorical feature encoding
- Feature scaling and normalization
- Exploratory data analysis
- Feature preparation for anomaly detection models
PCA reduces the dimensionality of the dataset while preserving maximum variance.
Anomaly Detection Principle
Transactions are reconstructed from principal components and reconstruction error is calculated:
Reconstruction Error = ||x − x̂||²
Large reconstruction error indicates anomalous behaviour.
Isolation Forest identifies anomalies through random feature partitioning.
Anomaly Detection Principle
Anomalous observations require fewer partitions and therefore have shorter isolation path lengths.
DBSCAN identifies anomalies as observations that do not belong to dense neighbourhood regions.
Observations with insufficient neighbours are classified as noise points and treated as anomalies.
GMM models transaction behaviour using multiple Gaussian probability distributions.
Transactions with low likelihood values are identified as anomalous observations.
| Method | Anomalies Detected | Detection Principle |
|---|---|---|
| PCA | 2500 | Reconstruction Error |
| Isolation Forest | 2500 | Isolation Depth |
| DBSCAN | 2896 | Density-Based Noise Detection |
| Gaussian Mixture Model | 2500 | Probabilistic Likelihood |
- PCA successfully identified transactions with high reconstruction error.
- Isolation Forest detected observations requiring fewer partitions.
- DBSCAN identified sparse observations outside dense behavioural clusters.
- GMM detected low-probability transactions under the learned probability distribution.
- Anomalous transactions generally exhibited higher transaction amounts and increased login activity compared to normal observations.
The project will be extended by incorporating:
Distance-based anomaly scoring:
Deep learning approach based on reconstruction loss:
Future work will focus on comparing classical machine learning techniques with deep learning approaches for anomaly detection in financial transaction datasets.
- Python
- Pandas
- NumPy
- Matplotlib
- Seaborn
- Scikit-Learn
- Jupyter Notebook
├── data/
│ └── financial_transactions.csv
│
├── notebooks/
│ └── anomaly_detection.ipynb
│
├── report/
│ └── Project_Report.pdf
│
├── presentation/
│ └── Viva_Presentation.pptx
│
├── README.md
│
└── requirements.txt
- Bishop, C. M. Pattern Recognition and Machine Learning. Springer, 2006.
- Ester, M., Kriegel, H.-P., Sander, J., & Xu, X. (1996). A density-based algorithm for discovering clusters in large spatial databases with noise.
- Aggarwal, C. C. Outlier Analysis, 2nd Edition. Springer, 2017.
- Cover, T. M., & Hart, P. E. (1967). Nearest Neighbor Pattern Classification.
- Géron, A. Hands-On Machine Learning with Scikit-Learn, Keras & TensorFlow.
Rajat Kumar
Professional Master's Program in Data Science and AI
Academic Project – Unsupervised Anomaly Detection in Financial Transaction Data