liac-arff
liac-arff copied to clipboard
Issue- "BadLayout: Invalid layout of the ARFF file, at line ..."
Hello,
I tried to convert regular arff file format to sparse arff format through liac-arff. I used the code below:
import arff fp = open('est1.arff') data = arff.load(fp)
X = arff.dumps(data)
from scipy import sparse decoder = arff.ArffDecoder() d = decoder.decode(X, encode_nominal=True, return_type=arff.COO) data = d['data'][0] row = d['data'][1] col = d['data'][2] matrix = sparse.coo_matrix((data, (row, col)), shape=(max(row)+1, max(col)+1))
However, it did not work, and the comment in console was "BadLayout: Invalid layout of the ARFF file, at line ..."
I am not sure what the problem is. Would you please help me to solve this issue? Thank you.
I think you should have got a generator only if you pass in a return_type parameter.
Thank you for your comment. Where can I get a generator?
Sorry, I was responding to the first version of this issue which complained that the output of loading was a Generator.
If your data is not a sparse ARFF, attempting COO return type will raise a BadLayout. Instead, load it dense, then convert to sparse.