The KNN is a basic supervised learning algorithm used for both regression. It operates on the principle of proximity between data points. To determine a new data point, the KNN algorithm finds its closest k neighbors in the training dataset. The category of the new data point is then decided based on the common class among its closest data points.