Skip to main content

Posts

IMPLEMENTATION OF LINEAR REGRESSION IN PYTHON

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 , ...
Recent posts

EVALUATION METRICS FOR REGRESSION

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...

LINEAR REGRESSION - MATHEMATICAL IMPLEMENTATION (SUPERVIZED MACHINE LEARNING)

 LINEAR REGRESSION LINEAR REGRESSION is a type of supervised machine learning which deals with continuous data. LINEAR REGRESSION comes under regression in supervised machine learning.   (don't know what is continuous data? refer to my previous blog or click the link given below). Click here to know what is continuous data From the above graph, we can see X is an independent variable and Y is a dependent variable, based on the features of X the Y gets plotted. Apart from X and Y we also have a Regression line, which is also known as the line of linear regression. This regression line shows the relationship between the Independent variable(x) and the dependent variable(Y). The formula to find the regression line is  y=mx+c   or    yhat=β0+β1*X Here, β0 =Intercept β1 =Coeeficient X= x values Formula to find out  β1 is: Formula to find  β0 is:   So for clear understanding let's take a graph Here, The orange dots are actual values. The gre...

INTRODUCTION TO MACHINE LEARNING

  MACHINE LEARNING Machine learning is nothing but training the machine with data in order to predict the correct output and to give us better accuracy. TYPES OF MACHINE LEARNING SUPERVISED MACHINE LEARNING UNSUPERVISED MACHINE LEARNING REINFORCEMENT LEARNING   SUPERVISED MACHINE LEARNING In supervised machine learning, we have both X and Y labels. Here, X is an independent variable and Y is a dependent variable. Based on the features of X we are going to predict the output Y. Here X features are( Outlook, Temp, Humidity, Windy ) based on these factors we predict the output or we also call it as target variable Y which is ( Play ).   X is independent.   Y is dependent on X that means Y which is ( Play) can only be predicted based on the X features which are ( Outlook,Temp, Humidity, Windy ). Considering X features we can say whether we can Play on those conditions or not. TYPES OF SUPERVISED MACHINE LEARNING Supervised machine learning is further divided into: CLAS...