HomeMachine Learning & Neural NetworksK-Nearest Neighbors Regression: Predicting by Local Averaging

K-Nearest Neighbors Regression: Predicting by Local Averaging

Watch k-nearest neighbors regression predict a value by averaging the labels of the closest training points in 3D feature space — tune k and distance weighting and see the fit go from noisy to over-smoothed.

Machine Learning & Neural Networks3DModerate60 FPS📱 Mobile-adapted⇄ 2D version
supervised-learning ↗ Open standalone

Supervised learning splits into two jobs: classification (predict a category) and regression (predict a number). This simulator focuses on the regression side of k-nearest neighbors — instead of voting on a class, it averages the target values of the k closest labeled points in a 3D feature space to predict a continuous value at any query location. A translucent wireframe traces the true underlying function that generated the noisy training data, so you can watch the k-NN prediction surface hug it tightly at low k and flatten out as k grows, with live readouts for the predicted value, the ground truth, the pointwise error, and the RMSE across the whole domain.

⚙ Under the hood

Watch k-nearest neighbors regression predict a continuous value by averaging the labels of the closest training points in a 3D feature space — tune k and switch between uniform and distance-weighted voting to see the fit swing from noisy to over-smoothed.

machine-learningsupervised-learningknnregressionregression-algorithms3d-visualization

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)