I am doing a science project on my school, and I need to use several filters on my data stream. I am using MOA with filters from WEKA. The following code is part of a classifier I made so I could use the Filter with a MOA classifier. I am ware that MOA has the WEKA classifier, where I can choose filtered classifier. However I making my own, to make sure the classifier is not testing the synthetic instances.
@Override
public void trainOnInstanceImpl(Instance instnc) {
Instance aux;
Instances moaNewInstances;
weka.core.Instances mWekaInstances, mWekaNewInstances;
mWekaInstances = new weka.core.Instances("WekaInstances", mAttFastVector, windownSize);
mWekaNewInstances = new weka.core.Instances("WekaNewInstances", mAttFastVector, windownSize);
moaNewInstances = new Instances("moaNewInstances",mAttList, windownSize);
if(IsFirst)
{
getAttributes(instnc);
moaInstances = new Instances("moaInstances",mAttList, windownSize);
IsFirst= false;
}
if(cont < windownSize)
{
moaInstances.add(instnc);
cont++;
}
else
{
cont = 0;
mWekaInstances = converterToWeka.wekaInstances(moaInstances);
mFilter.setInputFormat(mWekaInstances);
mWekaNewInstances = weka.filters.Filter.useFilter(mWekaInstances, mFilter);
moaNewInstances = converterToMoa.samoaInstances(mWekaNewInstances);
moaInstances.delete();
for(int i = 0; i < moaNewInstances.size(); i++)
mLearner.trainOnInstance(moaNewInstances.get(i));
}
}
Basically the filter will be applied whenever the size of the window is reached. in the lines mFilter.setInputFormat(mWekaInstances);
and mWekaNewInstances = weka.filters.Filter.useFilter(mWekaInstances, mFilter);
However those lines gives an Exception. What could be the reason?