Skip to content

akshaypratap008/FastAPI---Insurance-Premium-Prediction---Tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Insurance Premium Category Prediction API

This project is built to understand how FastAPI can be used to serve a machine‑learning model through an API. The model is a simple RandomForestClassifier trained on a toy dataset of 100 rows, and the focus is on learning the end‑to‑end workflow rather than building a usefull project.


Overview

The API exposes a /predict endpoint that accepts user details such as age, weight, height, income, and some lifestyle factors. These inputs are converted into a pandas DataFrame and passed to the prideiction API which validates the date, performes feature engineering and tranformation and ultimately make a prediction about the Insurance Premium Category.

A lightweight Streamlit UI is included to collect user inputs and send them to the FastAPI backend.


Tech Stack

  • FastAPI for building the API
  • Uvicorn as the ASGI server
  • pandas for data manupulation
  • scikit‑learn for the RandomForest model
  • Streamlit for the frontend UI

API Endpoint

POST /predict

Example Input:

{
  "age": 119,
  "weight": 79,
  "height": 1.72,
  "income_lpa": 70,
  "smoker": true,
  "city": "Delhi",
  "occupation": "government_job"
}

How to use:

Start API server

uvicorn main:app --reload

Launch Streamlit UI

streamlit run app.py

About

This is a tutorial project. An API built using FastAPI for a model that predicts the Insurance Premium Category for the user based on some input features. The UI is built using Streamlit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors