简体   繁体   中英

imbalanced classification using undersampling and oversampling using pytorch python

I want to use oversampling and under sampling techniques together I have 6 classes with number of samples as following: class 0 250000 class 1 48000 class 2 40000 class 3 38000 class 4 35000 class 5 7000 I want to use smot to make all classes balance and equal same size class 0 40000 class 1 40000 class 2 40000 class 3 40000 class 4 40000 class 5 40000 I know how to make oversampling or undersampling for all data but how use them together with multi class classification

I Try this

ros = RandomUnderSampler()
X, y=ros.fit_resample(mydata, labels)
strategy = {0:40000, 1:40000, 2:40000, 3:40000, 4:40000, 5:40000}
over = SMOTE(sampling_strategy=strategy)
X, y=over.fit_resample(X, y)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM