我试图让我的线性判别分析工作。我试图跑:
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".
怎么办?