Hello everyone, in this blog I will explain how to implement Linear Regression using python. This requires a pre-requisite which is Mathematical Implementation Of Linear Regression, which I have explained in one of my previous blogs, I have pasted the link below. Click here to know the mathematical implementation of Linear Regression Get to know the Mathematical implementation first, or else you might feel very difficult to understand this blog. So let's start, now I will show how to implement Linear Regression in python. NOTE: Lines highlighted with Yellow color are actually code. STEP 1: Import necessary libraries that are required for numerical operations, importing data frames and plotting the graph. import numpy as np import pandas as pd import matplotlib.pyplot as plt STEP 2: Read the data The data will be in the format of CSV, EXCEL there are still some, but I have mentioned only two . The data which I'm taking is tiny it has only two columns SAT and GPA , ...
Hello guys, in my previous blog that is Mathematical implementation of Linear Regression I explained the internal operations of the algorithm, in this blog I will explain you the evaluation metrics that are used to evaluate the model. Before going to the Evaluation metrics let me show you a graph. (x,y) is an Actual value. (x,ŷ) is an predicted value. y-ŷ= Difference between the actual and predicted value /also called as Residual. EVALUATION METRICS MEAN SQUARED ERROR(MSE) MEAN ABSOLUTE ERROR(MAE) R-SQUARED ROOT MEAN SQUARE(RMSE) MEAN SQUARED ERROR (MSE) MSE is nothing but the squared difference between the actual and the predicted value. Let me take an example Here y is the actual value and yhat is the predicted value. Let's begin the process: Calculate the difference between actual (Y) and predicted (YHAT) . Here Error is the difference between Y and Yhat Error=Y - Yhat So, our next step is to square this Error We have got the squares of the error now, now we have...