This repository contains a machine learning project that predicts medical insurance costs based on user inputs such as age, gender, BMI, number of children, smoking status, and region.
-
Implements multiple machine learning models:
- Linear Regression
- Random Forest Regressor
- Decision Tree Regressor
-
Provides a user-friendly Streamlit web interface to interact with the models.
-
Exposes a RESTful API to make predictions using the trained models.
├── app.py # Streamlit app interface
├── main.py # Core logic and model loading
├── api.py # RESTful API using FastAPI
├── model/ # Directory containing trained model pickle files
│ ├── linear_model.pkl
│ ├── random_model.pkl
│ └── descision_model.pkl
├── static/ # Any frontend assets if needed
├── requirements.txt # Python dependencies
└── README.md
- Clone the repository:
git clone https://github.com/pranjaykumar926/Medical-Insurance-Cost-Prediction.git
cd Medical-Insurance-Cost-Prediction- Install dependencies:
pip install -r requirements.txtstreamlit run app.pyuvicorn api:app --reloadThe API will be available at http://127.0.0.1:8000 with automatic documentation at http://127.0.0.1:8000/docs (Swagger UI).
Returns a welcome message.
Accepts JSON input and returns the predicted insurance cost.
Input JSON:
{
"age": 29,
"sex": "male",
"bmi": 27.9,
"children": 0,
"smoker": "yes",
"region": "southwest",
"model": "linear"
}Supported model values: linear, random, descision
Output JSON:
{
"prediction": 16884.92
}Pranjay Kumar GitHub
Feel free to fork this repository and contribute to the project.