Continuing on the biopsy dataset.
Questions
- Create a vector
train
with all the numbers from 1 to 400
- Create a subset of biopsy with only the response and the rows with
the index not in
train
and store it in test.Y
- Create a subset of biopsy with only the predictors and the rows with
the index not in
train
and store it in test.X
- Create a subset of biopsy with only the response and the rows with
the index in
train
and store it in train.Y
- Create a subset of biopsy with only the predictors and the rows with
the index in
train
and store it in train.X
- Create a K-Nearest Neighbors classifier with K = 1 and K = 3,
store the predictions in
knn.pred1
and knn.pred3
respectively
- For both classifiers create a table that compares the predicted results
with the actual diagnosis and store it in
knn.table1
and knn.table3
- For both classifiers calculate the accuracy and store in
knn.acc1
and knn.acc3
Assume that:
- The
MASS
and class
libraries have been loaded
- The
biopsy
dataset has been loaded and attached
- The rows with NA values have been dropped
- The
ID
column has been dropped