KNN in R: 'train and class have different lengths'?

前端 未结 5 1136
清酒与你
清酒与你 2020-12-11 01:49

Here is my code:

train_points <- read.table(\"kaggle_train_points.txt\", sep=\"\\t\")
train_labels <- read.table(\"kaggle_train_labels.txt\", sep=\"\\t         


        
5条回答
  •  情书的邮戳
    2020-12-11 02:24

    Simply set drop = TRUE while you're excluding cl from dataframe, it causes to remove dimension from an array which have only one level:

    cl = train_labels[,1, drop = TRUE]
    knn(train_points, test_points, cl, k = 5)
    

提交回复
热议问题