the -nearest neighbor algorithm is pattern recognition model that can be used for classification as well as regression often abbreviated as knnthe in -nearest neighbor is positive integerwhich is typically small in either classification or regressionthe input will consist of the closest training examples within space we will focus on -nn classification in this methodthe output is class membership this will assign new object to the class most common among its nearest neighbors in the case of the object is assigned to the class of the single nearest neighbor let' look at an example of -nearest neighbor in the diagram belowthere are blue diamond objects and orange star objects these belong to two separate classesthe diamond class and the star class