0

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

blackjacc
  • 1
  • 1
  • [See here](https://stackoverflow.com/q/5963269/5325862) on making a reproducible example that is easier for folks to help with. We don't have your data, so we can't run your code, you haven't mentioned what packages you're using (like what's `cv.kknn`?), and it's unclear what the issue actually is or what you've done so far to debug this – camille Sep 03 '21 at 23:33
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 04 '21 at 00:56

0 Answers0