Skip to content

LakshyaMittal1/Insurance-Premium-Predictor-Backend-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Insurance Premium Predictor – Backend (FastAPI)

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.


🚀 Features

  • 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

🌐 Live Backend

The backend is hosted on Railway and connected to the frontend.
👉 Backend API Base URL

Main endpoint: POST /predict


📌 API Usage

Endpoint

POST https://web-production-2c19.up.railway.app/predict

Request Body (JSON)

{ "age": 31, "weight": 91, "height": 1.72, "income_lpa": 10, "smoker": false, "city": "Jaipur", "occupation": "business_owner" }

Response (JSON)

{ "response": { "predicted_category": "Low", "confidence": 0.51, "class_probabilities": { "High": 0.13, "Low": 0.51, "Medium": 0.36 } } }


🛠️ Tech Stack

  • 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

📌 Related Repositories

About

FastAPI backend for Insurance Premium Predictor. Serves a trained Random Forest model via a /predict API endpoint, deployed on Railway and connected with the Streamlit frontend. Frontend repo: https://github.com/LakshyaMittal1/Insurance-Premium-Predictor-Frontend-

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors