Question

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?

Was it helpful?

Solution

After loading data, just add the following statement:

sampler.setInputFormat(data);

OTHER TIPS

ArffLoader loader = new ArffLoader();
loader.setFile(new File("some.arff"));
Instances data= loader.getStructure();
// you missed this
sampler.setInputFormat(data);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top