The $k$-neighbours method is an instance-based learning algorithm. It remembers the training set and when a new data point is presented it looks for the closest $k$ samples from the training set and returns
The parameter $k$ can be used to control overfitting.
We can use the iris dataset:
We can use the 8x8 digits picture example after applying PCA to reduce it to 2 dimensions: