I'm trying to run the code using the Biopsy dataset from R. The idea is creating a Knn machine learning.
I appreciate your help.
I tried to run the code but I got some warnings. e.g. NAs introduced by coercion.
cc = c(1:100)*0
for (i in 1:100) {
L<- sample(1:nrow(biopsy_sem_NA_nas_Linhas),round(nrow(biopsy_sem_NA_nas_Linhas)/3))
train_sem_NA_Linhas = biopsy_sem_NA_nas_Linhas[-L,2:11]
test_sem_NA_Linhas = biopsy_sem_NA_nas_Linhas[L,2:11]
cl = factor( biopsy_sem_NA_nas_Linhas[-L, 11])
fit = knn(train_sem_NA_Linhas, test_sem_NA_Linhas, cl, k = 5)
c_matrix = table(fit[1:length(L)], factor(biopsy_sem_NA_nas_Linhas[L, 11]))
acc[i] = cat('Accurancy:', sum(diag(c_matrix))/sum(c_matrix)*100, '%')
}
mean(acc)
Errors below appeared:
Error in knn(train_sem_NA_Linhas, test_sem_NA_Linhas, cl, k = 5) : NA/NaN/Inf in foreign function call (arg 6) In addition: Warning messages: 1: In knn(train_sem_NA_Linhas, test_sem_NA_Linhas, cl, k = 5) : NAs introduced by coercion 2: In knn(train_sem_NA_Linhas, test_sem_NA_Linhas, cl, k = 5) : NAs introduced by coercion