XGBoost Model for Fraud Detection
This repository contains an XGBoost model trained to detect fraudulent transactions based on transaction data. The model uses several engineered features that are designed to capture various aspects of the transactions, including anonymized features, time-based features, and behavioral features.
Features Used in the Model
The model is trained on the following features, which include both anonymized PCA-like features (V1-V28) as well as some time and behavioral features:
V1-V28 Features
These are anonymized features generated using Principal Component Analysis (PCA) on the raw transaction data. They are designed to capture latent patterns in the data that are not directly observable in the original features. The anonymization process ensures that no personal or sensitive information is exposed.
V1-V28: These are features generated from the raw transaction data (like transaction amount, frequency, etc.), and each of them represents a component extracted via PCA or similar methods to anonymize the data. These features help the model learn complex patterns in the data without exposing the original sensitive attributes.
Other Features in the Dataset
DOW (Day of Week): The day of the week on which the transaction occurred. Values range from 0 (Monday) to 6 (Sunday).
Is_Weekend: A binary feature indicating whether the transaction occurred on the weekend (1) or on a weekday (0).
Max_Days_Between: The maximum number of days between this transaction and the previous transaction made by the same user.
Monthly_Txns_lag_30: The cumulative number of transactions made by the user in the last 30 days.
Weekly_Txns_lag_30: The cumulative number of transactions made by the user in the last 7 days.
Class_lag_30: A placeholder feature that represents the fraud class from 30 days ago. Since fraud labels are not available historically, it is set to 0.
Model Evaluation
The model has been evaluated on a dataset of 10,236 transactions, with a significant class imbalance, as fraudulent transactions (label 1) make up a small portion of the data.
Confusion Matrix
The confusion matrix summarizes the performance of the classification model:
lua
Copy
Edit
[[6487 13]
[ 6 3730]]
True Negatives (TN): 6487
False Positives (FP): 13
False Negatives (FN): 6
True Positives (TP): 3730
Classification Report
The classification report provides a detailed breakdown of the model's precision, recall, and F1-score for each class (fraudulent and non-fraudulent):
markdown
Copy
Edit
precision recall f1-score support
Precision: 0.9991
Recall: 0.9980
F1-score: 0.9985
Class 1 (Fraudulent Transactions):
Precision: 0.9965
Recall: 0.9984
F1-score: 0.9975
ROC AUC Score
The model achieved a ROC AUC Score of 1.0, indicating that it has perfect discriminatory power between fraudulent and non-fraudulent transactions. This means the model is able to perfectly distinguish between both classes across all possible thresholds.
Model Performance Summary
Accuracy: 99.81%
Precision (Class 0): 99.91%
Recall (Class 0): 99.80%
Precision (Class 1): 99.65%
Recall (Class 1): 99.84%
F1-Score (Class 1): 99.75%
ROC AUC Score: 1.0
The model performs excellently in distinguishing fraudulent transactions, with an extremely high accuracy and very low false positive and false negative rates.