I am trying to build classification model using Java Weka API. My training dataset have class imbalance problems. For this reason, I want to use SMOTE to reduce class imbalance problem. But, I do not know how to use it in Java Weka API.
Asked
Active
Viewed 782 times
1 Answers
8
Welcome to the community.
You can use the following code:
import weka.filters.supervised.instance.SMOTE;
import weka.core.Instances;
import weka.core.converters.ConverterUtils.DataSource;
import weka.filters.Filter;
Instances data = DataSource.read(".../file.arff"); //Dataset
SMOTE smote=new SMOTE(); //create object of SMOTE
smote.setInputFormat(data);
Instances data_smote = Filter.useFilter(data, smote); //Apply SMOTE on Dataset

Reja
- 898
- 1
- 9
- 21
-
Thanks for your support. I am trying to applying your code. – Sagor Ali Nov 06 '18 at 10:32
-
I am glad to hear that. – Reja Dec 04 '18 at 00:54