This project transforms a traditional Data Science analysis into a production-grade Full-Stack Machine Learning Application. It features a resilient Backend API, an interactive Frontend Dashboard, and is fully Dockerized for cross-platform deployment.
- Prediction Service: Real-time fatality estimation using a trained XGBoost Regressor.
- Interactive Dashboard:
- 3D Global Incident Sphere: 🌐 Interactive 3D globe visualization (Plotly) with "Cyberpunk" aesthetics for exploring incident density.
- Data Explorer Mode: 🗺️ Dedicated interface for browsing historical incident maps and filtering by region/attack type.
- Trend Analytics: Historical incident charts for the selected country.
- AI Security Analyst: 🤖 Generates travel safety briefings using LLMs (Gemini) based on incident history.
- Smart Inputs: Dropdowns populated dynamically from dataset metadata.
- REST API: Fully documented endpoints via FastAPI (Swagger UI included).
- Production Ready: Docker containerization ensures consistent execution on Windows, Mac, and Linux.
- Training Pipeline (
sde_project/train_pipeline.py):- Modular script for data ingestion, preprocessing (LabelEncoding, Scaling), and model training.
- Serializes model artifacts (
.joblib) for inference.
- Backend API (
sde_project/api.py):- FastAPI microservice serving the model.
- Endpoints:
POST /predict: Get fatality predictions.GET /history: Fetch yearly trends for charting.GET /similar: Fetch geolocation data for maps.GET /metadata: Dynamic form population.
- Frontend Dashboard (
sde_project/app.py):- Streamlit interface for user interaction.
- Connects to the backend via REST API calls.
- Core: Python 3.9+
- ML: XGBoost, Scikit-learn, Pandas, NumPy
- Web/API: FastAPI, Uvicorn, Streamlit
- DevOps: Docker, Docker Compose
- Ensure the dataset
gt.csvis present in the project root.
The easiest way to run the full stack (Frontend + Backend).
- Build and Run:
# Run from the project root directory docker-compose up --build - Access the App:
- Dashboard: http://localhost:8501
- API Docs: http://localhost:8000/docs
-
Install Dependencies:
pip install -r requirements.txt
-
Navigate to Project Folder:
cd sde_project -
Train the Model:
python train_pipeline.py
-
Start the Backend:
uvicorn api:app --reload
-
Start the Frontend (in a new terminal):
streamlit run app.py
├── gt.csv # Dataset (Input)
├── docker-compose.yml # Docker Envrionment Definition
├── requirements.txt # Python Dependencies
├── sde_project/
│ ├── Dockerfile # Container Definition
│ ├── train_pipeline.py # ML Training Script
│ ├── api.py # Backend API
│ ├── app.py # Frontend Dashboard
│ └── models/ # Saved Model Artifacts