使线性判别分析运行

时间:2018-02-13 13:24:14

标签: r

我试图让我的线性判别分析工作。我试图跑:

set.seed(2018)

n <- nrow(<dataset>)

shuffled <- <dataset>[sample(n),]

training <- shuffled[1:round(0.7 * n),]
testing<- shuffled[(round(0.7 * n) + 1):n,]

lda.fit=lda(y ~.,data = training)

summary(lda.fit)

lda.pred=predict(lda.fit,training)

lda.class=lda.pred$class

table(lda.class,testing)

mean(lda.class)

运行table-function时,出现错误:

"Error in table(lda.class, banktrain) : 
  all arguments must have the same length".

怎么办?

0 个答案:

没有答案