> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clickml.app/llms.txt
> Use this file to discover all available pages before exploring further.

# K-Nearest Neighbors Classifier component

> Classify examples using the majority vote of their K nearest neighbors, with configurable distance metrics and neighbor weighting strategies.

**K-Nearest Neighbors (KNN)** makes predictions by finding the K training examples closest to the input and returning their most common class. No training phase is required — the model stores the training data and queries it at prediction time.

## Configuration

| Parameter       | Description                                                                      | Default     |
| --------------- | -------------------------------------------------------------------------------- | ----------- |
| **N Neighbors** | Number of neighbors to consider.                                                 | `5`         |
| **Weights**     | `uniform` — all neighbors vote equally. `distance` — closer neighbors vote more. | `uniform`   |
| **Metric**      | Distance metric: `minkowski`, `euclidean`, `manhattan`, `chebyshev`              | `minkowski` |
| **P**           | Power parameter for `minkowski`. `p=1` is Manhattan, `p=2` is Euclidean.         | `2`         |

## Input / Output

|        | Type                  |
| ------ | --------------------- |
| Input  | `X Train` + `Y Train` |
| Output | Trained Model         |

## When to use

Simple and effective for small datasets. **Always scale features** — KNN is purely distance-based and will give misleading results if features are on different scales. Slow at prediction time on large datasets.
