This Project explains the implementation of Simple Linear Regression to a dataset using two different methods.
The first method uses the built-in linear regression model from the scikit-learn library to train the dataset. The following steps are followed:
- Import the required libraries (numpy, pandas, matplotlib, and scikit-learn) Load the dataset using pandas read_csv() function
- Split the dataset into independent and dependent variables
- Train the model using scikit-learn's LinearRegression() function
- Test the accuracy of the model using the R-squared score
- Visualize the best fit line using Matplotlib
The second method implements simple linear regression using the NumPy library. The following steps are followed:
- Import the required libraries (numpy, pandas, and matplotlib)
- Load the dataset using pandas read_csv() function
- Split the dataset into independent and dependent variables
- Initialize coefficients and bias Set the learning rate and number of iterations
- Train the model using gradient descent algorithm
- Test the accuracy of the model
- Visualize the best fit line using Matplotlib
Overall, this markdown file provides a basic understanding of how simple linear regression can be applied to a dataset using different libraries and methods.