The nearest neighbor classifier is among the simplest possible classifiers. When given an item to classify, it finds the training data item that is most similar to the new item, and outputs its label. An example is given in the following diagram.
최대 근접 이웃 분류기는 가장 간단한 분류기 중 하나입니다.분류할 항목이 주어졌을 때, 그것은 새로운 아이템과 가장 유사한 훈련 데이터 항목을 찾아 레이블을 출력합니다. 다음의 다이어그램의 예시를 봅시다.
In the above diagram, we show a collection of training data items, some of which belong to one class (green) and other to another class (blue). In addition, there are two test data items, the stars, which we are going to classify using the nearest neighbor method.
위의 다이어그램에서 각각 녹색과 파란색에 속한 훈련 데이터 항목들의 모음과 최대 근접 이웃 분류기를 사용하여 분류할 두 개의 테스트 항목인 별들이 있습니다.
The two test items are both classified in the “green” class because their nearest neighbors are both green (see diagram (b) above).
The position of the points in the plot represents in some way the properties of the items. Since we draw the diagram on a flat two-dimensional surface – you can move in two independent directions: up-down or left-right – the items have two properties that we can use for comparison. Imagine for example representing patients at a clinic in terms of their age and blood-sugar level. But the above diagram should be taken just as a visual tool to illustrate the general idea, which is to relate the class values to similarity or proximity (nearness). The general idea is by no means restricted to two dimensions and the nearest neighbor classifier can easily be applied to items that are characterized by many more properties than two.
위의 다이어그램에서 각각 녹색과 파란색에 속한 훈련 데이터 항목들의 모음과 최대 근접 이웃 분류기를 사용하여 분류할 두 개의 테스트 항목인 별들이 있습니다. 두 개의 테스트 항목들은 모두 녹색으로 분류되는데 그들의 최대 근접 이웃이 모두 녹색이기 때문입니다.이 구성에서 점의 위치는 항목의 속성을 나타냅니다. 평평한 2 차원 표면에 다이어그램을 그리므로 위-아래 또는 왼쪽-오른쪽 이라는 두 방향으로 이동할 수 있습니다. 항목들은 비교할 수 있는 두 가지 속성이 있습니다. 예를 들어 클리닉의 환자를 나이와 혈당 수준으로 대표한다고 상상해보십시오. 그러나 위의 다이어그램은 클래스 값을 유사성 또는 근접성으로만 관련시킬 수 있는 일반적인 아이디어를 보여주기 위한 시각적 도구로서만 사용해야합니다. 일반적인 아이디어는 결코 2 차원으로만 제한되지 않으며 최대 근접 분류기는 그보다 더 많은 속성을 특징으로 하는 항목들에 쉽게 적용될 수 있습니다.(그림처럼 2차원적으로 표현 되지만은 않는다는 의미)
An interesting question related to (among other things) the nearest neighbor classifier is the definition of distance or similarity between instances. In the illustration above, we tacitly assumed that the standard geometric distance, technically called the Euclidean distance, is used. This simply means that if the points are drawn on a piece of paper (or displayed on your screen), you can measure the distance between any two items by pulling a piece of thread straight from one to the other and measuring the length.
최대 근접 이웃 분류기와 관련된 흥미로운 질문은 항목 간 거리 또는 유사성에 대해 어떻게 정의를 내렸냐 하는 것입니다. 위의 그림에서 기술적 용어로 유클리드 거리라고 하는, 기하학적 거리(기하학이란 : 공간에 있는 도형의 성질 즉, 대상들의 치수, 모양, 상대적 위치 등을 연구하는 수학의 한 분야이다. 기하학이 다루는 대상으로는 점, 선, 면, 도형, 공간과 같은 것이 있다.)가 사용된다고 암묵적으로 가정했습니다. 이는 단순히 종이 위나 화면에 점들이 있을 때, 실을 한 점에서 다른 점까지 똑바로 잡아 당겨 길이를 측정하여 두 항목 사이의 거리를 측정 할 수 있음을 의미합니다.
Using the geometric distance to decide which is the nearest item may not always be reasonable or even possible: the type of the input may, for example, be text, where it is not clear how the items are drawn in a geometric representation and how distances should be measured. You should therefore choose the distance metric on a case-by-case basis.
(두 기준 사이의 길이를 의미하는) 기하학적 거리를 사용하여 가장 가까운 항목을 결정하는 것은 항상 합리적이거나 가능하지 않을 수도 있습니다. 입력 방식이 (점이 아니라) 텍스트 일 수 있고 이럴 때는 거리라는 개념으로 측정하기 어려울 수 있습니다. 따라서 상황을 봐가며 거리로 측정하는 방식 채택 여부를 결정해야합니다.
In the MNIST digit recognition case, one common way to measure image similarity is to count pixel-by-pixel matches. In other words, we compare the pixels in the top-left corner of each image to one another and if the more similar color (shade of gray) they are, the more similar the two images are. We also compare the pixels in the bottom-right corner of each image, and all pixels inbetween. This technique is quite sensitive to shifting or scaling the images: if we take an image of a '1' and shift it ever so slightly either left or right, the outcome is that the two images (before and after the shift) are very different because the black pixels are in different positions in the two images. Fortunately, the MNIST data has been preprocessed by centering the images so that this problem is alleviated.
<< I.머신러닝의 종류