A machine learning project for predicting the Remaining Useful Life (RUL) of aircraft engines using sensor data. The project includes data exploration, preprocessing, model training, and a FastAPI-based REST API for real-time predictions.
This project implements a predictive maintenance solution that analyzes sensor data from aircraft engines to predict their remaining useful life. The solution uses a Random Forest regression model trained on historical sensor readings and provides predictions through a REST API.
- Data Processing Pipeline: Complete data exploration and preprocessing workflows
- Machine Learning Model: Random Forest regressor for RUL prediction
- REST API: FastAPI-based service for real-time predictions
- Containerization: Docker support for easy deployment
- Jupyter Notebooks: Interactive analysis and model development
predictive-maintenance/
├── api/ # FastAPI application
│ └── main.py # API endpoints and model serving
├── data/ # Data storage
│ ├── 01_raw/ # Raw datasets
│ └── 02_processed/ # Processed datasets
├── models/ # Trained models and artifacts
│ ├── features.json # Feature names for model input
│ ├── rf_model.joblib # Trained Random Forest model
│ └── scaler.joblib # Data scaler for preprocessing
├── notebooks/ # Jupyter notebooks for analysis
│ ├── 01_data_exploration.ipynb
│ ├── 02_data_preprocessing.ipynb
│ └── 03_modelling.ipynb
├── src/ # Source code modules
├── Dockerfile # Container configuration
├── pyproject.toml # Project dependencies
└── README.md # This file
- Python 3.10+
- Dependencies listed in
pyproject.toml
# Clone the repository
git clone https://github.com/metedogan/predictive-maintenance
cd predictive-maintenance
# Install dependencies
uv sync# Clone the repository
git clone https://github.com/metedogan/predictive-maintenance
cd predictive-maintenance
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -e .Start the FastAPI server:
uvicorn api.main:app --reloadThe API will be available at http://localhost:8000
- Interactive API documentation:
http://localhost:8000/docs - Alternative docs:
http://localhost:8000/redoc
Send a POST request to /predict with sensor data:
curl -X POST "http://localhost:8000/predict" \
-H "Content-Type: application/json" \
-d '{
"data": {
"sensor_2": 643.22,
"sensor_3": 1589.73,
"sensor_4": 1402.35,
"sensor_21": 23.3916
}
}'Response:
{
"predicted_rul": 142.35
}Build and run the container:
# Build the image
docker build -t predictive-maintenance .
# Run the container
docker run -p 8000:8000 predictive-maintenanceThe project includes three main notebooks:
- 01_data_exploration.ipynb: Initial data analysis and visualization
- 02_data_preprocessing.ipynb: Data cleaning and feature engineering
- 03_modelling.ipynb: Model training and evaluation
Start Jupyter to explore the notebooks:
jupyter lab notebooks/To retrain the model with new data:
- Place raw data in
data/01_raw/ - Run the preprocessing notebook to generate processed data
- Execute the modeling notebook to train and save the new model
- The trained artifacts will be saved in the
models/directory
Welcome message and API information
Predict remaining useful life from sensor data
Request Body:
{
"data": {
"sensor_2": float,
"sensor_3": float,
"sensor_4": float,
// ... other sensor values
"sensor_21": float
}
}Response:
{
"predicted_rul": float
}- Algorithm: Random Forest Regressor
- Input: Sensor readings from aircraft engines
- Output: Remaining Useful Life (RUL) in cycles
- Preprocessing: StandardScaler for feature normalization
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request