library(rio) library(MASS) library(ggplot2) vege <- import("vege_soil.csv") head(vege) view(vege) library(MASS) vege$classification <- as.factor(vege$classification) vege[1:9] <- scale(vege[1:9])#标准化 result1 <- 0 for(i in 1:100) { ind <- sample(x = 1:1000, size = 700) m <- lda(classification ~., data = vege) ##Fisher判别100% pre <- predict(m, vege[-ind, -10])$class result1[i] <- sum(pre == vege[-ind, 10])/length(pre) } result1 mean(result1) #决策树92% m <- rpart(formula = classification~., data = vege, method = "class") result2 <- 0