November 2017
Intermediate to advanced
374 pages
10h 19m
English
For this recipe, we'll use the iris dataset. If we want to predict something such as the petal width for each flower, clustering by iris species can potentially give us better results. The KNN regression won't cluster by the species, but we'll work under the assumption that the Xs will be close for the same species, in this case, the petal length:
import numpy as npfrom sklearn import datasetsiris = datasets.load_iris()iris.feature_names
X = iris.data[:,:2] y = iris.data[:,2] from sklearn.linear_model import ...
Read now
Unlock full access