Recall from Chapter 1, The Fundamentals of Machine Learning that the goal of classification tasks is to use one or more features to predict the value of a discrete response variable. Let's work through a toy classification problem. Assume that you must use a person's height and weight to predict his or her sex. This problem is called binary classification because the response variable can take one of two labels. The following table records nine training instances:
Height | Weight | Label |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Unlike the previous chapter's simple linear regression problem, we are now using features from two explanatory variables to predict the value of the response variable. KNN is not limited to two features; the algorithm can use an arbitrary number of features, but more than three features cannot be visualized. Let's visualize the data by creating...