-2
Good afternoon,
Why does my KNN code in R produce "predictions" that are equal to the Test Base responses themselves? That is, if we change the responses of the test base the "forecast" changes equally (and the forecast table turns out to be 100% accuracy)?
Code:
a <- read.csv2("Base Treino.csv")
b <- read.csv2("Base Teste.csv")
a_cl <- a[1:10,4]
pr=knn(a,b,a_cl, k=2)
a_teste_cat <- b[,4]
tab <- table(pr,a_teste_cat)
tab
Base Treino:
100 33 100 0
100 66 75 0
100 100 50 0
100 0 25 100
100 0 100 100
0 0 25 100
0 0 75 100
0 0 0 100
0 33 100 0
0 66 100 0
Base Teste:
100 33 100 0
100 66 75 0
0 0 25 100
0 0 75 100
0 0 0 100
0 66 100 0
Hi Victor, why did you include the test set when training the KNN? A dirty word is to improve the name of the variables, instead of 'a', use something like 'data''.
– Filipe Lauar
Filipe, good night. knn syntax asks me to insert the test base in the parameters... How you perform?
– VictorS