Почему я продолжаю получать и неиспользованные аргументы ошибки? - PullRequest
0 голосов
/ 20 апреля 2020

Я применяю алгоритм kNN к набору данных с 6 предикторами и 1 переменной класса с 1599 строками, я много раз проверял свой синтаксис и возвращался к другим примерам, чтобы попытаться найти свою ошибку. Я полностью сбит с толку в настоящее время. Я разбил набор данных на test_set, test_set_class, training_set, training_set_class. Любая помощь будет фантастической c, код и ошибку см. Ниже.

num_obs <- nrow(wine_preds3)
# set the sample size to be 80%
sample_size <- as.integer(num_obs*0.8)
# set the seed for the sample split
set.seed(0)
# randomly split 80% the data indexes in reduced wine
split_index <- sample(num_obs, size = sample_size, replace = FALSE)
# subset the reduced wine into a testing subset of 20%
test_wine_preds <- wine_preds3[-split_index, 1:6]
test_wine_class <- wine_preds3[-split_index, 7]
# subset the reduced wine into a training subset of 80%
train_wine_preds <- wine_preds3[split_index, 1:6]
train_wine_class <- wine_preds3[split_index, 7]
Pred_class <- kNN(train = train_wine_preds, test = test_wine_preds, cl = train_wine_class, k = 15)

Error in kNN(train = train_wine_preds, test = test_wine_preds, cl = train_wine_class,  : 
  unused arguments (train = train_wine_preds, test = test_wine_preds, cl = train_wine_class)
...