Answers.Body: <p>Line 30 of your jupyter notebook:</p>
  <p>Perceptron(<strong>max_iter=40</strong>, random_state=0)</p>
  <p>The perceptron does not converge, it simply stops after going through the data 40 times. Always read carefully the code and especially the <a href="https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Perceptron.html" rel="nofollow noreferrer">documentation</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-27T12:36:20.077Z
Answers.Text: Wow, that instantly made sense. Thank you so much! I actually thought the convergence was just naturally achieved within the max_iter.
Answers.UserDisplayName: jacquesadit00
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-27T12:09:39.263Z
Answers.LastActivityDate: 2022-07-27T12:09:39.263Z
Answers.UserDisplayName: Edoardo Guerriero
Body: <p>I learned that the perceptron algorithm only converges if the dataset is linearly separable. I am implementing this algorithm using scikit learn.</p>
  <p>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?</p>
  <p><a href="https://i.sstatic.net/P7HaI.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/P7HaI.png" alt="enter image description here" /></a></p>
  
Tags: <machine-learning><classification><python><perceptron><scikit-learn>
Title: Why does sklearn perceptron converge for linearly inseparable data points?
UserDisplayName: jacquesadit00
ThreadText: # Why does sklearn perceptron converge for linearly inseparable data points?
  
  (Asked by: username_0 on 2022-07-27)
  
  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](https://i.sstatic.net/P7HaI.png)](https://i.sstatic.net/P7HaI.png)
  
  **Tags:** machine-learning, classification, python, perceptron, scikit-learn
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-07-27. Score: 1 | Accepted answer
  
  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](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Perceptron.html).
  
  > **Comments:**
  > **username_0**: Wow, that instantly made sense. Thank you so much! I actually thought the convergence was just naturally achieved within the max_iter.  
  
  ---
  
  