R語言DMwR包中的SMOTE函數中perc.over和perc.under的含義。

引文:幫助文檔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個

自己試試 吧

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章