liac-arff icon indicating copy to clipboard operation
liac-arff copied to clipboard

Issue- "BadLayout: Invalid layout of the ARFF file, at line ..."

Open j00n162 opened this issue 5 years ago • 3 comments

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.

j00n162 avatar Feb 07 '20 09:02 j00n162

I think you should have got a generator only if you pass in a return_type parameter.

jnothman avatar Feb 08 '20 11:02 jnothman

Thank you for your comment. Where can I get a generator?

j00n162 avatar Feb 08 '20 11:02 j00n162

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.

jnothman avatar Feb 08 '20 13:02 jnothman