Skip to content

End-to-end Predictive Maintenance project using LSTM, TensorFlow and FastAPI on NASA C-MAPSS dataset.

Notifications You must be signed in to change notification settings

MEK-0/Turbofan-RUL-Prediction-LSTM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✈ Turbofan Engine Remaining Useful Life (RUL) Prediction

Python TensorFlow FastAPI License

📖 Project Overview

This project implements an end-to-end Predictive Maintenance (PdM) solution to estimate the Remaining Useful Life (RUL) of turbofan jet engines using the NASA C-MAPSS (FD001) dataset.

The system utilizes a Deep Learning approach (LSTM - Long Short-Term Memory) to model the temporal degradation patterns of engine sensors. It features a complete pipeline including signal processing, feature engineering, model training, evaluation, and a production-ready REST API built with FastAPI.

🎯 Key Achievements

  • High Accuracy: Achieved an RMSE of 13.87 on the unseen test set (outperforming standard benchmarks of ~15.0).
  • Robust Preprocessing: Implemented Moving Average Filtering and Variance Thresholding to reduce sensor noise.
  • Microservice Architecture: Deployed the trained model as a REST API capable of real-time inference.
  • Dynamic Windowing: Utilizes a sliding window technique (Sequence Length = 50) for time-series forecasting.

🏗️ System Architecture

1. Data Pipeline & Signal Processing

The raw sensor data from NASA contains high-frequency noise. The pipeline applies:

  • Feature Selection: 7 constant sensors (s_1, s_5, etc.) were removed based on variance analysis.
  • Noise Reduction: A Moving Average Filter (window=5) smoothens the sensor readings to reveal degradation trends.
  • Normalization: MinMax Scaling ensures all 14 active sensors are within the [0, 1] range.

2. Model Architecture (LSTM)

The core model is designed to capture long-term dependencies in time-series data:

  • Input Layer: Shape (50, 14) representing 50 flight cycles of 14 sensors.
  • LSTM Layers: Two stacked LSTM layers (128 & 64 units) with return_sequences=True/False.
  • Regularization: Dropout (0.3) to prevent overfitting.
  • Output: Dense layer predicting a single continuous value (RUL).

3. Deployment (API)

  • Framework: FastAPI with Uvicorn server.
  • Structure: lifespan manager for efficient model loading.
  • Validation: Pydantic models ensure data integrity for input sequences.

📂 Project Structure

Turbofan_Project/
│
├── api/                     # Microservice & Serving Layer
│   ├── main.py              # FastAPI Application Entry Point
│   └── test_api.py          # Client Script for API Testing
│
├── data/                    # Dataset Directory
│   └── raw/                 # C-MAPSS Data (train_FD001.txt, etc.)
│
├── models/                  # Artifacts Store
│   ├── saved_models/        # .h5 Model and .pkl Scaler
│   └── test_result_plot.png # Evaluation Graphs
│
├── notebooks/               # Research & Experiments
│   ├── 1_Exploratory_Data_Analysis.ipynb
│   ├── 2_Signal_Processing.ipynb
│   └── 3_Model_Evaluation.ipynb
│
├── src/                     # Source Code Modules
│   ├── data_loader.py       # Data Ingestion
│   ├── preprocessing.py     # Feature Engineering & Windowing
│   ├── model_def.py         # LSTM Architecture Definition
│   └── evaluate.py          # Evaluation Pipeline
│
├── train.py                 # Main Training Script
├── requirements.txt         # Dependencies
└── README.md                # Project Documentation

Installation & Usage

1. Clone & Install Dependencies

git clone [https://github.com/yourusername/turbofan-rul-prediction.git](https://github.com/yourusername/turbofan-rul-prediction.git)
cd turbofan-rul-prediction
pip install -r requirements.txt

2. Train the Model

This script loads raw data, processes it, trains the LSTM model, and saves the best weights.

python train.py

3. Evaluate Performance

Generates predictions on the Test set and calculates RMSE/MAE metrics.

python src/evaluate.py

4. Run the API Server

Start the FastAPI server for real-time predictions.

uvicorn api.main:app --reload
Access Swagger UI at: http://127.0.0.1:8000/docs

Results

The model was evaluated on 100 test engines.

RMSE: 13.87

MAE: 10.24

Prediction vs. Actual (Test Set):

(Note: The red line represents the LSTM predictions, closely tracking the actual degradation path shown in black.)

API Usage Example

Endpoint: POST /predict

Request Body (JSON): Must contain a list of 50 time steps (dictionaries).

JSON
{
  "data": [
    { "s_2": 641.82, "s_3": 1589.70, "s_4": 1400.15, ... },
    ...
    { "s_2": 642.15, "s_3": 1590.20, "s_4": 1401.05, ... }
  ]
}

Response:

JSON
{
  "status": "success",
  "predicted_rul": 112.45,
  "unit": "cycles"
}

License

This project is licensed under the MIT License.

About

End-to-end Predictive Maintenance project using LSTM, TensorFlow and FastAPI on NASA C-MAPSS dataset.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published