I need to implement a Weka classifier that standaridizes the input data before processing. I use the following code for this:
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);
}
....
}
Now, to classify a single Instance, I also need to standardize it before actually classifying using the same Standardize
filter. But Filter.useFilter
only accepts Instances
as an argument - and not an Instance
.
public double classifyInstance(Instance instance) throws Exception {
if (this.stdAtt) {
// standardize instance before processing
}
return super.classifyInstance(instance);
}
How can I do it? Or should I implement my own standardizer?