Skip to content

Commit 18a878f

Browse files
author
Jeffin Francis
committed
multivariable linear regression
1 parent 5d985e5 commit 18a878f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Machine_Learning/MultivariateLinearRegression.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def cost_function(self, x, y, n_weights):
1919
return cost
2020

2121

22+
2223
def gradient(self, x, y, n_weights, epochs):
2324
m = len(y)
2425
for i in range(epochs):
@@ -31,6 +32,12 @@ def gradient(self, x, y, n_weights, epochs):
3132
print("Loss of {}th epoch is {} ".format(i , model.cost_function(x, y, self.n_weights)))
3233
return self.n_weights
3334

35+
def predict(self, x):
36+
x=np.insert(x, 0 ,1)
37+
print(x.T.dot(self.n_weights))
38+
39+
40+
3441
def plot(self):
3542
plt.plot(self.loss_)
3643
plt.xlabel("Epochs")
@@ -54,3 +61,4 @@ def plot(self):
5461
model.fit(x, y, learning_rate)
5562
print("Plotting loss")
5663
model.plot()
64+
model.predict(np.array([45,48]))

0 commit comments

Comments
 (0)