+2 votes
in Programming Languages by (74.9k points)
I saved 2 CSR matrices on the disk in .npy format. For running the classifier, I need to merge the CSR matrices. How can I concatenate CSR2 to CSR1?

1 Answer

+1 vote
by (353k points)
selected by
 
Best answer

The sparse library has hstack and vstack for concatenating matrices horizontally and vertically respectively. Look at the following code for the reference.

from scipy import sparse

data1 = np.load('filename1.npy').tolist()

data2 = np.load('filename2.npy').tolist()

merged_data = sparse.vstack((data1,data2), format='csr')  #merge the data

The above code will generate the merged data in CSR format.


...