What you're seeing
The nearest-centroid model compares Euclidean distances to the two class means. Its boundary is a straight perpendicular bisector when the means differ. This is not logistic regression: no log-loss, learned coefficient vector or probability calibration is implemented.
The k-NN model takes a majority vote of the five closest examples. It can form local islands, but this plot alone does not measure generalization or prove overfitting. Neither model is a neural network.
- Switch between nearest centroid and k-NN.
- Click Reset data to restore the same starting clusters.
- Add contradictory examples and compare local voting with shifting class means.
Two rules, one dataset
The colored background represents the prediction at sampled grid locations, while the dots are labeled training examples. Blue means class zero and amber means class one. Model switches between nearest-centroid classification and a five-neighbor majority vote without changing those examples. Both use Euclidean distance in the displayed coordinate system. The initial sixty points come from two reproducible uniform rectangles; they are not Gaussian measurements or a real benchmark. Reset data restores exactly those starting points, making before-and-after experiments repeatable.
Change the evidence
Point X and Point Y specify canvas coordinates for a new observation. Point class supplies its known label, and Add labeled point inserts that observation and redraws the classification grid. The coordinate inputs work with touch and keyboard arrows as well as a mouse. Alternatively, click or tap the plot: that shortcut inserts the opposite of the current prediction at the selected position. It deliberately creates a challenge to the classifier, not a newly discovered ground-truth label. Watch the labeled-point count in the text output to confirm the insertion.
Try a local disturbance
Start with k-NN, set Point X to 250, Point Y to 170 and Point class to Amber. Add the same point three times. Inspect whether the local amber region expands inside the mostly blue cluster. Switch to nearest centroid without resetting: those observations instead move the amber class mean, affecting one straight boundary across the plot. Reset and repeat with Blue near the amber cluster. Repeated identical examples count as separate votes in this deliberately simple model; duplication is not additional independent evidence.
Read the limits
The background samples a twelve-pixel grid, so a stair-stepped border is partly a rendering approximation. Five-neighbor voting uses insertion order to break equal-distance ties; nearest-centroid distance ties choose amber. No test split, accuracy estimate, probability, feature scaling, optimizer or neural network is present. A more irregular boundary is not automatically more accurate. The comparison demonstrates sensitivity to local examples versus class averages; deciding which rule generalizes requires held-out labeled data and an appropriate evaluation metric.