# 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 β¦