This repository contains a Python script for implementing linear regression using scikit-learn. Linear regression is a simple yet powerful algorithm for predicting a continuous target variable based on one or more independent features.
Before running the script, make sure you have the following libraries installed:
pip install numpy matplotlib pandas scikit-learn
- Clone the repository:
git clone https://github.com/*****/linear-regression.git
cd linear-regression
- Run the script:
python linear_regression.py
Make sure to update the file paths in the script to point to your actual dataset files.
The script uses the scikit-learn library to implement linear regression. You can experiment with other regression algorithms by replacing the LinearRegression
model with the desired model from scikit-learn.
For example, to use Decision Tree Regression:
from sklearn.tree import DecisionTreeRegressor
# Create a Decision Tree Regression model
model = DecisionTreeRegressor()
# ... rest of the code remains the same
The script calculates Mean Squared Error (MSE) and R-squared (R^2) scores for both the training and test sets. The results are printed, and a plot is generated to visualize the regression line and actual data points.
This project is licensed under the MIT License - see the LICENSE.md file for details.