我正在尝试使用SMOTE来处理二进制分类中的不平衡类数据,我所知道的是:例如,如果我们使用
sm = SMOTE(ratio = 1.0, random_state=10)
Before OverSampling, counts of label '1': [78]
Before OverSampling, counts of label '0': [6266]
After OverSampling, counts of label '1': 6266
After OverSampling, counts of label '0': 6266对于1级是少数的情况,它将产生50:50的0级和1级的数量。
和
sm = SMOTE(ratio = 0.5, random_state=10)
Before OverSampling, counts of label '1': [78]
Before OverSampling, counts of label '0': [6266]
After OverSampling, counts of label '1': 3133
After OverSampling, counts of label '0': 6266将导致类1的大小减半到0级。
我的问题是:
我们如何将比率设置为获得比0类更多的1级,例如75:25?
发布于 2020-03-06 21:19:44
试着用字典。
smote_on_1 = 18798
#(In your case 18798 is thrice of 6266)
smt = SMOTE(sampling_strategy={1: smote_on_1})
X_train, y_train = smt.fit_sample(X_train, y_train)发布于 2019-09-08 07:32:38
从文档来看,ratio看起来可以是一个大于1的浮点数--也就是说,对于75:25的比率,您可以设置ratio=3。
试试看这是否有效。
https://stackoverflow.com/questions/57839023
复制相似问题