This repository contains the code and data for a machine learning project that predicts insurance costs based on various factors. We have used three different regression models: Linear Regression, Support Vector Regression, and Random Forest Regression to predict insurance costs. We then evaluate the performance of each model using the R^2 score to determine which model has the best accuracy.
The dataset used for this project is available in the insurance.csv file. It contains the following columns:
age: Age of the insured person.sex: Gender of the insured person (male or female).bmi: Body mass index (BMI) of the insured person.children: Number of children/dependents covered by the insurance.smoker: Whether the insured person is a smoker (yes or no).region: The region where the insured person resides.charges: The insurance cost charged to the insured person (target variable).
-
Linear Regression: Linear regression is a simple regression model that assumes a linear relationship between the input features and the target variable.
-
Support Vector Regression (SVR): SVR is a regression technique that uses support vector machines to find the best-fitting line while minimizing the error.
-
Random Forest Regression: Random Forest is an ensemble learning method that combines multiple decision trees to make predictions.
To run the code in this repository, you'll need the following libraries:
pip install numpy pandas scikit-learn- Clone this repository:
git clone [https://github.com/yourusername/insurance-cost-prediction.git
cd insurance-cost-prediction](https://github.com/harshil-1402/Insurance-prediction)- Run the Jupyter Notebook or Python script to train and evaluate the models.
jupyter notebook insurance_cost_prediction.ipynb
# OR
python insurance_cost_prediction.py- Examine the results and the R^2 scores to determine the best model for insurance cost prediction.
After running the models, the R^2 scores will be displayed, allowing you to compare their performance. The model with the highest R^2 score is the one that best predicts insurance costs.
This project demonstrates the application of machine learning regression models to predict insurance costs. By comparing the R^2 scores of the Linear Regression, Support Vector Regression, and Random Forest Regression models, we can determine which model provides the most accurate predictions for insurance costs.
Feel free to explore the code and dataset further, and customize it for your own insurance cost prediction tasks.