In [17]:
#实现好挫啊
def perceptron(points, w=[0,0], b=0, eta=1):
reset = True
while(reset):
for point in points:
print(point)
print(point[1] * (w[0] * point[0][0] + w[1] * point[0][1] + b))
if(point[1] * (w[0] * point[0][0] + w[1] * point[0][1] + b) <= 0):
w[0] += eta * point[1] * point[0][0]
w[1] += eta * point[1] * point[0][1]
b += eta * point[1]
break
print(w)
print(b)
else:
reset = False
return (w, b)
print(perceptron([[(3,3), 1],[(4,3), 1],[(1,1), -1]]))