Getting ready

The MNIST digit dataset is composed of thousands of labeled images that are 28x28 pixels in size. Although this is considered a small image, it has a total of 784 pixels (or features) for the nearest-neighbor algorithm. We will compute the nearest-neighbor prediction for this categorical problem by considering the mode prediction of the nearest k neighbors (k=4, in this example).

Get TensorFlow Machine Learning Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.