我需要实现一个Weka分类器,它在处理之前对输入数据进行标准化处理。我使用以下代码:
private Filter standardize = new Standardize();
...
public void buildClassifier(Instances instances) throws Exception {
if (this.stdAtt) {
this.standardize.setInputFormat(instances);
instances = Filter.useFilter(instances, this.standardize);
}
....
}
现在,为了对单个实例进行分类,我还需要在使用相同的Standardize
过滤器进行实际分类之前对其进行标准化。但Filter.useFilter
仅接受Instances
作为参数 - 而不是Instance
。
public double classifyInstance(Instance instance) throws Exception {
if (this.stdAtt) {
// standardize instance before processing
}
return super.classifyInstance(instance);
}
我该怎么办?或者我应该实现自己的标准化器?