What is Simple Linear Regression?
Simple Linear Regression is a statistical method that allows seeing the relationship between the dependent and independent variables or we can say a regression model having one independent variable.
The Independent Variable is a variable that helps in the prediction or we can say that helps the dependent variable to make predictions.
The Dependent Variable is a variable that is the outcome or we can say the result which is the actual outcome of the prediction.
The above image gives you insight that ‘y’ denotes the dependent variable and ‘x’ denotes an independent variable. It is a simple linear regression equation.
In the above equation, ‘Constant’ is a predefined requirement that affects the situation and ‘Coefficient’ is a variable constant that multiple with the independent variable to give the impact or the significance to the dependent variable.
We are using a dataset of the employe's having years of experience and there estimated salary.
Now we are doing the Simple linear Regression analysis on the above dataset.
Step 1. Import the Libraries
Step 2. Importing the Dataset
Step 3. Split the data into a matrix of features(X) and the dependent variable(y).
Step 4. Splitting the matrix of features(X) and dependent variable(y) into training and test set.
Step 5. Fitting a linear model to test and training dataset.
Step 6. Predicting the Test result.
Step 7. Making the Confusion Matrix to do predictions.
Confusion Matrix helps to give the accuracy of our model that is the number of false values and true values.
Step 8. Do the visualization of the model.