0% found this document useful (0 votes)
23 views14 pages

Machine Learning Outlier Detection by Using Autoencoders

Machine Learning Outlier detection by using autoencoders for financial data to predict weather it’s a fraud or normal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views14 pages

Machine Learning Outlier Detection by Using Autoencoders

Machine Learning Outlier detection by using autoencoders for financial data to predict weather it’s a fraud or normal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Outlier Detection in Financial

Transactions Using Autoencoders

Vineeth Reddy GUDA


Overview of the Dataset

Context:
• Limited availability of financial datasets, especially in emerging domains like mobile money transactions.
• Synthetic dataset generated using the PaySim simulator to address this gap.
Content:
• PaySim simulates mobile money transactions based on real data from an African country.
• Dataset scaled down for Kaggle use, preserving the original transaction patterns.
• Fraudulent transactions are canceled, emphasizing the need for careful consideration during analysis.
Solution Overview

Utilizing Autoencoder for Anomaly Detection:


• Introduction of machine learning approach.
• Autoencoders are utilized for their ability to detect anomalies in
transaction data.
Understanding Autoencoders:
• Autoencoders consist of encoder and decoder layers.
• Encoder compresses input data, while decoder reconstructs it.
Detection via Reconstruction Error:
• Anomalies are identified based on reconstruction error.
• Higher error indicates potential fraudulent activity.
Learning to Distinguish Normal vs. Fraudulent Transactions:
• Autoencoder learns patterns to differentiate between normal and
fraudulent transactions.
• By training on diverse data, the model becomes adept at identifying
anomalies.
Libraries
numpy and pandas: Data manipulation and analysis.

keras: For building and training neural networks.

matplotlib and seaborn: Plotting and visualization.

pickle: Serialization of Python objects.

scikit-learn: Evaluation metrics for model


performance.
keras.backend: Access to TensorFlow backend
operations.
Fraud Distribution:
Data Preprocessing • Majority (99.87%) of transactions are non-
fraudulent, with only 0.13% being fraudulent.
• Indicates significant class imbalance, posing a
challenge for model training.
Data Preprocessing:
• Log Transformation: Applied to numerical features
to handle skewness and improve distribution.
• Scaling: Normalized numerical features to a range
between 0 and 1 for uniformity.
• One-Hot Encoding: Converted categorical 'type'
variable to numerical format for model
compatibility.
Sample Preprocessed Data:
• Displayed sample rows of preprocessed data,
demonstrating transformed features and encoded
variables.
• Data is now ready for model training and evaluation,
enhancing interpretability and model performance.
Autoencoder Model Architecture
Model Architecture:
• Input layer with 9 features representing transaction attributes.
• Encoder layer with 16 neurons, followed by a code layer with 8 neurons,
compressing input data into a lower-dimensional representation.
• Decoder layer with 16 neurons reconstructs the compressed representation.
• Output layer reconstructs the original 9 features using sigmoid activation.
Parameter Summary:
• Total trainable parameters: 593.
• Parameters include weights and biases of each layer in the autoencoder
architecture.
• No non-trainable parameters present.
Model Summary:
• Provides an overview of the layers, their output shapes, and the total number of
parameters.
• Highlights the simplicity and efficiency of the autoencoder architecture for fraud
detection tasks.
Training the Autoencoder Model
Model Compilation:
• Loss function: Binary cross-entropy, suitable for binary classification tasks like fraud detection.
• Optimizer: Adam optimizer, known for its efficiency and adaptability.
• Metrics: Accuracy is tracked during training for evaluation purposes.
Callbacks:
• ModelCheckpoint: Saves the best performing model weights during training to "autoencoder_fraud.h5" file.
• TensorBoard: Logs training progress and writes logs for visualization in the './logs' directory.
Training Process:
• Dataset consists of 63,62,620 samples, with 20% used for validation (1,272,524 samples).
• Model trained for 10 epochs with a batch size of 128, shuffled before each epoch.
• Each epoch shows loss and accuracy metrics for both training and validation sets.
• Training time: Approximately 156 seconds per epoch.
Model Evaluation:
• Loss Curves:
• Plots training and validation loss against epochs to visualize learning
progress.
• Interpretation:
• Training Loss: Decreases steadily, indicating improved reconstruction
of normal transactions.
• Validation Loss: Follows a similar trend, indicating good
generalization without overfitting.
• Convergence Analysis:
• Both curves converge towards the end of 10 epochs, indicating stable
model performance.
• Model Performance:
• Close alignment of curves demonstrates effective learning and
identifies fraudulent activities accurately.
• Overall decreasing trend signifies the effectiveness of autoencoder
architecture for fraud detection.
Reconstruction Error Analysis
Reconstruction Error Calculation:
• Autoencoder predicts reconstructed transactions (train_x_predictions).
• Mean Squared Error (MSE) between original and reconstructed transactions
calculated.
• Error DataFrame created with MSE and true class labels.
Error Distribution:
• Mean reconstruction error: 8.35e-06, indicating overall low error in normal
transactions.
• Standard deviation: 6.43e-05, showing variability in reconstruction errors.
• Minimum error: 1.14e-11, representing accurately reconstructed transactions.
• Maximum error: 7.68e-02, indicating significant deviation from normal
behavior.
Interpretation:
• Majority of transactions have low reconstruction error, reflecting accurate
reconstruction of normal transactions.
• Higher errors may indicate anomalies or potentially fraudulent activities.
Precision-Recall Analysis
Precision-Recall Curve:
• Visualizes the trade-off between precision and recall for various threshold values.
• Precision: Fraction of true positive predictions among all positive predictions.
• Recall: Fraction of true positive predictions among all actual positive instances.
• Demonstrates how precision and recall change with threshold adjustments.
Interpretation:
• Lowering the threshold increases recall (detecting more fraudulent transactions) but
decreases precision (increasing false positives).
• Precision-Recall curve aids in selecting an optimal threshold for practical
deployment of the fraud detection model.
Precision and Recall vs. Threshold:
• Plots precision and recall against different threshold values.
• Highlights the trade-off between precision and recall as the threshold varies.
• Intersection of curves assists in selecting a suitable threshold balancing the trade-off
between metrics.
Confusion Matrix Analysis

Confusion Matrix:

• Provides visual representation of model predictions


compared to actual class labels.

Interpretation:

• Majority of normal transactions correctly identified


(6,354,406 true negative).
• Presence of false negatives (8,213) indicates potential
missed fraudulent transactions.
• Single false positive observed (normal transaction
misclassified as fraudulent).
Confusion Matrix
Analysis
Conclusion

Key Findings: Implications: Future Directions:

ML techniques, particularly the ML-driven fraud detection offers Continued refinement and
autoencoder model, show cost savings and enhances exploration of ML algorithms.
promise in fraud detection. customer trust. Application of findings to real-
Achieved commendable accuracy, Potential for further optimization world fraud detection systems.
precision, and recall rates. and exploration of advanced
algorithms.
Thank you…

Vineeth Reddy GUDA

You might also like