开发者

problem in using weka.core.instance in java

i have a trained j48 classifier and i want to classify one record by it. so i decided to use weka.core.instance object and classify it by command : "classifyInstance(record)"/ but i have a problem in at first step: creating instance. when i want to set the values of attributes i get exception : Exception in thread "main" java.lang.ArrayIndexOutOfBoundsExcept开发者_Python百科ion: -1 i have 24 attribute which first of them is string and others are int. so i use the code below:

    Instance record = new Instance(data.size());
    for(int i=1; i<data.size(); i++) 
    record.setValue(new Attribute(featuers[i]), Integer.parseInt(data.get(i)));

data is a arrayList which contains the value of attribute and featuers is a String Array that contains name of attributes.

thanks alot.


for String or nominal attributes, first we should add the value of string attribute to dataset and then try to setValue for instance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜