import numpy as np
import math
import matplotlib.pyplot as plt
x = np.array ([[2, 3], [4, 6], [7, 8], [12, 15]])
t = np.array ([5, 8, 14, 17])
alpha = 0.1
fir0 = np.random.random()
fir1 = np.random.random()
fir2 = np.random.random()
theta = np.array([fir1, fir2])
eps = 1e-4
e0 = 9
e1 = 9
e2 = 9
while e0 >= eps or e1 >= eps or e2 >= eps:
i = 0
e0 = (np.sum((x[:, i] * theta[i])) + fir0 * 1 - t[i])
e1 = e0 * x[1, i]
e2 = e0 * x[2, i]
fir0 = fir0 - alpha * e0
fir1 = fir1 - alpha * e1
fir2 = fir2 - alpha * e2
i += 1
print (fir0, fir1, fir2)
def __init__(self, w1, w2):
self.w1 = 0
self.w2 = 0.2
self.alpha = 0.01
self.eps = math.e**(-4)