AttributeError: ‘RandomOverSampler’ object has no attribute ‘fit_sample’
报错代码
resample_ratio = 0.3 # (anomalies / normal) after resampling
sample_normal = tn + fp # total number of true normal points
sample_anomaly = int(resample_ratio*sample_normal) # must be an integer
sampling_dict = {0: sample_normal, 1: sample_anomaly}
ros = RandomOverSampler(sampling_dict, random_state=0)
features_resampled, label_resampled = ros.fit_sample(features,label)
报错信息
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-22-ffd748cd2c3f> in <module>
5 sampling_dict = {0: sample_normal, 1: sample_anomaly}
6 ros = RandomOverSampler(sampling_dict, random_state=0)
----> 7 features_resampled, label_resampled = ros.fit_sample(features,label)
AttributeError: 'RandomOverSampler' object has no attribute 'fit_sample'
解决办法
features_resampled, label_resampled = ros.fit_resample(features,label)
fit_resample