Introduction
Every day, millions of financial transactions take place across the world through credit cards, online payments, and digital banking platforms. While digital payments have made transactions faster and more convenient, they have also created new opportunities for fraudulent activities.
Credit card fraud remains one of the biggest challenges faced by financial institutions. Fraudulent transactions result in direct financial losses, increased operational costs, chargebacks, damaged customer trust, and significant pressure on organizations to build systems capable of identifying suspicious activities quickly and accurately.
Traditional fraud detection systems often rely on predefined rules such as transaction limits, unusual locations, or suspicious spending patterns. Although rule-based systems can detect known fraud patterns, they struggle when fraudsters develop new techniques that bypass existing rules.
Machine learning provides an alternative approach by allowing systems to learn patterns from historical transaction data and identify potentially fraudulent behavior. Instead of relying only on manually defined rules, machine learning models analyze multiple transaction characteristics and estimate the probability that a transaction is fraudulent.
However, credit card fraud detection presents a unique machine learning challenge: extreme class imbalance.
Unlike many classification problems where classes are relatively balanced, fraudulent transactions represent only a tiny fraction of all financial activity. A model can achieve extremely high accuracy simply by predicting that almost every transaction is legitimate while failing at the one task that matters most — identifying fraud.
This project explores the development of a machine learning-based credit card fraud detection system using multiple imbalanced learning techniques. The goal was not only to build a predictive model but also to understand how different approaches handle rare fraud cases and identify the best balance between detecting fraudulent transactions and minimizing false alarms.
The project evaluated multiple machine learning algorithms, including Logistic Regression, Random Forest, and XGBoost, while applying different imbalance handling techniques such as:
- SMOTE (Synthetic Minority Oversampling Technique)
- Random Undersampling
- Class Weighting
- XGBoost scale_pos_weight
The models were evaluated using metrics more appropriate for fraud detection, including:
- Precision
- Recall
- F1-score
- ROC-AUC
The final model was further analyzed using confusion matrices, threshold tuning, and SHAP explainability to understand not only whether the model detected fraud but also why specific transactions were classified as fraudulent.
Understanding the Credit Card Fraud Detection Problem
At its core, fraud detection is a binary classification problem. Each transaction belongs to one of two categories:
- Legitimate transaction (Class 0)
- Fraudulent transaction (Class 1)
The objective of the machine learning model is to learn patterns from historical transactions and predict whether new transactions are legitimate or fraudulent. However, unlike typical classification problems, fraud detection has an important asymmetry: the consequences of mistakes are not equal. A false prediction can happen in two ways:
False Positive
A legitimate transaction is incorrectly classified as fraudulent.
Example: A customer makes a genuine purchase, but the system blocks the transaction because it appears suspicious.
Consequences:
- Customer frustration
- Failed payments
- Additional manual investigations
- Poor customer experience
False Negative
A fraudulent transaction is incorrectly classified as legitimate.
Example: A stolen credit card is used for an unauthorized transaction, but the system fails to detect it.
Consequences:
- Direct financial losses
- Customer disputes
- Increased fraud exposure
- Loss of trust
In most financial systems, false negatives are significantly more costly than false positives. Missing fraudulent activity can result in much larger financial damage than temporarily reviewing a legitimate transaction.
This makes fraud detection a problem where the goal is not simply maximizing accuracy. Instead, the focus is finding a model that achieves the right balance between:
- Detecting as much fraud as possible
- Avoiding unnecessary disruption to legitimate customers
Why Accuracy Is Misleading in Fraud Detection
One of the biggest mistakes when working with imbalanced datasets is relying heavily on accuracy. Accuracy measures the percentage of predictions the model gets correct:
- Accuracy = Correct Predictions / Total Predictions
At first glance, accuracy appears useful. However, in fraud detection, it can create a false sense of success. Imagine a dataset containing:
- 99.83% legitimate transactions
- 0.17% fraudulent transactions
A model that predicts every transaction as legitimate would achieve approximately 99.83% accuracy. It sounds impressive but the model would detect zero fraudulent transactions. For a fraud detection system, such a model would be completely useless.
This is why this project focuses on evaluation metrics designed for imbalanced classification problems.
- Precision: Precision answers the question: "When the model predicts fraud, how often is it actually correct?" A high precision score means fewer legitimate transactions are incorrectly flagged. This is important because financial institutions do not want their fraud investigation teams overwhelmed by false alarms.
- Recall: Recall answers the question: "Of all actual fraudulent transactions, how many did the model successfully detect?" A high recall score means the model catches more fraud cases. In fraud detection, improving recall is often valuable because missing fraud can be extremely expensive.
- F1-Score: The F1-score combines precision and recall into a single metric. It provides a balance between catching fraudulent transactions and avoiding unnecessary false alerts. Because fraud detection requires balancing these competing priorities, F1-score is often more meaningful than accuracy.
Dataset Overview
The dataset used in this project was obtained from Kaggle and contains historical credit card transactions labeled as either legitimate or fraudulent. Due to confidentiality concerns, the original transaction features were anonymized. The dataset contains:
- 28 anonymized numerical features (V1 to V28)
- Transaction time (Time)
- Transaction amount (Amount)
- Target variable (Class)
The target variable represents:
- Class = 0 → Legitimate transaction
- Class = 1 → Fraudulent transaction
The anonymized variables were transformed using Principal Component Analysis (PCA) by the original dataset creators to protect sensitive financial information while maintaining useful patterns for machine learning.
After removing duplicate records, the dataset contained: 283,726 transactions with 30 input features and 1 target variable.
The class distribution was extremely imbalanced:
- Approximately 99.83% legitimate transactions
- Approximately 0.17% fraudulent transactions
This imbalance became the central challenge of the project.
Why Imbalanced Learning Was Necessary
Machine learning algorithms generally perform best when they have enough examples from each class to learn meaningful patterns.
In this dataset:
- Legitimate transactions had hundreds of thousands of examples.
- Fraudulent transactions represented only a very small minority.
Without addressing this imbalance, many algorithms would naturally favor the majority class.
For example, a model might learn: "Most transactions are legitimate, therefore predicting legitimate most of the time gives good performance." While this strategy improves accuracy, it fails the primary objective of fraud detection. To overcome this challenge, this project investigated several imbalanced learning techniques.
SMOTE (Synthetic Minority Oversampling Technique)
SMOTE improves class balance by generating synthetic examples of the minority class. Instead of simply duplicating existing fraudulent transactions, SMOTE creates new synthetic fraud samples based on similarities between existing fraud cases.
The advantage is that the model receives more examples of fraudulent behavior without simply memorizing duplicate transactions. However, synthetic data generation must be carefully evaluated because artificially created examples may not always perfectly represent real-world fraud patterns.
Random Undersampling
Random undersampling reduces the number of legitimate transactions to create a more balanced dataset. The advantage is faster training and improved class balance. The disadvantage is that removing legitimate transactions may discard useful information about normal customer behavior.
Class Weighting
Class weighting does not modify the dataset. Instead, it changes how the algorithm treats mistakes. Misclassifying a fraudulent transaction receives a higher penalty than misclassifying a legitimate transaction.
This encourages the model to pay more attention to the minority class.
XGBoost Scale Positive Weight
XGBoost provides a specialized parameter called scale_pos_weight, which increases the importance of minority class errors during training. This technique is commonly used for highly imbalanced classification problems.
Exploratory Data Analysis: Understanding the Data Before Building Models
Before training any machine learning model, it is essential to understand the underlying data. Exploratory Data Analysis (EDA) provides valuable insights into the structure, quality, and distribution of the dataset while revealing patterns that may influence model performance.
For fraud detection, EDA serves an even greater purpose. Since fraudulent transactions are exceptionally rare, visualizing the data helps quantify the degree of imbalance, identify potential preprocessing requirements, and determine whether certain features exhibit stronger relationships with fraudulent activity.
The exploratory analysis in this project focused on:
- Class distribution
- Transaction amount distribution
- Feature correlations
- Relationships between features and the fraud class
These analyses established the foundation for selecting appropriate preprocessing techniques and machine learning algorithms.
Class Distribution Analysis

The first step was examining the distribution of the target variable. After removing duplicate records, the dataset contained approximately 283,726 transactions, of which:
- 99.83% were legitimate transactions
- 0.17% were fraudulent transactions
The visualization immediately highlights one of the defining characteristics of fraud detection datasets: extreme class imbalance.
While the legitimate class dominates the dataset, fraudulent transactions occupy only a tiny fraction of the observations. This imbalance presents a significant challenge because many machine learning algorithms assume that classes are relatively balanced during training.
Without appropriate handling, a model can become biased toward predicting the majority class simply because it encounters legitimate transactions far more frequently than fraudulent ones.
The visualization reinforces why this project prioritizes evaluation metrics such as Precision, Recall, and F1-score over overall accuracy. It also justifies investigating specialized techniques like SMOTE, class weighting, and undersampling to improve the model's ability to recognize the minority class.
Transaction Amount Distribution

The distribution of transaction amounts provides another important perspective on customer behavior. The histogram reveals a highly right-skewed distribution. Most transactions involve relatively small amounts, while only a limited number represent high-value purchases.
This pattern is expected in financial transaction datasets, where everyday purchases such as groceries, subscriptions, transportation, and online shopping greatly outnumber expensive transactions.
Interestingly, fraudulent transactions are not necessarily concentrated among high-value purchases. Fraudsters often attempt smaller transactions to avoid triggering fraud detection systems before progressing to larger unauthorized purchases.
Because of this skewed distribution, directly applying algorithms that are sensitive to feature scales can reduce model performance. To address this issue, the Time and Amount features were transformed using RobustScaler.
Unlike StandardScaler, which relies on the mean and standard deviation, RobustScaler uses the median and interquartile range (IQR), making it considerably more resistant to extreme outliers. This makes it particularly suitable for financial transaction data where unusually large purchases naturally occur.
Correlation Heatmap

Understanding relationships between variables helps determine whether features contain redundant information or exhibit multicollinearity that could negatively affect certain machine learning algorithms.
The correlation heatmap showed relatively weak relationships among most features. This outcome is expected because the original dataset creators transformed the confidential transaction variables using Principal Component Analysis (PCA) before releasing the dataset.
PCA creates new orthogonal components that capture most of the variance while minimizing correlations between variables. As a result, the transformed features (V1–V28) display very little multicollinearity.
From a modeling perspective, this is beneficial. Low correlation between features reduces redundancy and allows many machine learning algorithms to extract information from multiple independent dimensions instead of repeatedly learning the same patterns.
Although the variables have been anonymized, they still preserve enough statistical information for predictive modeling without exposing sensitive customer or merchant data.
Feature Correlation with Fraud Class

While the overall feature correlations remain relatively weak, several variables demonstrate much stronger relationships with the target variable.
The analysis showed that features such as V17, V14, V12, and V10 exhibited the strongest negative correlations with fraudulent transactions, while variables including V4 and V11 displayed stronger positive relationships.
Since the features have been anonymized through PCA, their real-world meanings remain unknown. Nevertheless, the strength of their correlations indicates that these variables contain important information for distinguishing legitimate transactions from fraudulent ones.
Rather than interpreting the financial meaning of these variables, the analysis focuses on their predictive value. Features with stronger correlations are more likely to influence machine learning predictions and later become significant contributors in model explainability techniques such as SHAP.
This observation proved particularly valuable during model interpretation, where several of these variables emerged among the most influential predictors.
Data Preprocessing
Machine learning models are only as effective as the quality of the data they learn from. Before training the models, several preprocessing steps were performed to ensure the dataset was clean, consistent, and suitable for classification.
- Duplicate Removal: The first preprocessing step involved identifying and removing duplicate transaction records. Duplicate observations can introduce bias by allowing models to repeatedly learn identical examples, artificially inflating performance metrics and reducing generalization. After removing duplicates, the dataset contained 283,726 unique transactions, providing a cleaner and more representative sample for training and evaluation.
- Feature Scaling: Most machine learning algorithms benefit from features being on comparable numerical scales. The dataset already contained PCA-transformed variables that were standardized during the original preprocessing performed by the dataset creators. However, the Time and Amount variables remained on their original scales. Rather than applying standard normalization, RobustScaler was used. Robust scaling was chosen because financial transaction data naturally contains outliers. Extremely large purchases, although uncommon, are legitimate and should not excessively influence feature scaling. By centering the data around the median instead of the mean, RobustScaler minimizes the impact of these outliers while preserving meaningful differences between transactions.
- Stratified Train-Test Split: Maintaining the original fraud ratio during model evaluation is critical. If the train-test split were performed randomly without considering class proportions, one subset could accidentally contain significantly more fraud cases than the other, leading to misleading evaluation results. To prevent this, the dataset was divided using stratified sampling, ensuring both the training and testing datasets preserved the same distribution of legitimate and fraudulent transactions. This approach produces a more realistic evaluation of how the models would perform on unseen data.
Building and Evaluating Multiple Machine Learning Models
Rather than relying on a single algorithm, this project evaluated multiple machine learning approaches to determine which model best addressed the challenges posed by highly imbalanced fraud detection data.
The models selected represent different families of machine learning algorithms, each with unique strengths and weaknesses.
Logistic Regression
Logistic Regression served as the baseline linear model.
Despite its simplicity, Logistic Regression remains one of the most widely used classification algorithms due to its interpretability, computational efficiency, and ability to establish strong baseline performance.
To evaluate how imbalance handling affected linear models, four variations were trained:
- Baseline Logistic Regression
- Logistic Regression with SMOTE
- Logistic Regression with Random Undersampling
- Logistic Regression with Class Weighting
These experiments demonstrated how different balancing techniques influence precision and recall in linear classifiers.
Random Forest
Random Forest is an ensemble learning algorithm that combines numerous decision trees to produce more stable and accurate predictions. Unlike individual decision trees, Random Forest reduces variance through bootstrap aggregation (bagging), making it more robust to noise and capable of capturing complex nonlinear relationships within the data.
Two versions were evaluated:
- Baseline Random Forest
- Balanced Random Forest using class weighting
Random Forest ultimately emerged as the strongest-performing model in this project.
XGBoost
Extreme Gradient Boosting (XGBoost) is one of the most powerful machine learning algorithms available for structured tabular data. Unlike Random Forest, which builds trees independently, XGBoost constructs trees sequentially, allowing each new tree to correct the errors made by previous ones.
Two configurations were evaluated:
- Baseline XGBoost
- XGBoost with scale_pos_weight
The scale_pos_weight parameter increased the importance assigned to fraudulent transactions during training, helping the algorithm focus more effectively on the minority class. Although XGBoost achieved an impressive ROC-AUC score, it did not surpass Random Forest when evaluated using the F1-score, which better reflects the balance between precision and recall required for fraud detection.
Model Comparison
After training each model, their performance was evaluated using Precision, Recall, F1-score, and ROC-AUC.
The comparison revealed an important insight: more complex imbalance-handling techniques did not always produce better overall performance.
The baseline Random Forest model achieved the highest F1-score of 0.838, outperforming both its balanced counterpart and the XGBoost models.
This finding demonstrates an important lesson in applied machine learning: sophisticated preprocessing techniques and more advanced algorithms do not automatically guarantee superior results. Model performance should always be validated empirically using metrics aligned with the business objective rather than assumptions about algorithm complexity.
Furthermore, the comparison highlighted the trade-offs introduced by different imbalance strategies. Techniques that substantially increased recall often did so at the expense of precision, generating more false positives. Conversely, models optimized for precision occasionally failed to identify a greater proportion of fraudulent transactions.
Because financial fraud detection requires balancing customer experience with financial risk, selecting the best model ultimately depended on achieving the most effective compromise between these competing objectives rather than maximizing any single metric in isolation.
Results and Discussion: Identifying the Best Model
After evaluating multiple machine learning algorithms and imbalance-handling strategies, the next step was to determine which model provided the most reliable performance for detecting fraudulent transactions.
Rather than selecting the model with the highest accuracy or even the highest ROC-AUC score, the evaluation focused on metrics that better reflect the objectives of fraud detection. In highly imbalanced classification problems, a successful model should identify as many fraudulent transactions as possible while minimizing the number of legitimate transactions incorrectly flagged for investigation.
The evaluation showed that the baseline Random Forest model achieved the best overall balance between precision and recall, resulting in the highest F1-score of 0.838 on the test dataset.
- Random Forest (Baseline) — Precision: 0.97, Recall: 0.74, F1-Score: 0.84, ROC-AUC: 0.93
- Random Forest (Balanced) — Precision: 0.99, Recall: 0.72, F1-Score: 0.83, ROC-AUC: 0.93
- XGBoost (Baseline) — Precision: 0.93, Recall: 0.73, F1-Score: 0.82, ROC-AUC: 0.97
- XGBoost (Balanced) — Precision: 0.76, Recall: 0.79, F1-Score: 0.77, ROC-AUC: 0.97
- Logistic Regression (Baseline) — Precision: 0.85, Recall: 0.58, F1-Score: 0.69, ROC-AUC: 0.96
- Logistic Regression (Class Weighting) — Precision: 0.06, Recall: 0.87, F1-Score: 0.11, ROC-AUC: 0.97
- Logistic Regression (SMOTE) — Precision: 0.05, Recall: 0.87, F1-Score: 0.10, ROC-AUC: 0.96
- Logistic Regression (Undersampling) — Precision: 0.05, Recall: 0.87, F1-Score: 0.10, ROC-AUC: 0.96
Several interesting observations emerged from this comparison.
Although XGBoost achieved a higher ROC-AUC score than Random Forest, it did not produce the highest F1-score. Similarly, applying imbalance-handling techniques such as SMOTE, undersampling, or aggressive class weighting did not consistently improve model performance. In several cases, these techniques significantly increased recall but dramatically reduced precision, producing a large number of false alarms.
These findings reinforce an important principle in applied machine learning: the most complex model is not necessarily the most effective model. Success depends on selecting an algorithm that aligns with the business objective rather than pursuing the highest value for a single evaluation metric.
Visualisations for the Best Model: Random Forest Baseline
Confusion Matrix Analysis

A confusion matrix provides a detailed breakdown of model predictions by showing not only how many transactions were classified correctly but also the types of mistakes the model made.
The Random Forest model produced the following results:
- True Negatives: 56,649
- False Positives: 2
- True Positives: 70
- False Negatives: 25
These numbers provide valuable business insights beyond standard evaluation metrics. The model correctly identified 56,649 legitimate transactions, demonstrating excellent reliability in recognizing normal customer activity.
More importantly, it incorrectly flagged only two legitimate transactions as fraudulent. Such a remarkably low false positive rate minimizes unnecessary manual investigations and reduces customer inconvenience caused by declined transactions.
The model also successfully detected 70 fraudulent transactions, preventing potential financial losses. However, 25 fraudulent transactions remained undetected, illustrating that even high-performing models cannot eliminate fraud entirely.
This highlights a fundamental challenge in fraud detection: reducing false negatives often increases false positives, while reducing false positives may allow more fraudulent transactions to escape detection. Selecting the appropriate balance depends on the organization's risk tolerance and operational priorities.
ROC Curve Analysis

The Receiver Operating Characteristic (ROC) Curve evaluates how effectively a model separates fraudulent and legitimate transactions across different classification thresholds. The Random Forest model achieved an ROC-AUC score of 0.93, indicating excellent discriminative ability.
An ROC-AUC value close to 1.0 suggests that the model consistently assigns higher fraud probabilities to fraudulent transactions than to legitimate ones. In practical terms, the model has a very high probability of ranking a randomly selected fraudulent transaction above a randomly selected legitimate transaction.
Although ROC-AUC provides a useful overall measure of classification performance, it can sometimes paint an overly optimistic picture when dealing with highly imbalanced datasets. Since legitimate transactions dominate the dataset, correctly classifying the majority class contributes heavily to the ROC metric.
For this reason, ROC-AUC should always be interpreted alongside metrics such as Precision, Recall, and the Precision–Recall Curve.
Precision–Recall Curve Analysis

For highly imbalanced datasets like credit card fraud detection, the Precision–Recall (PR) Curve is often more informative than the ROC Curve. Rather than emphasizing performance across both classes equally, the PR Curve focuses specifically on the model's ability to identify the minority class in this case, fraudulent transactions.
The Random Forest model maintained high precision even as recall increased, indicating that it could detect a substantial proportion of fraudulent transactions without generating excessive false positives.
This behavior is particularly desirable in real-world fraud detection systems, where every false alarm requires investigation while every missed fraud can result in financial loss. The Precision–Recall Curve therefore reinforces the conclusion that Random Forest provides an effective balance between fraud detection capability and operational efficiency.
Threshold Tuning: Finding the Right Business Balance
Most binary classification models use a default probability threshold of 0.5 to determine class membership. If the predicted probability exceeds 0.5, the transaction is classified as fraudulent; otherwise, it is classified as legitimate. However, this threshold is not fixed. Adjusting it changes the relationship between precision and recall, allowing organizations to tailor the model according to their specific business objectives.
The threshold analysis produced the following results:
- Threshold 0.3 — Precision: 0.88, Recall: 0.76, F1-Score: 0.81
- Threshold 0.4 — Precision: 0.95, Recall: 0.75, F1-Score: 0.84
- Threshold 0.5 — Precision: 0.97, Recall: 0.74, F1-Score: 0.84
- Threshold 0.7 — Precision: 0.98, Recall: 0.65, F1-Score: 0.78
Several important trade-offs emerged.
Lowering the threshold to 0.4 slightly improved recall, allowing the model to detect additional fraudulent transactions while only marginally reducing precision. This configuration may be preferable for organizations where preventing fraud losses is the highest priority. Reducing the threshold further to 0.3 increased recall again but generated more false positives, lowering overall precision.
Conversely, increasing the threshold to 0.7 produced exceptionally high precision but substantially reduced recall, allowing more fraudulent transactions to pass undetected. The default threshold of 0.5 ultimately provided the best balance between fraud detection and operational efficiency, achieving the highest overall F1-score.
This experiment demonstrates that machine learning models should not simply be optimized for predictive accuracy. They should be configured according to business objectives and organizational risk tolerance.
Explaining Predictions with SHAP

One of the most significant challenges in modern machine learning is explainability.
Although complex models such as Random Forest often achieve excellent predictive performance, they are frequently criticized as "black boxes" because their decision-making processes are difficult to interpret. To improve transparency, this project incorporated SHAP (SHapley Additive exPlanations).
SHAP explains individual predictions by measuring how much each feature contributes to moving a prediction toward either the fraudulent or legitimate class.
Unlike traditional feature importance measures that provide only global rankings, SHAP explains both overall model behavior and individual predictions. The SHAP summary plot identified several features including V14, V10, V12, and V17 as the strongest contributors to fraud predictions.
These findings closely aligned with the earlier correlation analysis, providing additional confidence that the model was learning meaningful statistical patterns rather than random noise. For individual transactions, SHAP force plots reveal how specific feature values influence a prediction. Some variables push the prediction toward fraud, while others pull it toward legitimacy. This level of transparency is invaluable for fraud analysts, enabling them to understand why a transaction was flagged and supporting faster, more informed investigations.
Explainability is increasingly important in regulated industries such as banking, where organizations must justify automated decisions to customers, auditors, and regulators. Integrating SHAP into the fraud detection workflow therefore enhances both model transparency and operational trust.
Business Implications and Recommendations
From a business perspective, fraud detection extends beyond predictive performance. Every prediction has operational and financial consequences.
A false positive may require manual review, delay customer purchases, or damage the customer experience. A false negative, however, can result in direct financial losses, reimbursement costs, reputational damage, and increased exposure to fraudulent activity.
Based on the findings of this project, several recommendations emerge:
- Deploy the baseline Random Forest model, as it achieved the strongest balance between precision and recall.
- Select the classification threshold based on business priorities. Organizations prioritizing fraud prevention may benefit from a slightly lower threshold, while those focused on customer experience may prefer the default threshold.
- Integrate SHAP explanations into fraud investigation workflows to provide analysts with interpretable reasons behind flagged transactions.
- Continuously monitor and retrain the model using newly labeled transaction data to adapt to evolving fraud patterns and maintain predictive performance.
Project Limitations
While the project demonstrates the effectiveness of machine learning for fraud detection, several limitations should be acknowledged.
The dataset represents historical transactions and therefore may not fully capture evolving fraud strategies observed in real-world financial systems. Fraudsters continuously adapt their techniques, making periodic retraining essential.
Additionally, the anonymized PCA features prevent domain-specific interpretation of individual variables. While this protects confidentiality, it limits the ability to derive business insights from the underlying transaction characteristics.
The project also focused primarily on supervised learning approaches and did not explore anomaly detection techniques, deep learning models, or graph-based fraud detection methods that have gained increasing attention in recent years.
Future Improvements
Future work could extend this project in several ways:
- Hyperparameter optimization using Grid Search or Bayesian Optimization.
- Evaluation of additional ensemble methods such as LightGBM and CatBoost.
- Investigation of anomaly detection algorithms including Isolation Forests and Autoencoders.
- Development of a real-time fraud detection API using FastAPI or Flask.
- Deployment with monitoring tools capable of detecting concept drift and triggering automated retraining.
- Integration with MLOps frameworks such as MLflow for experiment tracking and model versioning.
These enhancements would move the project closer to a production-ready fraud detection system capable of adapting to changing transaction patterns.
Conclusion
Credit card fraud detection remains one of the most challenging applications of machine learning due to the extreme imbalance between legitimate and fraudulent transactions. This project demonstrated that building an effective fraud detection system requires far more than selecting a powerful algorithm. Success depends on understanding the data, choosing appropriate evaluation metrics, addressing class imbalance thoughtfully, and interpreting results within a business context.
Among all evaluated models, the baseline Random Forest delivered the strongest overall performance, achieving an excellent balance between precision and recall while maintaining a remarkably low false positive rate. Through threshold tuning and SHAP-based explainability, the project also showed that model performance and transparency can be optimized together rather than treated as competing objectives.
Perhaps the most important lesson from this work is that machine learning is not solely about maximizing metrics. In fraud detection, every prediction represents a business decision with real financial and customer implications. Building models that are accurate, interpretable, and aligned with organizational objectives is ultimately what transforms predictive analytics into practical business value.




