I was trying out the sparse representation of the arff file as shown here. In my program I am able to print the the class label “B” but for some reason it is not printing “A”.
attVals = new FastVector();
attVals.addElement("A");
attVals.addElement("B");
atts.addElement(new Attribute("class", attVals));
vals[index] = attVals.indexOf("A");
The output for the program is like –
{0 6,2 8} --- I should get {0 6,2 8,3 A}
But when I do
vals[index] = attVals.indexOf("B");
I get proper output –
{0 6,2 8,3 B}
For some reason it is not taking the index 0. Can someone tell me why this is happening?
This is a very popular problem. The Sparse format by definition does not store 0 values.
Weka ARFF format page clearly says that:
You have to put a dummy attribute in the first place. Just modify your code to:
Let me know if you need any further help.