This project aims to develop a machine learning pipeline to categorize messages sent during disaster events, enabling their efficient forwarding to the appropriate disaster relief agency. Additionally, a user-friendly web app has been created for data visualization, where emergency workers can input new messages and receive classification results across various categories.
The dataset used in this project, provided by Figure Eight, comprises real messages sent during disasters. The goal is to build a robust model that can accurately categorize these messages to streamline the response efforts.
The ETL (Extract, Transform, Load) pipeline is responsible for data preprocessing. It performs the following tasks:
- Loads the messages and categories datasets.
- Merges the two datasets based on common identifiers.
- Cleans the data by handling duplicates and addressing missing or inconsistent information.
- Stores the processed data in an SQLite database.
messages_filepath: Path to the CSV file containing messages (e.g.,disaster_messages.csv).categories_filepath: Path to the CSV file containing categories (e.g.,disaster_categories.csv).database_filename: Path to the destination SQLite database (e.g.,disaster_response_db.db).
The Machine Learning (ML) pipeline focuses on training a multi-label classifier for text messages. The key steps are as follows:
- Loads data from the SQLite database generated by the ETL pipeline.
- Splits the dataset into training and test sets for model evaluation.
- Builds a comprehensive text processing and machine learning pipeline.
- Utilizes
GridSearchCVfor model tuning, optimizing hyperparameters. - Outputs evaluation results on the test set for model assessment.
- Exports the final trained model as a pickle file.
database_filepath: Path to the SQLite destination database (e.g.,disaster_response_db.db).model_filepath: Path to the pickle file where the ML model is saved (e.g.,classifier.pkl).
The Flask web app provides a user interface for interacting with the trained model. Emergency workers can input new messages into the app, which then classifies the messages across relevant categories.
This project was prepared as part of the Udacity Data Scientist Nanodegree
-
ETL Pipeline: Clean and Store Data
- Run the following command to execute the ETL pipeline, which cleans the data and stores the processed information in the database:
python data/process_data.py data/disaster_messages.csv data/disaster_categories.csv data/disaster_response_db.db
- Run the following command to execute the ETL pipeline, which cleans the data and stores the processed information in the database:
-
ML Pipeline: Train and Save Model
- Execute the ML pipeline to load data from the database, train the classifier, and save the trained model as a pickle file:
python models/train_classifier.py data/disaster_response_db.db models/classifier.pkl
- Execute the ML pipeline to load data from the database, train the classifier, and save the trained model as a pickle file:
-
Run the Web App
- Navigate to the app's directory and run the following command to start the web app:
python run.py
- Navigate to the app's directory and run the following command to start the web app:

