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
Which SciPy module is commonly used for sparse matrix file input/output?
The
scipy.sparse module along with scipy.io is used to save and load sparse matrices efficiently.Click to reveal answer
intermediate
How do you save a sparse matrix to a file using SciPy?
Use
scipy.io.savemat to save a sparse matrix in MATLAB format or scipy.sparse.save_npz to save in compressed NumPy format.Click to reveal answer
intermediate
How do you load a sparse matrix saved in NPZ format?
Use
scipy.sparse.load_npz(filename) to load the sparse matrix back into memory.Click to reveal answer
beginner
Why is it better to use sparse matrix file formats instead of saving as dense arrays?
Saving sparse matrices in special formats keeps file size small and loading fast because it only stores non-zero values, unlike dense arrays which store all values including zeros.
Click to reveal answer
Which function saves a sparse matrix in compressed NPZ format?
✗ Incorrect
scipy.sparse.save_npz saves sparse matrices in compressed NPZ format, which is efficient for storage.
What does a sparse matrix mainly store to save space?
✗ Incorrect
Sparse matrices store only the non-zero values and their positions to save memory.
Which function loads a sparse matrix saved in NPZ format?
✗ Incorrect
scipy.sparse.load_npz loads sparse matrices saved in NPZ format.
What file format does
scipy.io.savemat save data in?✗ Incorrect
scipy.io.savemat saves data in MATLAB's .mat file format.
Why should you use sparse matrix file I/O methods instead of saving as dense arrays?
✗ Incorrect
Sparse matrix file I/O saves disk space and loads data faster by storing only non-zero values.
Explain how to save and load a sparse matrix using SciPy.
Think about the functions for saving and loading NPZ files.
You got /4 concepts.
Why is it important to use sparse matrix file I/O methods instead of saving as dense arrays?
Consider the difference in storage between sparse and dense matrices.
You got /4 concepts.