0
0
SciPydata~5 mins

Creating sparse matrices in SciPy - Quick Revision & Summary

Choose your learning style9 modes available
Recall & Review
beginner
What is a sparse matrix?
A sparse matrix is a matrix mostly filled with zeros. It saves memory by only storing the non-zero values and their positions.
Click to reveal answer
beginner
Name two common formats for sparse matrices in SciPy.
Two common formats are CSR (Compressed Sparse Row) and COO (Coordinate list). CSR is good for fast row slicing, COO is easy to create.
Click to reveal answer
beginner
How do you create a COO sparse matrix in SciPy?
Use scipy.sparse.coo_matrix with three arrays: data (values), row indices, and column indices.
Click to reveal answer
beginner
Why use sparse matrices instead of regular dense matrices?
Sparse matrices save memory and speed up calculations when most values are zero, like in large graphs or text data.
Click to reveal answer
intermediate
What function creates a CSR sparse matrix from dense data?
Use scipy.sparse.csr_matrix with a dense matrix or arrays. It converts dense data into compressed sparse row format.
Click to reveal answer
Which SciPy function creates a sparse matrix from data, row, and column arrays?
Ascipy.sparse.dense_matrix
Bscipy.sparse.coo_matrix
Cscipy.sparse.array_matrix
Dscipy.sparse.full_matrix
What is the main benefit of using sparse matrices?
AThey use less memory for mostly zero data
BThey are easier to read
CThey always run faster than dense matrices
DThey store all values including zeros
Which sparse matrix format is best for fast row slicing?
ACOO
BLIL
CCSR
DDOK
How do you convert a dense matrix to a CSR sparse matrix?
AUse csr_matrix with the dense matrix as input
BUse coo_matrix with zeros
CUse dense_matrix function
DUse toarray() method
Which of these is NOT a sparse matrix format in SciPy?
ACOO
BCSR
CDOK
DXYZ
Explain how to create a sparse matrix using the COO format in SciPy.
Think about what information you need to specify the non-zero values and their positions.
You got /4 concepts.
    Describe why sparse matrices are useful and when you would use them.
    Consider situations with many zeros in data.
    You got /4 concepts.