Train Tonnage Anomaly Detection

Published: Mar 16, 2024 by

Prerequisites

  • Configure RHODS workspace has been completed.

Run Jupyter notebooks

  1. Accessing an AWS S3 bucket & downloading multiple JSON files - advanceddownloadData.ipynb

Data Collection Change the following to notebook

AWS_ACCESS_KEY_ID = 'YOUR_ACCESS_KEY'
AWS_SECRET_ACCESS_KEY = 'YOUR_SECRET_KEY'
bucket_name = 'edge-anomaly-detection-bucket-name'
# List of file names to download
file_names = [
    'edge-datalake-bullet--Wed Oct 04 13:56:26 GMT 2023.txt',
    'edge-datalake-bullet--Wed Oct 04 13:57:26 GMT 2023.txt',
    # Add more file names here if needed
]

Example Bucket contents 20240318160248

20240318160350

Train Tonnage Anomaly Detection Model - TrainTonnage.ipynb

Data Exploration 20240318160746 Preprocess the data (remove rows with missing values) 20240318160826

Make an Isolation Forest Model 20240318161314

Show Anomalies 20240318161351

Check the Correlations in the Data 20240318161420

Check fo Missing Data in the Dataset 20240318161455

Detect Negative Values in the ‘TrainSpeed’ Column 20240318161529

Print the Anomaly Scores and Correlation Matrix 20240318161605

Train Tonnage Over Time with Anomalies Highlighted 20240318161633

List Detected Anomalies in Train Tonnage Data 20240318161705

Visualize of All Dataframe Columns 20240318161922

Visualize All Anomalies Dataframe Columns 20240318161950

Correlation Heatmap 20240318162010

Review Box Plot of Key Features 20240318162037

Pairwise Scatter Plot of Key Features 20240318162107

Scatter Plot of Primary Suspension Stiffness vs. Train Acceleration 20240318162134

Scatter Plot of Train Tonnage vs. Elapsed Time 20240318162205

Scatter Plot of Train Tonnage vs. Anomaly Scores 20240318162230

Scatter Plot of Anomaly vs. Anomaly Scores 20240318162252

Scatter Plot of TrainSpeed vs. TrainAcceleration with Correlation Line 20240318162331

Model Conversion to ONNX Format

Load an ONNX Model for Inference

List Features in a Sample DataFrame 20240318163307

Feature Extraction and Inference

Inference using ONNX Model

Visualizing Model Output with a Bar Chart 20240318163342

Visualizing Anomaly Scores with a Bar Chart 20240318163407

Share