June 2016
Beginner to intermediate
304 pages
6h 24m
English
We learned how to use k-nearest neighbors algorithm to build a classifier. The good thing is that we can also use this algorithm as a regressor. Let's see how to use it as a regressor.
import numpy as np import matplotlib.pyplot as plt from sklearn import neighbors
# Generate sample data amplitude = 10 num_points = 100 X = amplitude * np.random.rand(num_points, 1) - 0.5 * amplitude
# Compute target ...