5
1.0× < 1 shrinks X (Y dominates). > 1 stretches X (X dominates). Watch the boundary tilt.
Class A Class B Hover anywhere to see how k neighbors vote.
🧭 Guided challenge: predict before reveal

Choose a query point, select exactly k training points you predict will count as nearest, and predict the class. Lock the prediction before revealing the model's selected neighbors and vote.

In challenge mode, click the canvas to place the query; click training points to select predicted neighbors.
Challenge inactive.
Predicted class:
🔢 k-fold cross-validation (compare candidate k values)

Splits the current sample into f folds. For each candidate k, it trains on f−1 folds and validates on the remaining fold, then averages across rotations. The highest score is evidence for this sample and fold scheme, not a universally correct k; stability, class balance, the metric, scaling, and domain costs still matter.

5 20
(click "Run CV": needs at least 10 training points)
✨ Featured comparison
Featured comparison

Move the query point near the boundary and compare k=1 with a larger k. The nearest neighbor can be vivid and wrong.

Change k after placing the query point near mixed classes, then compare the vote explanation.

🧭 Visual explanation

Live state to watch
No state captured yet. Run or adjust the applet first.
Misread to avoid

📚 Lesson tour (5 steps)
Step 1/4: -

-

📝 Worksheet (3 questions)

Q1. Load two blobs, k=1. Add a test point right in the middle, between the blobs. Which class does k=1 assign?

Q2. Same dataset, switch to k=25. Compared to k=1, the decision boundary becomes:

Q3. Switch the closeness rule to Manhattan. Which statement is mathematically accurate?

🧪 Quick Assign · QA-KNN-01 · 10–15 min
QA-KNN-01 · Level 1 · 10–15 min
Which neighbors vote—or get averaged?

Compare classification voting with regression averaging while keeping the same k, metric, weighting, and selected neighbors.

State snapshot appears here.
♿ Text and keyboard support

Text and keyboard support

Keyboard path

  • Use Tab and Shift+Tab to move through controls.
  • Use Enter or Space on buttons, and arrow keys on sliders or select controls.
  • The visual region is focusable and described by the state summary below.

Text state summary

Reduced motion and non-visual support

Reduced-motion settings are honored where possible. The current state is also available as text, so the main result does not depend only on color, animation, or spatial position.

Accessibility note: this layer gives a text equivalent for the applet state. It does not replace a full human screen-reader audit.