Learn Before
Concept

Creating Sparse Matrices

F = np.eye(3, k=1) #Create a 2X2 identity matrix

G = np.mat(np.identity(2)) #Create a 2x2 identity matrix

C[[C > 0.5]] = 0

H = sparse.csr_matrix(C) #Compressed Sparse Row matrix

I = sparse.csc_matrix(D) #Compressed Sparse Column matrix

J = sparse.dok_matrix(A) #Dictionary Of Keys matrix

E.todense() #Sparse matrix to full matrix

sparse.isspmatrix_csc(A) #Identify sparse matrix

0

1

Updated 2021-06-08

Tags

Python Programming Language

Data Science