# Morocco Flood Prediction AI
An AI-powered system for predicting flood risks across Morocco using machine learning and weather data.
## 🎯 Project Overview
This project provides a complete machine learning pipeline for:
- **Data Collection**: Fetches historical and real-time weather data from Open-Meteo API
- **Data Preprocessing**: Feature engineering for flood prediction
- **Model Training**: Multiple ML models (Random Forest, XGBoost, LSTM)
- **Prediction API**: REST API for real-time flood risk predictions
## 🌦️ Flood Risk Levels
| Level | Label | Description |
|-------|-------|-------------|
| 0 | No Risk | Normal conditions |
| 1 | Low Risk | Light precipitation expected |
| 2 | Moderate Risk | Significant precipitation |
| 3 | High Risk | Heavy rain, potential flooding |
| 4 | Extreme Risk | Severe weather, high flood probability |
## 📁 Project Structure
```
morocco-flood-ai/
├── configs/
│ └── config.yaml # Configuration file
├── data/
│ ├── raw/ # Raw weather data
│ ├── processed/ # Preprocessed data
│ └── models/ # Trained models
├── src/
│ ├── data/
│ │ ├── data_collector.py # Data collection module
│ │ └── preprocessor.py # Data preprocessing
│ ├── models/
│ │ └── model.py # ML model definitions
│ └── utils/
│ └── config.py # Configuration utilities
├── train.py # Training script
├── predict.py # Prediction module
├── api.py # FastAPI web API
├── demo.py # Demonstration script
└── requirements.txt # Python dependencies
```
## 🚀 Quick Start
### 1. Install Dependencies
```bash
cd morocco-flood-ai
pip install -r requirements.txt
```
### 2. Collect Data
```python
from src.data.data_collector import MoroccoWeatherDataCollector
collector = MoroccoWeatherDataCollector()
df = collector.collect_all_historical(
start_date="2020-01-01",
end_date="2024-01-01",
include_flood_z …