Complete the code to save a sparse matrix to a file using scipy.
from scipy import sparse matrix = sparse.csr_matrix([[0, 0, 1], [1, 0, 0]]) sparse.[1]('matrix.npz', matrix)
The save_npz function saves a sparse matrix to a file in .npz format.
Complete the code to load a sparse matrix from a file using scipy.
from scipy import sparse loaded_matrix = sparse.[1]('matrix.npz')
The load_npz function loads a sparse matrix from a .npz file.
Fix the error in the code to correctly save a sparse matrix to a file.
from scipy import sparse matrix = sparse.csr_matrix([[1, 0], [0, 1]]) sparse.save_npz('data.npz', [1])
The save_npz function requires a sparse matrix, not a dense array or data attribute.
Fill both blanks to save and then load a sparse matrix correctly.
from scipy import sparse matrix = sparse.csr_matrix([[0, 2], [3, 0]]) sparse.[1]('file.npz', matrix) loaded = sparse.[2]('file.npz')
Use save_npz to save and load_npz to load sparse matrices.
Fill all three blanks to create, save, and load a sparse matrix, then convert it to dense.
from scipy import sparse matrix = sparse.[1]([[1, 0], [0, 1]]) sparse.[2]('matrix.npz', matrix) loaded = sparse.[3]('matrix.npz') dense = loaded.toarray()
Create the sparse matrix with csr_matrix, save with save_npz, and load with load_npz.
