- Explain the k-nearest neighbors algorithm for prediction, accompanied by a simple example.
- Using the data on the amount of the customers’ shopping by using an account card and whether they decided to upgrade their account from silver status to platinum status after receiving the upgrade offer is shown in Table 2, construct the k nearest neighbors scheme for predicting upgrades based on the data given in Table 2, and interpret the confusion matrix.
- According to these data, estimate the probability of upgrade for each division of the purchase amount, using Bayes’ theorem.
Table 2
Data on the Amount of Shopping and the decision to Upgrade
UpGrade | Purchases | PlatProfile | RowNear 1 | RowNear 2 | RowNear 3 | RowNear 4 | |
1 | 0 | 7.471 | 0 | 7 | 40 | 26 | 29 |
2 | 0 | 21.142 | 0 | 33 | 10 | 25 | 14 |
3 | 1 | 39.925 | 1 | 17 | 19 | 37 | 38 |
4 | 1 | 32.450 | 1 | 32 | 22 | 39 | 38 |
5 | 1 | 48.950 | 1 | 9 | 11 | 31 | 24 |
6 | 0 | 28.520 | 1 | 35 | 20 | 32 | 4 |
7 | 0 | 7.822 | 0 | 40 | 1 | 26 | 29 |
8 | 0 | 26.548 | 0 | 36 | 13 | 25 | 33 |
9 | 1 | 48.831 | 1 | 5 | 11 | 31 | 24 |
10 | 0 | 17.584 | 0 | 14 | 2 | 29 | 33 |
11 | 1 | 49.820 | 1 | 5 | 9 | 31 | 15 |
12 | 1 | 50.450 | 0 | 21 | 18 | 28 | 23 |
13 | 0 | 28.175 | 0 | 36 | 8 | 34 | 25 |
14 | 0 | 16.200 | 0 | 10 | 29 | 2 | 33 |
15 | 1 | 52.978 | 1 | 31 | 27 | 11 | 5 |
16 | 1 | 58.945 | 1 | 27 | 15 | 31 | 11 |
17 | 1 | 40.075 | 1 | 3 | 37 | 19 | 38 |
18 | 1 | 42.380 | 0 | 28 | 23 | 12 | 21 |
19 | 1 | 38.110 | 1 | 3 | 17 | 38 | 39 |
20 | 1 | 26.185 | 1 | 35 | 6 | 32 | 4 |
21 | 0 | 52.810 | 0 | 12 | 18 | 28 | 23 |
22 | 1 | 34.521 | 1 | 39 | 38 | 4 | 19 |
23 | 0 | 34.750 | 0 | 30 | 28 | 34 | 13 |
24 | 1 | 46.254 | 1 | 9 | 5 | 11 | 37 |
25 | 0 | 24.811 | 0 | 33 | 8 | 36 | 13 |
26 | 0 | 4.792 | 0 | 1 | 7 | 40 | 29 |
27 | 1 | 55.920 | 1 | 15 | 16 | 31 | 11 |
28 | 0 | 38.620 | 0 | 18 | 23 | 30 | 34 |
29 | 0 | 12.742 | 0 | 14 | 40 | 10 | 7 |
30 | 0 | 31.950 | 0 | 34 | 23 | 13 | 36 |
31 | 1 | 51.211 | 1 | 11 | 15 | 5 | 9 |
32 | 1 | 30.920 | 1 | 4 | 6 | 35 | 22 |
33 | 0 | 23.527 | 0 | 25 | 2 | 8 | 36 |
34 | 0 | 30.225 | 0 | 30 | 13 | 36 | 8 |
35 | 0 | 28.387 | 1 | 6 | 20 | 32 | 4 |
36 | 0 | 27.480 | 0 | 13 | 8 | 25 | 34 |
37 | 1 | 41.950 | 1 | 17 | 3 | 19 | 24 |
38 | 1 | 34.995 | 1 | 39 | 22 | 4 | 19 |
39 | 0 | 34.964 | 1 | 38 | 22 | 4 | 19 |
40 | 0 | 7.998 | 0 | 7 | 1 | 26 | 29 |
41 | 42.571 | 1 | – | – | – | – | |
42 | 51.835 | 0 | – | – | – | – |