7,617 views
4 4 votes

Suppose, you have given the following dataset where x and y are the 2 features and color Red or Blue is the target variable.

a) A new data point $x=1$ and $y=1$ is given. Using Euclidean distance in 3-NN, what you predict as the color for this data point?

Dataset
x y Color
-1 1 Red
0 1 Blue
0 2 Red
1 -1 Red
1 0 Blue
1 2 Blue
2 2 Red
2 3 Blue

 

b) Now assume we have the following dataset and the target value is the price. A new data point $x=1$ and $y=1$ is given. Using Euclidean distance in 3-NN. What would be the estimated price?

Dataset
x y Price
-1 1 $100
0 1 $50
0 2 $20
1 -1 $40
1 0 $30
1 2 $40
2 2 $70
2 3 $30
50% Accept Rate Accepted 31 answers out of 62 questions

1 Answer

Best answer
1 1 vote

a) You can calculate the distances or simply visualize it:

(The code of above visualization is available here)

Based on the above visualization, 3 closest neighbors are blue points. Therefore, the predicted class is blue.

b) The 3 closest neighbors are data points: $(0,1,\$50)$, $(1,0,\$30)$, and $(1,2,\$40)$. Therefore, the estimated price is the mean of the target values $\frac{50+40+30}{3}=\$40$

selected by

Related questions

2 2 votes
1 answers 1 answer
20.9k
20.9k views
tofighi asked Jun 26, 2019
20,914 views
Use the k-means algorithm and Euclidean distance to cluster the following 8 examples into 3 clusters:$A1=(2,10), A2=(2,5), A3=(8,4), A4=(5,8), A5=(7,5), A6=(6,4), A7=(1,2...
3 3 votes
1 answers 1 answer
7.8k
7.8k views
tofighi asked Feb 3, 2020
7,789 views
How to solve this problem?https://i.imgur.com/8urywpf.jpgQ1) Complete the ? sectionsQ2) Accuracy of system if threshold = 0.5?Q3) Accuracy of system if threshold = 0.95?
0 0 votes
1 answers 1 answer
2.5k
2.5k views
tofighi asked Oct 2, 2024
2,466 views
For the following neural network, calculate accuracy of classification, given these settings
3 3 votes
2 answers 2 answers
8.4k
8.4k views
tofighi asked Apr 4, 2019
8,401 views
The scatter plot of Iris Dataset is shown in the figure below. Assume Softmax Regression is used to classify Iris to Setosa, Versicolor, or Viriginica using just petal le...
3 3 votes
1 answers 1 answer
10.8k
10.8k views
tofighi asked Mar 21, 2019
10,781 views
The scatter plot of Iris Dataset is shown in the figure below. Assume Softmax Regression is used to classify Iris to Setosa, Versicolor, or Viriginica using just petal le...