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.
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.
- 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
Example Input:
{
"age": 119,
"weight": 79,
"height": 1.72,
"income_lpa": 70,
"smoker": true,
"city": "Delhi",
"occupation": "government_job"
}uvicorn main:app --reload
streamlit run app.py