import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model class gradientdescent: def fit(self,X,Y): lr=0.01 m=5 b=0 m_gradient=0 for _ in range(1000): m_gradient= (lr*(np.sum((m*X+b-Y)*X))/(np.size(X))) b_gradient= (lr*(np.sum(m*X+b-Y))/(np.size(X))) self.m=m-m_gradient #this part is giving me conflicting results self.b=b-b_gradient #and this part def predict(self,X): return self.m*X+self.b X=np.array([1,2,3,4,5,6,7,8]) Y=np.array([1,2,4,4,5,7,8,8]) clf=gradientdescent() clf.fit(X,Y) plt.scatter(X,Y, color=’black’) plt.plot(X, clf.predict(X)) #np.size(X) I have… Read More Linear regression (Gradient descent) single feature