to the new data pointwe can consider any fixed number of neighbors in the training (for examplethe closest three or five neighborsthenwe can make prediction using the majority class among these neighbors we will go into more detail about this in for nowwe'll use only single neighbor all machine learning models in scikit-learn are implemented in their own classeswhich are called estimator classes the -nearest neighbors classification algorithm is implemented in the kneighborsclassifier class in the neighbors module before we can use the modelwe need to instantiate the class into an object this is when we will set any parameters of the model the most important parameter of kneighbor sclassifier is the number of neighborswhich we will set to in[ ]from sklearn neighbors import kneighborsclassifier knn kneighborsclassifier(n_neighbors= the knn object encapsulates the algorithm that will be used to build the model from the training dataas well the algorithm to make predictions on new data points it will also hold the information that the algorithm has extracted from the training data in the case of kneighborsclassifierit will just store the training set to build the model on the training setwe call the fit method of the knn objectwhich takes as arguments the numpy array x_train containing the training data and the numpy array y_train of the corresponding training labelsin[ ]knn fit(x_trainy_trainout[ ]kneighborsclassifier(algorithm='auto'leaf_size= metric='minkowski'metric_params=nonen_jobs= n_neighbors= = weights='uniform'the fit method returns the knn object itself (and modifies it in place)so we get string representation of our classifier the representation shows us which parameters were used in creating the model nearly all of them are the default valuesbut you can also find n_neighbors= which is the parameter that we passed most models in scikit-learn have many parametersbut the majority of them are either speed optimizations or for very special use cases you don' have to worry about the other parameters shown in this representation printing scikit-learn model can yield very long stringsbut don' be intimidated by these we will cover all the important parameters in in the remainder of this bookwe will not show the output of fit because it doesn' contain any new information first applicationclassifying iris species