Linear Regression
Linear Regression
ROLL NO : F2022132029
JOB NO:6
Title : LINEAR REGRESSION METHOD
Introduction:
Linear regression analysis is used to predict the value of a variable based on the value of another
variable. The variable you want to predict is called the dependent variable. The variable you are
using to predict the other variable's value is called the independent variable.
Programme:
import numpy as np
import matplotlib.pyplot as plt
#4 . Gradient Descent
def gradient_descent(X, Y, m, b, learning_rate, iterations):
N = len(Y)
for _ in range(iterations):
Y_pred = predict(m, b , X)
dm = -(2/N) * np.sum(X * (Y - Y_pred))
db = -(2/N) * np.sum(Y - Y_pred) b = b - learning_rate * db
return m, b
plt.xlabel('X')
plt.ylabel('Y')
plt.title( 'Linear Regression Fit')
plt.show()
X values:

Y values:
Y-pred values: