1

我想将实例重新采样到统一的类分布。为此,我使用以下代码。

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);

但得到以下错误:

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)

有没有人知道这里发生了什么,我怎样才能让它工作?

4

2 回答 2

3
ArffLoader loader = new ArffLoader();
loader.setFile(new File("some.arff"));
Instances data= loader.getStructure();
// you missed this
sampler.setInputFormat(data);
于 2011-04-21T18:13:05.363 回答
3

加载数据后,只需添加以下语句:

sampler.setInputFormat(data);
于 2012-06-29T10:41:00.247 回答