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.ArrayIndexOutOfBoundsException: -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.