質問

Given this sample:

$$\begin{array}{|c|c|c|} \hline X1 & X2 (Kg/m^2) & \text{Class} \\ \hline 8 & 4 & A \\ \hline 4 & 5 & B \\ \hline 4 & 6 & B \\ \hline 7 & 7 & A \\ \hline 5 & 6 & B \\ \hline 6 & 5 & A \\ \hline \end{array}$$ we then calculate each of Euclidean distance values to the row:

with P = (7, 4)

$$\begin{array}{|c|c|c|} \hline X1 & X2 (Kg/m^2) & \text{Square distance to query point P} \\ \hline 8 & 4 & (8 - 7)^2 + (4 - 4)^2 = 1 \\ \hline 4 & 5 & (4 - 7)^2 + (5 - 4)^2 = 10 \\ \hline 4 & 6 & (4 - 7)^2 + (6 - 4)^2 = 13 \\ \hline 7 & 7 & (7 - 7)^2 + (7 - 4)^2 = 9 \\ \hline 5 & 6 & (5 - 7)^2 + (6 - 4)^2 = 8 \\ \hline 6 & 5 & (6 - 7)^2 + (5 - 4)^2 = 2 \\ \hline \end{array}$$

But what if each class has more than one attribute , for example: $$\begin{array}{|c|c|c|c|} \hline X1 & X2 (Kg/m^2) & \color{red}{X3} & \text{Square distance to query point P} \\ \hline 8 & 4 & \color{red}{2} & (8 - 7)^2 + (4 - 4)^2 = 1 \\ \hline 4 & 5 & \color{red}{5} & (4 - 7)^2 + (5 - 4)^2 = 10 \\ \hline 4 & 6 & \color{red}{1} & (4 - 7)^2 + (6 - 4)^2 = 13 \\ \hline 7 & 7 & \color{red}{4} & (7 - 7)^2 + (7 - 4)^2 = 9 \\ \hline 5 & 6 & \color{red}{6} & (5 - 7)^2 + (6 - 4)^2 = 8 \\ \hline 6 & 5 & \color{red}{2} & (6 - 7)^2 + (5 - 4)^2 = 2 \\ \hline \end{array}$$

How to calculate the Euclidean distance in this case?

正しい解決策はありません

ライセンス: CC-BY-SA帰属
所属していません cs.stackexchange
scroll top