Let's see how to build a simple classifier using some training data:
- We will use the simple_classifier.py file, already provided to you as a reference. To start, we import the numpy and matplotlib.pyplot packages, as we did in Chapter 1, The Realm of Supervised Learning, and then we create some sample data:
import numpy as npimport matplotlib.pyplot as pltX = np.array([[3,1], [2,5], [1,8], [6,4], [5,2], [3,5], [4,7], [4,-1]])
- Let's assign some labels to these points:
y = [0, 1, 1, 0, 0, 1, 1, 0]
- As we have only two classes, the y list contains 0's and 1's. In general, if you have N classes, then the values in y will range from 0 to N-1. Let's separate the data into classes based on the labels:
class_0 = np.array([X[i] ...