You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using SVMSMOTE the resampled data is not equal among the different classes when sampling_strategy is set to 'not majority' or when passing a dict of values.
Steps/Code to Reproduce
importnumpyasnpfromsklearn.svmimportSVCfromimblearn.over_samplingimportSVMSMOTEfromcollectionsimportCounter# create datax=np.random.normal(0, 0.5, 1000)
y=np.random.normal(0, 0.5, 1000)
clss=np.minimum(np.random.geometric(0.5, 1000), 7)
# check original class distributionCounter(clss)
num_majority=Counter(clss).get(1)
arr=np.array((x,y)).Tsvc=SVC(C=10, kernel='rbf', gamma='scale', class_weight='balanced', random_state=2024)
svc.fit(arr, clss)
not_majority=SVMSMOTE(sampling_strategy='not majority', k_neighbors=7, m_neighbors=14, svm_estimator=svc, out_step=0.25, random_state=2024)
# check resampled class distribution with 'not majority' sample_strategya, b=not_majority.fit_resample(arr, clss)
Counter(b)
sampling_strategy=sampling_strategy= {1:num_majority, 2:num_majority, 3:num_majority, 4:num_majority, 5:num_majority, 6:num_majority, 7:num_majority}
dict_strat=SVMSMOTE(sampling_strategy=sampling_strategy, k_neighbors=7, m_neighbors=14, svm_estimator=svc, out_step=0.25, random_state=2024)
# check resampled class distribution with dictionary sample_strategyc, d=dict_strat.fit_resample(arr, clss)
Counter(d)
Expected Results
I would expect the resampled classes to all have the same number of samples like below:
Describe the bug
When using SVMSMOTE the resampled data is not equal among the different classes when sampling_strategy is set to 'not majority' or when passing a dict of values.
Steps/Code to Reproduce
Expected Results
I would expect the resampled classes to all have the same number of samples like below:
Actual Results
But after resampling the minority classes have fewer samples than the majority class.
Versions
The text was updated successfully, but these errors were encountered: