Java Weka - 如何标准化单个实例

时间:2018-05-13 17:52:35

标签: java classification weka standardized

我需要实现一个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);
}

我该怎么办?或者我应该实现自己的标准化器?

0 个答案:

没有答案