0 ×

K Nearest Neighbor (Distance Function)

DeprecatedKNIME Distance Matrix Extension version 4.3.0.v202011191420 by KNIME AG, Zurich, Switzerland

Classifies a set of test data based on the k Nearest Neighbor algorithm using the training data.

Note that for the Euclidean distance on numeric columns the other K Nearest Neighbor node performs better as it uses an efficient index structure. The implementation of this node performs an exhaustive search of all points to all potential neighbors and is therefore suited for small to medium data sets only.


Column with class labels
Select column to be used as classification attribute.
Number of neighbours to consider (k)
Select the number of nearest neighbors used to classify a new instance. An odd number is recommended to avoid ties.
Weight neighbours by distance
Includes the distance of the query pattern to the stored training patterns into the classification. Closer neighbors have greater influence on the resulting class than the ones further away. (Still only k neighbors will be considered, however!)
Output class probabilities
If this option in enabled, additional columns, containing the class probabilities, will be appended to the output table.

Input Ports

Input port for the training data
Input port for the test data
The distance function to use.

Output Ports

Output data with class labels

Best Friends (Incoming)

Best Friends (Outgoing)


To use this node in KNIME, install KNIME Distance Matrix from the following update site:


A zipped version of the software site can be downloaded here.

You don't know what to do with this link? Read our NodePit Product and Node Installation Guide that explains you in detail how to install nodes to your KNIME Analytics Platform.

Wait a sec! You want to explore and install nodes even faster? We highly recommend our NodePit for KNIME extension for your KNIME Analytics Platform. Browse NodePit from within KNIME, install nodes with just one click and share your workflows with NodePit Space.


You want to see the source code for this node? Click the following button and we’ll use our super-powers to find it for you.