A machine learning project that predicts earthquake alert levels (green, yellow, orange, red) using Random Forest Classifier based on seismic features.
This project analyzes earthquake data and predicts alert severity levels using key seismic parameters. The model helps in early warning systems by classifying earthquakes into different alert categories based on their characteristics.
- Random Forest Classification: Robust ensemble learning method for alert prediction
- Feature Importance Analysis: Identifies which seismic factors most influence alert levels
- Multi-class Classification: Predicts multiple alert levels (green, yellow, orange, red)
- Interactive Predictions: Test the model with custom earthquake parameters
- Visualization: Clear charts showing feature importance
- Python 3.x
- pandas - Data manipulation and analysis
- numpy - Numerical computing
- scikit-learn - Machine learning algorithms
- matplotlib - Data visualization
- Google Colab - Cloud-based development environment
pip install pandas numpy scikit-learn matplotlibgit clone https://github.com/zain-cs/earthquake-alert-predictor.git
cd earthquake-alert-predictorYour CSV file should contain the following columns:
magnitude- Earthquake magnitudedepth- Depth in kilometerscdi- Community Decimal Intensitymmi- Modified Mercalli Intensitysig- Significance valuealert- Alert level (green, yellow, orange, red)
Open the notebook in Google Colab or run the Python script:
python earthquake_predictor.pyUpload your earthquake dataset when prompted.
The Random Forest Classifier provides:
- Accuracy Score: Shows overall prediction accuracy
- Confusion Matrix: Detailed breakdown of predictions vs actual values
- Classification Report: Precision, recall, and F1-score for each alert level
- Feature Importance: Ranking of which features matter most
Predict alert level for a new earthquake:
# Example earthquake parameters
new_earthquake = {
'magnitude': 6.5,
'depth': 20, # km
'cdi': 5.0,
'mmi': 4.5,
'sig': 120
}
# Model predicts: "yellow" or "orange" depending on trained data| Column | Description | Example |
|---|---|---|
| magnitude | Richter scale measurement | 6.5 |
| depth | Depth in kilometers | 20 |
| cdi | Community Decimal Intensity | 5.0 |
| mmi | Modified Mercalli Intensity | 4.5 |
| sig | Significance score | 120 |
| alert | Alert level (target) | yellow |
- n_estimators: 100 trees in the forest
- max_depth: None (trees grow to full depth)
- random_state: 42 (for reproducibility)
- test_size: 20% of data reserved for testing
earthquake-alert-predictor/
│
├── earthquake_predictor.py # Main prediction script
├── README.md # Project documentation
├── requirements.txt # Python dependencies
└── data/ # Sample datasets (optional)
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Zain
- GitHub: @zain-cs
- Earthquake data from USGS (United States Geological Survey)
- scikit-learn documentation and community
- Random Forest algorithm by Leo Breiman
For questions or suggestions, please open an issue on GitHub or reach out through my profile.
⭐ If you find this project helpful, please consider giving it a star!