September 2019
Intermediate to advanced
420 pages
10h 29m
English
The other really helpful method that knn provides is called findNearest. It can be used to predict the label of a new data point based on its nearest neighbors.
Thanks to our generate_data function, it is actually really easy to generate a new data point! We can think of a new data point as a dataset of size 1:
In [17]: newcomer, _ = generate_data(1)... newcomerOut[17]: array([[91., 59.]], dtype=float32)
Our function also returns a random label, but we are not interested in that. Instead, we want to predict it using our trained classifier! We can tell Python to ignore an output value with an underscore (_).
Let's have a look at our town map again. We will plot the training set as we did earlier, but ...
Read now
Unlock full access