July 2017
Intermediate to advanced
382 pages
9h 13m
English
In order to find out how good our perceptron performs, we can calculate the accuracy score on all data samples:
In [10]: from sklearn.metrics import accuracy_score... accuracy_score(p.predict(X), y)Out[10]: 1.0
Perfect score!
Let's have a look at the decision landscape by bringing back our plot_decision_boundary from the earlier chapters:
In [10]: def plot_decision_boundary(classifier, X_test, y_test):... # create a mesh to plot in... h = 0.02 # step size in mesh... x_min, x_max = X_test[:, 0].min() - 1, X_test[:, 0].max() + 1... y_min, y_max = X_test[:, 1].min() - 1, X_test[:, 1].max() + 1... xx, yy = np.meshgrid(np.arange(x_min, x_max, h),... np.arange(y_min, y_max, h))... ... X_hypo = np.c_[xx.ravel().astype(np.float32), ...
Read now
Unlock full access