April 2017
Beginner to intermediate
358 pages
9h 30m
English
Estimators scikit-learn have two and predict(). We train the algorithm using the predict() method on our testing set. We evaluate it using the predict() method on our testing set.
from sklearn.cross_validation import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=14)
Then, we import the nearest neighbor class and create an instance for it. We leave the parameters as defaults for now and will test other values later in this chapter. By default, the algorithm will choose the five nearest neighbors to predict the class of a testing sample:
from ...
Read now
Unlock full access