Tunisair APP is a web application built using Python as the backend technology and Angular as the frontend technology. The web application aims to help Tunisair (national airline in Tunisia) reduce flight delays by predicting the Remaining Useful Life - RUL
of aircraft components and providing real-time dashboard to monitor the health of aircrafts.
The project got us the first prize at the OpenGovDataHack2020 national hackathon.
Getting the first place required us to train a predictive model using a Gradient Boosting
model, deploy it on the cloud (using AWS EC2 server and RDS PostgreSQL instance
) and integrate it in a dashboard to help the administration avoid unexpected component failures.
The project consists in predicting the Remaining Useful Life - RUL
of the aircraft's Turbofan engine. Sensors on the aircraft keep sending sensor data to the webservice. The app predicts the RUL
using the trained model, ingests data point to database, sends email alarm when the engine reaches danger state and exposes engines health data in a REST API for the frontend.
Therefore, building the project consisted in different steps :
- Training the machine learning model
- Building the Microservices (REST API)
- Building the Frontend
- Creating scripts to simulate sending sensor data from aircraft
We used the dataset provided in the Nasa repository for the Turbofan engine (check it here). The dataset comes with a research paper, describing the dataset and sensors data.
After training the model, accuracy was validated and plotted :
The REST API provides several endpoints listed below :
GET /api/aircraft/<string:aircraftid>
: Fetches RUL data points for a specific aircraft identified byaircraftid
from database and returns them ordered by timestamp. It also returns aircraft type and health status of the aircraft. Frontend uses this endpoint to visualize the aircraft RUL graph and show aircraft health status (healthy
orin danger
)POST /api/aircraft/<string:aircraftid>
: This endpoint receives sensor data for an aircraft from request payload as well as a timestamp value. It will call the machine learning model, predict the RUL value, put the new data point in the database and checks the health status of the aircraft. If the aircraft is indanger
status, it will send an email to the administrator, showing theRUL
value and a link to the aircraft graph : This endpoint, is used by ingestion scripts to simulate aircrafts sending sensor data.GET /api/aircraft
: This endpoint returns RUL datapoints for all aircrafts in database, to be shown in the main dashboard like so :
5. GET /api/flight/<int:day>/<int:month>/<int:year>
: This endpoint returns live data about flight in Tunis Carthage Airport. Data is scraped from the airport website in real-time and exposed in this endpoint.
The Frontend is built using AngularJS. The single page web application keeps consuming the webservice using crons, to keep real-time insights about aircrafts data and updated graphs.
The script flood_rul/flood_sousse.py
will get sample sensor data from the dataset and consume the REST API to send the data. Since the last sensor values corresponds to a deteriorated engine, the aircraft will enter an in danger
status and an email will be sent.
To use the script, first delete the RUL
data points from the frontend :
Then run the script :
python flood_rul/flood_sousse.py
Keep pressing Enter
to send new data points each time, meanwhile, you can observe the graph changing in real-time, until the aircraft becomes in the in danger
status :
To develop such a project, here is the used tech stack:
- Angular 8 - HTML enhanced for web apps!
- Django - python framework for the backend REST API
- Scikit-learn - we used the
GradientBoostingRegressor
from the scikit-learn library to train and deploy the Gradient Boosting model