R等比例抽样
library(caret)
#等比例抽样,按照物种分类的变量抽取10%的样本
splitindex <- createDataPartition(iris$Species,times = 1,p = 0.1,list = FALSE)
sample <- iris[splitindex,]
#亚变量处理
cor(iris[,1:4])
dmy <-dummyVars(~Species,data=iris)
result <- data.frame(predict(dmy,newdata = iris))
#Rattle
library(rattle)
rattle()
#等比例抽样,按照物种分类的变量抽取10%的样本
splitindex <- createDataPartition(iris$Species,times = 1,p = 0.1,list = FALSE)
sample <- iris[splitindex,]
#亚变量处理
cor(iris[,1:4])
dmy <-dummyVars(~Species,data=iris)
result <- data.frame(predict(dmy,newdata = iris))
#Rattle
library(rattle)
rattle()
评论
发表评论