I try to loop different parameters in the in cv.kknn , specifically in kvc, parameter = c(10,30,50,70,90,100,500,1000) and put all results of the MAE in a table.
data_CCard = read.table("/Users/credit_card_data.txt", stringsAsFactors = FALSE, header = FALSE)
data_CCard$V11 =as.factor(data_CCard$V11)
set.seed(188)
parameter = c(10,30,50,70,90,100,500,1000)
list= vector(mode="list")
MAE= vector(mode="list")
# Loop
for (i in seq_along (parameter)){
model_simple5 = cv.kknn(V11 ~.,
data = data_CCard,
kcv = parameter[i],
scale= TRUE)
list = c(list,parameter[i])
MAE = c(MAE, model_simple5[2])
}
col= cbind(list,MAE)
mode(col) = "numeric"
df= data.frame(col)
df
but when I run the code before displaying the final table this appears, and I have no clue why:
Error in apply(weightClass, 1, order, decreasing = TRUE)[1, ] : incorrect number of dimensions