3
$\begingroup$

I have read that the SMOTE package is implemented for binary classification. In the case of n classes, it creates additional examples for the smallest class. Can I balance all the classes by running the algorithm n-1 times?

$\endgroup$
1
$\begingroup$

Yes that is what SMOTE does, even if you do manually also you get the same result or if you run an algorithm to do that.

There are couple of other techniques which can be used for balancing multiclass feature. Attaching those 2 links for your reference.

Link 1

Link 2

Link 3 is having implementation of couple of oversampling techniques:

Link 3

ROSE also can be used for Oversampling.

Hope my answer is helpful. Do let me know of you have any additional questions.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Ok, but it's all about undersampling. I'm trying to find a solution to oversampling all minority classes. $\endgroup$ – atos Nov 13 '17 at 17:53
  • $\begingroup$ appended a new link in the answer as Link , most likely that would be helpful! $\endgroup$ – Toros91 Nov 14 '17 at 1:54
  • $\begingroup$ Did you try them and were they useful? $\endgroup$ – Toros91 Feb 1 '18 at 7:06
  • $\begingroup$ It turned out that SMOTE from Python by default uses oversampling of all minority classes. $\endgroup$ – atos Feb 2 '18 at 16:02
1
$\begingroup$


I am pretty sure that the SMOTE package in python can also be used for multi-class as well.
Just you can check its implementation for iris dataset-

http://contrib.scikit-learn.org/imbalanced-learn/stable/auto_examples/plot_ratio_usage.html
-Please correct me if I am wrong.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Well, first of all it's not about SMOTE. Secondly, I see there only methods for creating unbalanced collections from balanced and undersampling techniques. $\endgroup$ – atos Nov 12 '17 at 15:44
  • $\begingroup$ Is this not the correct link contrib.scikit-learn.org/imbalanced-learn/stable/generated/… $\endgroup$ – Keith Nov 20 '17 at 6:21
0
$\begingroup$

The SMOTE implementation provided by imbalanced-learn, in python, can also be used for multi-class problems.

Check out the following plots available in the docs:

enter image description here

enter image description here

Also, the following snippet:

from imblearn.over_sampling import SMOTE, ADASYN
X_resampled, y_resampled = SMOTE().fit_resample(X, y)
print(sorted(Counter(y_resampled).items()))
[(0, 4674), (1, 4674), (2, 4674)]

source: https://imbalanced-learn.readthedocs.io/en/stable/over_sampling.html#from-random-over-sampling-to-smote-and-adasyn

| improve this answer | |
New contributor
onofricamila is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.