Skip to article frontmatterSkip to article content

KNN

KNN with one neighbor

Which of these choices best describes the KK nearest neighbor prediction rule, with K=1K=1? Why?

  1. low bias, low variance

  2. low bias, high variance

  3. high bias, low variance

  4. high bias, high variance

KNN and standardization

Say you have a dataset about houses, and you would like to use KNN with this dataset to predict the price of a house that was not in the dataset. However, before applying KNN, you recall that it is common practice to apply a standardization that involves two steps:

  1. subtract the mean from each predictor feature (also known as centering) and

  2. divide by the standard deviation of each predictor feature (also known in this context as scaling).

However, it would be possible to preprocess the data by only performing one of these steps. We will now consider how different preprocessing choices might affect your prediction. Let

  1. y^0\hat{y}_{0} denote the KNN prediction if no preprocessing is used,

  2. y^c\hat{y}_{c} denote the KNN prediction if a centering preprocessing step is used,

  3. y^s\hat{y}_{s} denote KNN prediction if a scaling preprocessing step, and

  4. y^c+s\hat{y}_{c+s} denote KNN prediction if centering and scaling preprocessing steps are used.

In typical cases, only one of the following is true. Which is it?

  1. y^0y^c\hat{y}_{0}\neq\hat{y}_{c}

  2. y^0y^s\hat{y}_{0}\neq\hat{y}_{s}

  3. y^sy^c+s\hat{y}_{s}\neq\hat{y}_{c+s}

KNN by hand

Say you have this dataset.

EmployeeYears of ExperienceNumber of ProjectsSatisfaction Level1340.62450.83230.54560.95320.46440.7\begin{array}{|c|c|c|c|} \hline \text{Employee} & \text{Years of Experience} & \text{Number of Projects} & \text{Satisfaction Level}\\ \hline 1 & 3 & 4 & 0.6\\ 2 & 4 & 5 & 0.8\\ 3 & 2 & 3 & 0.5\\ 4 & 5 & 6 & 0.9\\ 5 & 3 & 2 & 0.4\\ 6 & 4 & 4 & 0.7 \\\hline \end{array}

Predict the satisfaction level of an employee with 3 years of experience and 3 projects using KNN with k=3k=3.

KNN by hand, III

Say you have this dataset.

EmployeeYears of ExperienceNumber of ProjectsTurnover(0:Stay,1:Leave)134024513230456153216441\begin{array}{|c|c|c|c|} \hline \text{Employee} & \text{Years of Experience} & \text{Number of Projects} & \text{Turnover}(0:\text{Stay},1:\text{Leave})\\ \hline 1 & 3 & 4 & 0\\ 2 & 4 & 5 & 1\\ 3 & 2 & 3 & 0\\ 4 & 5 & 6 & 1\\ 5 & 3 & 2 & 1\\ 6 & 4 & 4 & 1 \\\hline \end{array}

Predict whether an employee will leave or stay (0 for stay, 1 for leave) based on years of experience and the number of projects using KNN with k=3k=3.

Misclassification of 1NN with infinite data

As the number of data points approaches , the misclassification error rate of a 1-nearest-neightbor classifier must approaches 0. True or false?

Curse of dimensionality

True or false: the curse of dimensionality (as applied to regression problems) states that one can only obtain good estimates for E[YX=x]\mathbb{E}[Y|X=x] when the number of predictor features is less than the number of training samples.