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,506
  • 1
  • 15
  • 25