November 2016
Beginner to intermediate
941 pages
21h 55m
English
Let's see how to build a simple classifier using some training data.
simple_classifier.py file that is already provided to you as reference. Assuming that you imported the numpy and matplotlib.pyplot packages like we did in the last chapter, let's create some sample data:X = np.array([[3,1], [2,5], [1,8], [6,4], [5,2], [3,5], [4,7], [4,-1]])
y = [0, 1, 1, 0, 0, 1, 1, 0]
y list contains 0s and 1s. 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] for i in range(len(X)) if y[i]==0]) class_1 = np.array([X[i] ...