This is the backend service for the Insurance Premium Predictor project.
It is built using FastAPI and serves a trained Random Forest Classifier model that predicts whether a person’s insurance premium will be Low, Medium, or High.
The backend exposes a /predict API endpoint, which receives user input and returns the prediction in JSON format.
- FastAPI for building a lightweight and fast backend
- Random Forest Classifier trained on user details
- Pydantic for request validation
- Pickle model loading (
model.pkl) - Deployed on Railway
The backend is hosted on Railway and connected to the frontend.
👉 Backend API Base URL
Main endpoint: POST /predict
POST https://web-production-2c19.up.railway.app/predict
{ "age": 31, "weight": 91, "height": 1.72, "income_lpa": 10, "smoker": false, "city": "Jaipur", "occupation": "business_owner" }
{ "response": { "predicted_category": "Low", "confidence": 0.51, "class_probabilities": { "High": 0.13, "Low": 0.51, "Medium": 0.36 } } }
- FastAPI: Web Framework
- Scikit-learn: Random Forest Classifier (trained in Google Colab, saved as
model.pkl) - Pydantic: Request and Data (Input + Output) Validation
- Uvicorn: ASGI server
- Railway: Deployment
- Frontend Repo (Streamlit UI) – Insurance Premium Predictor – Frontend
- Complete Deployed App (Frontend + Backend connected) – FastAPI + ML model code:
👉 Live App