# help me understand kNN

Hello guys,

I read all the documentation about how kNN works but I have some questions still:

Lets say I try to use kNN to recognize capital letters. I generate my training data by creating a black/white 10x20 matrix for every character.

Now I want to find the letters in my picture (e.g. a Screenshot of some random text) and already have a resized 10x20 Mat for every letter. My "k" of kNN is 1. Does the algorythm now check every pixels 1 nearest neighbour? So it applys the kNN algorythm 20x10 = 200 times for each character it found? And afterwars it replys the letter with the most accordance? If not, how does it work?

Would be nice if you could help me understand it!

edit retag close merge delete

Sort by ยป oldest newest most voted

Conveniently, OpenCV tutorials has an example on just this thing. Take a look!

more

I read those tutorials before I asked the question but they didn't really help me to understand what's going on in my example.

( 2017-11-03 05:40:23 -0600 )edit

So what do you not understand? The concept behind kNN? I think that's what you're asking, not the implementation details.

Each feature is a dimension of data, the value of each sample is it's location in that dimension. Calculate the distance from each training pt to your sample pt, and use the k nearest neighbors to get your classification.

You've got 200 dimensions to your data, and I dunno how many sample points.

( 2017-11-03 09:30:47 -0600 )edit

I thought way too complicated and got confused by the Dimensions. My pictures are 2D but in this case every pixel is a dimension, so every sample has 200 dimensions which get compared by knn. Got it, thx!

( 2017-11-20 08:57:57 -0600 )edit

Official site

GitHub

Wiki

Documentation

## Stats

Seen: 225 times

Last updated: Nov 02 '17