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 1088 17
WORD ORDER PROBLEM 593 110
Palindrome related problem code - Python 628 123
Music Player - Python 420 31
Implementation of SVM For Spam Mail Detection - Python 569 17
Implementation of SVM For Spam Mail Detection - THEORY 607 209
Implementation of Movie Recommender System 379 57
Implementation of K Means Clustering for Customer Segmentation 610 224
Implementation of Decision Tree Regressor Model for Predicting the Salary of the Employee 409 72
Implementation of Decision Tree Classifier Model for Predicting Employee Churn 443 83
f-strings in Python 455 154
Implementation of Logistic Regression Using Gradient Descent - SOURCE CODE 366 149
Implementation of Logistic Regression Using Gradient Descent - THEORY 427 164
Implementation of Logistic Regression Model to Predict the Placement Status of Student 408 6
Implementation of Multivariate Linear Regression Model for Sales Prediction 1387 27
Colour Detection using Pandas & OpenCV -PYTHON CODE 413 17
Colour Detection using Pandas & OpenCV 420 46
Implementation of Simple Linear Regression Model for Predicting the Marks Scored 350 152
Python Program to generate one-time password (OTP) 609 117
Create a Screen recorder using Python 355 22
Face Detection Using Python 404 20
Linear Regression Lab 1440 180
MAKING A RECTANGULAR SPIRAL IN MS PAINT 391 118
pyautogui library Theory 401 25
Multiple message sending program 410 195
Sklearn 354 156
LinearRegression 377 167

Comments