1

I learned that the perceptron algorithm only converges if the dataset is linearly separable. I am implementing this algorithm using scikit learn.

The blue and orange points are from the training set, while red and green are from the test set. Clearly the blobs are inseparable, but why does my perceptron algorithm converge and give me a decision boundary?

enter image description here

1 Answers1

1

Line 30 of your jupyter notebook:

Perceptron(max_iter=40, random_state=0)

The perceptron does not converge, it simply stops after going through the data 40 times. Always read carefully the code and especially the documentation.

Edoardo Guerriero
  • 5,153
  • 1
  • 11
  • 25
  • Wow, that instantly made sense. Thank you so much! I actually thought the convergence was just naturally achieved within the max_iter. – jacquesadit00 Jul 27 '22 at 12:36