Используемая мной функция knn показывает следующую ошибку. Может кто-нибудь помочь мне?
Error in knn(train = auction_data_train, test = auction_data_test, cl <- auction_data_train_labels, :
NA/NaN/Inf in foreign function call (arg 6)
In addition: Warning messages:
1: In knn(train = auction_data_train, test = auction_data_test, cl <- auction_data_train_labels, :
NAs introduced by coercion
2: In knn(train = auction_data_train, test = auction_data_test, cl <- auction_data_train_labels, :
NAs introduced by coercion
Я показал структуру своих данных и код, использованный ниже.
> str(auction_data)
'data.frame': 69 obs. of 11 variables:
$ Qty : int 66 106 35 9 20 17 6 3 4 2 ...
$ Unit.Price : Factor w/ 15 levels "0-500","1000-1500",..: 12 12 13 15 15 3 9 9 8 14 ...
$ New.Invoice.Date : int 1 1 1 1 1 1 1 1 1 1 ...
$ New.Seller : int 1 1 1 1 1 1 1 1 1 1 ...
$ New.Seller.Branch: int 1 1 1 1 1 1 1 1 1 1 ...
$ New.Location : int 1 1 1 1 1 1 1 1 1 1 ...
$ New.Buyer : int 2 2 2 2 2 2 2 2 2 2 ...
$ New.Make : int 4 4 4 4 4 4 4 4 4 4 ...
$ New.Model : int 26 25 27 62 28 29 31 30 33 32 ...
$ New.Category : int 1 1 1 1 1 1 1 1 1 1 ...
$ New.Sub.Category : int 2 2 2 2 2 2 2 2 2 2 ...
> auction_data_train<-auction_data[1:59, ]
> auction_data_test<-auction_data[60:69, ]
> auction_data_train_labels<-auction_data[1:59,2]
> auction_data_test_labels<-auction_data[60:69,2]
> library(class)
> auction_data_test_pred<-knn(train=auction_data_train, test=auction_data_test,cl<-auction_data_train_labels, k=8)