creating our first classifier let us start with the simple and beautiful nearest neighbor method from the previous although it is not as advanced as other methodsit is very powerful as it is not model-basedit can learn nearly any data howeverthis beauty comes with clear disadvantagewhich we will find out very soon starting with the -nearest neighbor (knnalgorithm this timewe won' implement it ourselvesbut rather take it from the sklearn toolkit therethe classifier resides in sklearn neighbors let us start with simple -nearest neighbor classifierfrom sklearn import neighbors knn neighbors kneighborsclassifier(n_neighbors= print(knnkneighborsclassifier(algorithm=autoleaf_size= n_neighbors= = warn_on_equidistant=trueweights=uniformit provides the same interface as all the other estimators in sklearn we train it using fit()after which we can predict the classes of new data instances using predict()knn fit([[ ],[ ],[ ],[ ],[ ],[ ]][ , , , , , ]knn predict( array([ ]knn predict( array([ ]knn predict( neighborswarningkneighborsneighbor + and neighbor have the same distanceresults will be dependent on data order neigh_distneigh_ind self kneighbors(xarray([ ]to get the class probabilitieswe can use predict_proba(in this casewhere we have two classes and it will return an array of two elements as in the following codeknn predict_proba( array([ ]]knn predict_proba( array([ ]]knn predict_proba( array([ ]]