iit-cs579 / main

CS579: Online Social Network Analysis at the Illinois Institute of Technology
147 stars 204 forks source link

constructing csr_matrix #471

Closed aronwc closed 5 years ago

aronwc commented 5 years ago

Please note that you should be using one of these two constructors to build your csr matrix:

csr_matrix((data, (row_ind, col_ind)), [shape=(M, N)])
where data, row_ind and col_ind satisfy the relationship a[row_ind[k], col_ind[k]] = data[k].

csr_matrix((data, indices, indptr), [shape=(M, N)])
is the standard CSR representation where the column indices for row i are stored in indices[indptr[i]:indptr[i+1]] and their corresponding values are stored in data[indptr[i]:indptr[i+1]]. If the shape parameter is not supplied, the matrix dimensions are inferred from the index arrays.

https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html

vjstark commented 5 years ago

csr_matrix((3, 4), dtype=np.int8).toarray() gives array([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], dtype=int8)

However, changing dtype to int64 does not return any dtype in the result. It simply gives array([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])

aronwc commented 5 years ago

I wouldn't worry about the dtype matching; there may be some configuration difference. The matrix should contain ints.