Category : numerical-analysis

I tried to write my own code for linear regression. the code is below: import numpy as np class LinearRegression: def __init__(self,x=None,y=None): self.x = x self.y = y def fit(self,x=None,y=None,method = "SGD",num_iter=1000,learning_rate = 0.01): y_new = np.array(y).reshape(-1,1) if np.ndim(x)==1: self.theta = np.zeros(2).reshape(-1,1) x_new = np.array([[1]+[x[i]] for i in range(len(y))]) else: x_new = np.array([[1]+list(x[i,:]) for i ..

Read more