Predict medical insurance charges based on user information such as age, sex, BMI, number of children, smoking status, and region.
Built using classical machine learning techniques and deployed via an interactive Streamlit dashboard.
This project applies supervised machine learning to predict individual medical insurance costs. The application leverages a cleaned dataset of personal health and demographic data and enables users to input custom values for real-time predictions. The results are visualized and interpreted through a user-friendly web dashboard.
Insurance companies, actuaries, and healthcare professionals often need to estimate the expected cost of medical care for clients based on risk factors. Manual calculations are inefficient and fail to scale. This project:
- Provides a data-driven, automated solution for charge prediction
- Helps uncover feature importance and pricing patterns
- Offers an interactive, explainable prediction tool to enhance transparency and decision-making
- 📊 Interactive Dashboard (Streamlit)
- 🧮 User Input Form for real-time predictions
- 📉 Model Comparison (Linear Regression, Ridge, Lasso, Random Forest, XGBoost)
- 🔍 Feature Importance Visualization
- 📈 Residual Analysis
- 📥 Downloadable Results
- 🧠 Model Insight & Documentation
- 🗂️ Modular, clean project structure ready for production or extension
- Python 3.10+
- Pandas, NumPy – Data manipulation
- Scikit-learn – ML models and preprocessing
- XGBoost – Boosted trees model
- Matplotlib, Seaborn – Data visualization
- Streamlit – Web app interface
- Jupyter Notebook – EDA & development
- Git, GitHub – Version control
# Clone the repo
git clone https://github.com/yourusername/insurance-price-predictor.git
cd insurance-price-predictor
# Create a virtual environment
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
# Install dependencies
pip install -r requirements.txt
# Run the Streamlit dashboard
streamlit run app/dashboard.py- Open the dashboard in your browser.
- Explore the dataset in the Data Exploration tab.
- Enter values in the User Prediction Form.
- View the predicted medical charges instantly.
- Analyze model performance and download sample results.
Sample Prediction:
Input: 29 years old, male, BMI 27.3, smoker: no
→ Predicted Charges: $3,475.92
Feature Importance Plot:
insurance-price-predictor/ ├── app/ │ ├── dashboard.py │ └── components/ │ ├── header.py │ ├── data_exploration.py │ ├── feature_input.py │ ├── model_insights.py │ ├── download_section.py │ └── about.py ├── data/ │ └── insurance.csv ├── notebooks/ │ └── 01_exploration_and_modeling.ipynb ├── outputs/ │ ├── plots/ │ └── results.csv ├── src/ │ ├── data_preprocessing.py │ ├── train_models.py │ └── evaluate_models.py ├── main.py ├── requirements.txt └── README.md
## 🤝 Contributing Guidelines
Contributions are welcome!
If you'd like to improve the project or add new models:
1. Fork the repo
2. Create a new branch (`git checkout -b feature/model-name`)
3. Commit your changes
4. Push to your branch
5. Open a pull request
## 📜 License
Licensed under the **MIT License**.
See `LICENSE` file for more details.
## 👤 Author
**Stephen Kinuthia**
📧 [kinuthiastephen94@gmail.com](mailto:kinuthiastephen94@gmail.com)
🐙 [GitHub](https://github.com/stephenkinuthia-cell)
## ⭐ Show your support
If you found this useful or interesting, give it a ⭐ on GitHub!
