I have read this Wikipedia article. But, the idea is still very fuzzy to me.Suppose, k=5.Then, we have, $X_5 = \{A, B, C, D, E\}$$Y_2 = \{Triangle, Square\}$$R_5 = \{9, 8, 5, 1, 4 \}$ (just assumed)Now, $\mu_{Triangle} = \frac{5}{2} = 2.50$and, $\mu_{Square} = \frac{22}{3} = 7.33$Since, $\mu_{Triangle} < \mu_{Square}$, $class(?) == Triangle$.Am I correct?
How does the Nearest Centroid method work?
classification
You are making a mistake regarding what is given: during training, you don't have a radius $R$. You have the coordinates $\vec{x}$ and the label $y$ for each point:$$ \vec{x}_1 = [-2;1] \quad \vec{x}_2 = [1;2] \quad \vec{x}_3 = [0;-1] \quad \vec{x}_4 = [1;0] \quad \vec{x}_5 = [1;1] $$and$$ y_1 = T \quad y_2=T \quad y_3=T \quad y_4=S \quad y_5=S $$with that, your trained centroids are$$ \mu_T = \frac 13 [-2 + 1 + 0; 1 + 1 - 1] = \left[-\frac 13, \frac 13\right] $$$$ \mu_S = \frac 12 [1 + 1; 0 + 1] =\left[1, \frac 12\right]$$You calculate these centroids before you get any test values.Then, for testing, for your observed point $\vec{x} = [1,1]$, you calculate the Euclidean distance between the point $\vec{x}$ and the centroids $\mu_T$ and $\mu_S$:$$ \| \vec{x} - \mu_T \| = \left\| [1;1] - \left[-\frac 13; \frac 13\right] \right\| = \left\| \left[\frac 23; \frac 43\right] \right\| = 1.49 $$ $$ \| \vec{x} - \mu_S \| = \left\| [1;1] - \left[-1; \frac 12\right] \right\| = \left\| \left[0; \frac 12 \right] \right\| = 0.5$$Finally, the term $\hat{y} = \arg\min_{l \in \mathbf{Y}} \|\vec{x}-\mu_l\|$ is used to find the estimated class $\hat{y}$ (the hat symbol is to denote that this is an estimated $y$, not one we knew before.). $\arg\min$, means that you find the minimum value - which is 0.5 in our case, and chose which argument, i.e. which class, leads to that minimum value. In our case, the class which leads to the minimal distance is $S$, so the result is $\hat{y} = S$, and our test point is a square.