我正在我的学校做一个科学项目,我需要在我的数据流上使用几个过滤器。我正在使用MOA和WEKA的过滤器。以下代码是我制作的分类器的一部分,因此我可以使用带有MOA分类器的Filter。我知道MOA有WEKA分类器,我可以选择过滤分类器。但是,我自己创建,以确保分类器不测试合成实例。
@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));
}
}
基本上,只要达到窗口大小,就会应用过滤器。在mFilter.setInputFormat(mWekaInstances);
行和mWekaNewInstances = weka.filters.Filter.useFilter(mWekaInstances, mFilter);
然而,这些行给出了例外。可能是什么原因?