Getting ready

To illustrate how making predictions with nearest-neighbors works in TensorFlow, we will use the Boston housing dataset. Here, we will be predicting the median neighborhood housing value as a function of several features.

Since we consider the training set the trained model, we will find the k-NNs to the prediction points, and will calculate a weighted average of the target value.

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.