This project is a comprehensive AI and Machine Learning-based application for predicting flood risks in specific regions (Mostar, Jablanica, and Fojnica). By utilizing historical and real-time weather data, the system evaluates potential flood risks and offers valuable insights.
- Algorithm: Random Forest Regressor from
scikit-learn
. - Input Features:
- Temperature:
temp
- Humidity:
humidity
- Precipitation:
precip
- Precipitation Probability:
precipprob
- Wind Speed:
windspeed
- Temperature:
- Target: Predict precipitation levels.
- Automatic Retraining: The model dynamically updates with new data to enhance prediction accuracy.
- Built using Flask with endpoints for:
- Flood risk prediction.
- Retraining the model with updated data.
- Uses Flask-CORS to enable cross-origin requests.
- Fetches real-time weather data via the Visual Crossing Weather API.
- Developed using Tkinter.
- Features:
- Select a city (Mostar, Jablanica, or Fojnica).
- Predict flood risks for up to 10 days ahead.
- Displays results in a user-friendly, tabular format.
- Historical weather data merged and processed using
pandas
. - Combines data from multiple CSV files for model training.
- Handles missing or invalid data through preprocessing.
- Python: Core programming language.
- Flask: For building the backend API.
- Tkinter: For creating the desktop GUI.
- scikit-learn:
- Used to implement the Random Forest Regressor.
- Saves and loads the trained model using
joblib
.
pandas
: For data manipulation and merging CSV files.NumPy
: Efficient handling of numerical data.
- Visual Crossing Weather API: Fetches real-time weather data based on city and date.
joblib
: For saving and loading trained machine learning models.Flask-CORS
: To manage cross-origin requests.
- Python 3.8+
- Required Python packages (install via pip): pip install pandas scikit-learn flask flask-cors joblib requests
- Access to the Visual Crossing Weather API (you will need an API key).
- Clone the repository: git clone https://github.com/Selma-Bajramovic/ai-agent-flood-prediction.git cd flood_prediction
- Train the model: python model.py
- Start the Flask backend: python app.py
- Launch the Tkinter GUI: python frontend.py
├── backend
│ ├── data
│ │ ├── fetch_data.py
│ │ ├── fojnica_weather.csv
│ │ ├── jablanica_weather.csv
│ │ ├── merged_data.py
│ │ ├── merged_flood_data.csv
│ │ └── mostar_weather.csv
│ ├── model
│ │ └── flood_prediction_model.pkl
│ ├── app.py
│ └── model.py
├── frontend
│ └── frontend.py
└── README.md
- Data Collection: -Historical weather data is merged from multiple CSV files. -Real-time weather data is fetched using the Visual Crossing Weather API.
- Training the Model: -The model is trained using the RandomForestRegressor on historical data. -Input features include weather parameters like temperature and precipitation.
- Flood Risk Prediction: -The Flask API uses the trained model to predict precipitation levels. -Risk levels (Low, Moderate, High) are assigned based on thresholds.
- Interactive GUI: -Users input the city and forecast days. -Predictions are displayed in a detailed, interactive table.
- Visual Crossing Weather API: For providing real-time weather data.
- scikit-learn: For the robust machine learning library.
- Inspiration and feedback from educational and professional projects.
🌟 Thank you for exploring this project!