Skip to content

SakshamGG/Fault-Classification-Project-

Repository files navigation

Rolling Element Bearing Fault Detection (1D CNN)

This project implements a complete pipeline for rolling element ball bearing fault detection using vibration signals stored in .mat files and a 1D CNN in PyTorch.

Project Structure

  • utils.py: Scans folders, loads .mat files, extracts vibration signals (Data1_AI_1_Xaxis), segments signals into overlapping windows, and builds NumPy datasets.
  • dataset.py: Defines the PyTorch Dataset and helpers to split, scale (StandardScaler), and build DataLoaders.
  • model.py: Implements the 1D CNN architecture for fault classification.
  • train.py: Entry point for training, evaluation, and plotting.
  • requirements.txt: Python dependencies.

Dataset Expectations

  • The workspace (or a given --data_dir) must contain .mat files.
  • Each .mat file should contain a key named Data1_AI_1_Xaxis with a long 1D vibration signal.
  • File names encode the fault type:
    • Normal → label 0
    • BF (Ball Fault) → label 1
    • IF (Inner Race Fault) → label 2
    • OF (Outer Race Fault) → label 3

Matching is case-insensitive and based on substrings in the file name.

Installation

Create and activate a virtual environment, then install dependencies:

pip install -r requirements.txt

Running Training

From the project root:

python train.py --data_dir path/to/your/dataset

Arguments:

  • --data_dir (default .): Root directory to scan recursively for .mat files.
  • --epochs (default 20): Number of training epochs.
  • --batch_size (default 64): Batch size.
  • --lr (default 1e-3): Learning rate for Adam optimizer.

Outputs

Running train.py will:

  • Print training loss per epoch.
  • Print final test accuracy.
  • Save a training loss plot as loss_curve.png.
  • Save a confusion matrix plot as confusion_matrix.png.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages