title: Python perceptron zip error
body: <p>I am trying to implement a perceptron on my dataset, and when running it, I keep getting an error saying:</p>
  
  <blockquote>
    <p>TypeError: zip argument #2 must support iteration</p>
  </blockquote>
  
  <p>Here's the code I put in:</p>
  
  <pre><code>ppn = Perceptron(eta=0.1, n_iter=10)
  ppn.fit(X,y)
  plt.plot(range(1, len(ppn.errors_)+1), ppn.errors_, marker='o')
  plt.xlabel('Epochs')
  plt.ylabel('number of misclassifications')
  plt.show()
  </code></pre>
  
  <p>Here is the perceptron I implemented:</p>
  
  <pre><code>class Perceptron(object):
      def __init__(self, eta=0.01, n_iter=10):
          self.eta = eta
          self.n_iter = n_iter
      def fit(self, X, y):
          self.w_ = np.zeros(1 + X.shape[1])
          self.errors_ = []
          for _ in range(self.n_iter):
              errors = 0
              for xi, target in zip(X, y):
                  update = self.eta * (target - self.predict(xi))
                  self.w_[1:] += update * xi
                  self.w_[0] += update
                  errors += int(update != 0.0)
              self.errors_.append(errors)
          return self
  
      def net_input(self, X):
          return np.dot(X, self.w_[1:]) + self.w_[0]
  
      def predict(self, X):
          return np.where(self.net_input(X) &gt;= 0.0, 1, -1)
  </code></pre>