Shape not the same after dumping to libsvm a numpy sparse matrix
I suspect your last two columns consist of only 0's. When loading an libsvm file, it generally doesn't have anything indicating the number of columns. It's a sparse format of col_num:val and will learn the maximum number of columns by the highest column number observed. If you only have 0's in the last two columns, they'll get dropped in this transformation.
I have numpy sparse matrix that I dump in a libsvm format. VC was created using CountVectorizer where the size of the vocabulary is 85731
vc
<1315689x85731 sparse matrix of type '<type 'numpy.int64'>'
    with 38911625 stored elements in Compressed Sparse Row format>
But when I load libsvm file back I see that the shape is different. Two columns are gone:
data[0]
<1315689x85729 sparse matrix of type '<type 'numpy.float64'>'
    with 38911625 stored elements in Compressed Sparse Row format>
I have no idea why this could be happening ? I also loaded the VC sparse matrix as dmatrix. Same issue 2 columns vanish.
Hope someone with more experience could point out the issue.
Thanks