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.
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
$\begingroup$ Thanks for your support. I am trying to applying your code. $\endgroup$ Nov 6, 2018 at 10:32
$\begingroup$ I am glad to hear that. $\endgroup$– RejaDec 4, 2018 at 0:54