Linear Regression Lab














































Linear Regression Lab



                                  Implementation of Linear Regression Using Gradient Descent

Please go through my previous article before this lab work.And i will provide dataset to download.
Please go through below link and download "STUDENT_SCORES.CSV" file.

first
download the dataset links in this link

https://drive.google.com/drive/folders/1tzFtW4qGA3nyYErD-zjvmSppTikIYyEy?usp=sharing

SOURCE CODE:

    #used to get top five rows in the dataset

df.describe()

df.isnull().sum()

df.info()

x=df.Hours

x.head()

y=df.Scores

y.head()

iterations=1000

n=len(df)

n

n=len(df)

c=0

m=0

L=0.01

loss = []

for i in range(1000):

    y_pred=m * x + c

    MSE=(1/n)*sum((y_pred-y)**2)

    dm=(2/n)*sum(x*(y_pred-y))

    dc=(2/n)*sum((y_pred-y))

    c=c-L*dc

    m=m-L*dm

    loss.append(MSE)

print(m,c)

ypred = m*x+c

ypred 

plt.scatter(x,y,color="blue")

plt.plot(x,y_pred)

plt.xlabel("Study hours")

plt.ylabel("Scores")

plt.title("Study hours vs Scores")

plt.plot(loss)

plt.xlabel("iterations")

plt.ylabel("loss")


Output:

DATA_HEAD : 


DATA_DESCRIBE  :


m & c :


GRAPHS:



And if you get any doubt please comment below.And go through this link which I have executed in Google Colab.

In the
given link the above code available

https://colab.research.google.com/drive/1IVGE5m52soY-aJ9ZfsysoKKtfLYJOPrc?usp=sharing


More Articles of Eedula Ganesh Reddy:

Name Views Likes
Create a Virtual Private Cloud (VPC) Using AWS Coursera answers 560 17
WORD ORDER PROBLEM 527 110
Palindrome related problem code - Python 555 123
Music Player - Python 347 31
Implementation of SVM For Spam Mail Detection - Python 429 17
Implementation of SVM For Spam Mail Detection - THEORY 510 209
Implementation of Movie Recommender System 322 57
Implementation of K Means Clustering for Customer Segmentation 533 224
Implementation of Decision Tree Regressor Model for Predicting the Salary of the Employee 304 72
Implementation of Decision Tree Classifier Model for Predicting Employee Churn 376 83
f-strings in Python 389 154
Implementation of Logistic Regression Using Gradient Descent - SOURCE CODE 303 149
Implementation of Logistic Regression Using Gradient Descent - THEORY 341 164
Implementation of Logistic Regression Model to Predict the Placement Status of Student 319 6
Implementation of Multivariate Linear Regression Model for Sales Prediction 1304 27
Colour Detection using Pandas & OpenCV -PYTHON CODE 339 17
Colour Detection using Pandas & OpenCV 352 46
Implementation of Simple Linear Regression Model for Predicting the Marks Scored 283 152
Python Program to generate one-time password (OTP) 464 117
Create a Screen recorder using Python 288 22
Face Detection Using Python 347 20
Linear Regression Lab 1350 180
MAKING A RECTANGULAR SPIRAL IN MS PAINT 310 118
pyautogui library Theory 315 25
Multiple message sending program 350 195
Sklearn 279 156
LinearRegression 315 167

Comments