문제

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?

도움이 되었습니까?

해결책

After loading data, just add the following statement:

sampler.setInputFormat(data);

다른 팁

ArffLoader loader = new ArffLoader();
loader.setFile(new File("some.arff"));
Instances data= loader.getStructure();
// you missed this
sampler.setInputFormat(data);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top