> def fit(self, X, y, epochs = 2):
> self.w = np.ones(X.shape[1])
> self.b = 1
> for i in range(epochs):
> for x,y in zip(X,y):
> y_pred = self.model(x)
> if y == 1 and y_pred == 0:
> self.w = self.w + x
> self.b = self.b + 1
> elif y == 0 and y_pred == 1:
> self.w = self.w - x
> self.b = self.b - 1
It’s giving me the following error:
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call last)
> <ipython-input-151-1afc1e4b06e3> in <module>
> ----> 1 perceptron.fit(X_train, y_train, 2)
>
> <ipython-input-148-e4e7720338e7> in fit(self, X, y, epochs)
> 17 self.b = 1
> 18 for i in range(epochs):
> ---> 19 for x,y in zip(X,y):
> 20 y_pred = self.model(x)
> 21 if y == 1 and y_pred == 0:
>
> TypeError: zip argument #2 must support iteration
But if i remove the following line:
> for i in range(epochs):
then the code compiles without any error