This API is built using FastAPI to predict flood risks based on various environmental and infrastructural factors. The model used for prediction is loaded from a pickle file and uses features like Monsoon Intensity, Urbanization, Climate Change, and more.
- Load a pre-trained model from a specified path.
- Predict flood risk based on input data with 20 different features.
- Structured logging for better tracking and debugging.
- CORS support for local development and external connections.
Ensure you have the following installed:
- Python 3.7+
- FastAPI
- Uvicorn
- Pydantic
- Pandas
- Pickle
- Python-dotenv
-
Clone the repository:
git clone https://github.com/yourusername/flood-risk-prediction-api.git cd flood-risk-prediction-api
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.env
file in the root directory and add the following environment variables:MODEL_PATH=path/to/your/FloodRisk.pkl HOST=127.0.0.1 PORT=8000
-
Place your trained model (e.g.,
FloodRisk.pkl
) in the specified path or update theMODEL_PATH
in the.env
file.
Run the API using Uvicorn:
uvicorn main:app --reload