引文:帮助文档http://www.biostatistic.net/thread-34529-1-1.html
同样可以载入DMwR包之后,输入 ?SMOTE 查看相关帮助文档
perc.over = xx 表示 少样本变成原来的(1+xx/100)倍
perc.under=yy 表示多样本变成少样本的 yy/100 *(xx/100)倍
## data [#数据]
data(iris)
data <- iris[, c(1, 2, 5)]
data$Species <- factor(ifelse(data$Species == "setosa","rare","common"))
## checking the class distribution of this artificial data set[#检查类的分布,这种人工数据集]
table(data$Species)
## now using SMOTE to create a more "balanced problem"[#现在使用SMOTE的创建一个更加“平衡的问题”]
newData <- SMOTE(Species ~ ., data, perc.over = 600,perc.under=100)
table(newData$Species)
> table(data$Species)
common rare
100 50
>
> ## now using SMOTE to create a more "balanced problem"[#现在使用SMOTE的创建一个更加“平衡的问题”]
> newData <- SMOTE(Species ~ ., data, perc.over = 600,perc.under=100)
> table(newData$Species)
common rare
300 350
本文中,原始数据 多样本:少样本为 100:50
设置perc.over = 600,perc.under=100
即 少样本 变成原来的 1+600/100=7倍,计50*7=350个
多样本变为 少样本的 100/100*(600/100)=6倍,计50*6=300个
自己试试 吧