What is Class Index in WEKA?

GiriB picture GiriB · Nov 4, 2014 · Viewed 11.8k times · Source

I have to use WEKA in my java code for prediction. Basically I have to study a given code and reuse it.

testdata.setClassIndex(data.numAttributes() - 1);

I am unable to understand what the above line means. What is a Class Index?

testdata and data are Intances object.

Answer

Matthew Spencer picture Matthew Spencer · Nov 5, 2014

As outlined here, setClassIndex is used to define the attribute that will represent the class (for prediction purposes). Given that the index starts at zero, data.numAttributes() - 1 represents the last attribute of the testdata set.

Hope this Helps!