Recall & Review
beginner
What is a sparse matrix?
A sparse matrix is a matrix mostly filled with zeros. It saves memory by storing only the non-zero values and their positions.
Click to reveal answer
beginner
Name two common formats for storing sparse matrices in SciPy.
Two common formats are CSR (Compressed Sparse Row) and CSC (Compressed Sparse Column). They store data efficiently for different operations.
Click to reveal answer
beginner
How do you convert a dense NumPy array to a sparse CSR matrix in SciPy?
Use `scipy.sparse.csr_matrix(your_dense_array)` to convert a dense array to a CSR sparse matrix.
Click to reveal answer
intermediate
What is the advantage of using sparse matrix multiplication over dense matrix multiplication?
Sparse matrix multiplication is faster and uses less memory because it only processes non-zero elements, unlike dense multiplication which processes all elements.
Click to reveal answer
beginner
How can you find the number of non-zero elements in a sparse matrix?
Use the `.nnz` attribute of a sparse matrix to get the count of non-zero elements.
Click to reveal answer
Which SciPy sparse matrix format is best for fast row slicing?
✗ Incorrect
CSR format is optimized for fast row slicing and matrix-vector products.
What does the `.tocsc()` method do on a sparse matrix?
✗ Incorrect
The `.tocsc()` method converts a sparse matrix to Compressed Sparse Column format.
How do you create a sparse identity matrix of size 4x4 in SciPy?
✗ Incorrect
All these methods create a sparse identity matrix in SciPy.
Which attribute gives the number of non-zero elements in a sparse matrix?
✗ Incorrect
The `.nnz` attribute returns the count of non-zero elements.
Why use sparse matrices instead of dense matrices?
✗ Incorrect
Sparse matrices save memory and speed up calculations when most elements are zero.
Explain what a sparse matrix is and why it is useful in data science.
Think about storing mostly zeros efficiently.
You got /3 concepts.
Describe how to convert a dense matrix to a sparse matrix and perform multiplication using SciPy.
Use SciPy functions and explain benefits.
You got /3 concepts.