K Nearest Neighbors
References
Wikipedia
Youtube
Scikitlearn
K Nearest Neighbors
- Start with a set of example points
- The goal is to classify new points
- Calculate Geometric Distance to new point
- Sort distances in decreasing order
- Take k smallest distances
- Use majority class as prediction for new point
K Nearest Neighbor in KNIME
On the KNIME Server there is an example in the ‘Machine_Learning’ folder. Get the example from the server and open it. Your KNIME should look as follows.

The video here shows how to build the workflow.
- File Reader
- Color Manager and Scatter Plot
- Look for patterns and relationships
- Partitioning
- Divide into Training and Testing
- Normalizer (Optional)
- Precondition data so every feature has similar weight
- K Nearest Neighbor
- Inputs are training and testing data
- Scorer
- Test how the learner performed
K Nearest Neighbor in Python
This notebook shows how to run K Nearest Neighbors in Python.
- Uses scikit learn library
- Steps are the same as KNIME
- Divide into Training and Testing
- Train a classifier
- Apply classifier to test set
- Score