def main(): #load dataset data = pd.read_csv('../data/iris.data', sep=',', header=0) #classifying with two classes only dataset = data[data['CLASS'] != 'Iris-virginica'] #using the LENGHTS for separation X = dataset[['SEPAL_LENGHT','PETAL_LENGHT']] #converting classes to -1 and 1 y = dataset['CLASS'].apply(convert) #train Perceptron model = Perceptron(X.shape[1]) model.fit(X,y) #plotting w = model.get_w() #decision boundary: w[0] + w[1]*x + w[2]*y = 0 x1 = np.linspace(0, 10, 100) x2 = -w[0]/w[2] - (w[1]/w[2])*x1 plt.plot(x1,x2,'k') plt.scatter(X['SEPAL_LENGHT'],X['PETAL_LENGHT']) plt.show()