Even if the algorithm is very simple to implement from scratch, I prefer to employ the Scikit-Learn implementation Perceptron, so as to focus the attention on the limitations that led to non-linear neural networks. The historical problem that showed the main weakness of a perceptron is based on the XOR dataset. Instead of explaining, it's better to build it and visualize the structure:
import numpy as npfrom sklearn.preprocessing import StandardScalerfrom sklearn.utils import shufflenp.random.seed(1000)nb_samples = 1000nsb = int(nb_samples / 4)X = np.zeros((nb_samples, 2))Y = np.zeros((nb_samples, ))X[0:nsb, :] = np.random.multivariate_normal([1.0, -1.0], np.diag([0.1, 0.1]), size=nsb)Y[0:nsb] = 0.0 ...