小嘟嘟问题吧
关注: 2 贴子: 10

  • 目录:
  • 其他
  • 0
    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
  • 2
    麦格津 2021-04
    麦格津 4-5
  • 0
    测试测试 #Bayes判别法 library(rio) dr <- import("drought.xlsx") library(klaR) dr$group<-as.factor(dr$group)#贝叶斯判别中表示分类的必须是因子型 str(dr) knb.model <- NaiveBayes(group~x1+x2,data =dr) #预测结果 knb_predict <- predict(knb.model,data = dr) #生成实际与预测交叉表和预测精度 knb.table <- table(actual=dr$group,predict=knb_predict$class) knb_ratio <- sum(diag(knb.table))/sum(knb.table) knb.table knb_ratio #根据运行结果,Bayes判别法正确率为100%
  • 0
    亲爱的各位吧友:欢迎来到小嘟嘟问题

  • 发贴红色标题
  • 显示红名
  • 签到六倍经验

赠送补签卡1张,获得[经验书购买权]

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!

本吧信息 查看详情>>

会员: 会员

目录: 其他