An end-to-end Machine Learning project that predicts individual medical insurance charges using Linear Regression. The application takes customer information such as age, gender, BMI, number of children, and smoking habits to estimate insurance costs.
🌐 Live Application: Insurance Cost Prediction
💻 GitHub Repository: Insurance_Analysis_ML
Medical insurance costs vary depending on several demographic and lifestyle factors. This project uses Machine Learning to identify relationships between these factors and insurance charges.
A Linear Regression model is trained on historical insurance data and deployed through an interactive Streamlit web application.
- Analyse factors affecting medical insurance charges.
- Perform Exploratory Data Analysis (EDA).
- Apply data cleaning and preprocessing techniques.
- Perform categorical encoding and feature engineering.
- Analyse feature relationships using Pearson correlation.
- Apply Chi-square statistical testing for categorical feature analysis.
- Train a Linear Regression model.
- Evaluate model performance.
- Deploy an interactive prediction application.
Dataset: Medical Cost Personal Dataset (Insurance Dataset)
The dataset contains customer information and their corresponding medical insurance charges.
| Feature | Description |
|---|---|
| age | Age of the individual |
| sex | Gender of the individual |
| bmi | Body Mass Index |
| children | Number of dependent children |
| smoker | Smoking status |
| region | Residential region |
| charges | Medical insurance charges (target) |
- Python
- NumPy
- Pandas
- Matplotlib
- Seaborn
- SciPy
- Scikit-learn
- Streamlit
- Joblib
- Dataset exploration and statistical summaries.
- Missing-value and duplicate analysis.
- Distribution analysis using histograms.
- Outlier detection using boxplots.
- Correlation analysis using heatmaps.
- Duplicate removal.
- Categorical variable encoding.
- Feature engineering.
- StandardScaler for numerical features.
- Pearson correlation analysis.
- Chi-square statistical testing.
- Feature relationship analysis.
- Algorithm: Linear Regression.
- Train-test split: 80:20.
- Random state: 42.
- Model trained using five selected features:
- Age
- Gender
- BMI
- Number of children
- Smoking status
The model is evaluated using:
- R-squared (R²)
- Adjusted R-squared
- Mean Absolute Error (MAE)
- Root Mean Squared Error (RMSE)
The deployed application allows users to:
- Enter their age.
- Select gender.
- Enter BMI.
- Specify number of children.
- Select smoking status.
- Generate an estimated medical insurance cost.
The application uses the trained Linear Regression model and saved StandardScaler to generate predictions.
Clone the repository:
git clone https://github.com/tusharr29/Insurance_Analysis_ML.gitNavigate to the project directory:
cd Insurance_Analysis_MLCreate a virtual environment:
python -m venv .venvActivate the environment on Windows:
.venv\Scripts\activateInstall dependencies:
pip install -r requirements.txtTrain the model:
python main.pyRun the Streamlit application:
streamlit run app.pyInsurance_Analysis_ML/
│
├── insurance.csv
├── main.py
├── app.py
├── insurance_model.pkl
├── scaler.pkl
├── requirements.txt
├── README.md
└── .gitignore
- Compare Linear Regression with other regression algorithms.
- Implement cross-validation.
- Perform hyperparameter tuning.
- Improve model performance through feature selection.
- Add interactive data visualizations.
- Explore advanced regression techniques.
Tushar Deshmukh
- GitHub: @tusharr29
- Project: Insurance Cost Prediction
This project was developed for educational and portfolio purposes. Predictions are estimates based on historical data and should not be treated as actual insurance quotes.