Reputation: 29
I want to re-sample the instances to uniform class distribution. For this, I am using the following code.
import weka.core.Instances;
import weka.filters.supervised.instance.*;
...
String Fliteroptions="-B 1.0";
sampler.setOptions(weka.core.Utils.splitOptions(Fliteroptions));
sampler.setRandomSeed((int)System.currentTimeMillis());
data = // ... Instances leaded from ARFF file ...
data = Resample.useFilter(data, sampler);
But getting the following error:
Zero Weights processed. Default weights will be used
java.lang.IllegalStateException: No input instance format defined
at weka.filters.supervised.instance.Resample.input(Resample.java:443)
at weka.filters.Filter.useFilter(Filter.java:655)
at WekaClassify.main(WekaClassify.java:84)
Do anybody has any clue what is going on here and how can I get it work?
Upvotes: 1
Views: 5372
Reputation: 56
After loading data, just add the following statement:
sampler.setInputFormat(data);
Upvotes: 3
Reputation: 31
ArffLoader loader = new ArffLoader();
loader.setFile(new File("some.arff"));
Instances data= loader.getStructure();
// you missed this
sampler.setInputFormat(data);
Upvotes: 3