the -nearest neighbors algorithm for regression is implemented in the kneighbors regressor class in scikit-learn it' used similarly to kneighborsclassifierin[ ]from sklearn neighbors import kneighborsregressor xy mglearn datasets make_wave(n_samples= split the wave dataset into training and test set x_trainx_testy_trainy_test train_test_split(xyrandom_state= instantiate the model and set the number of neighbors to consider to reg kneighborsregressor(n_neighbors= fit the model using the training data and training targets reg fit(x_trainy_trainnow we can make predictions on the test setin[ ]print("test set predictions:\ {}format(reg predict(x_test)) supervised learning