0
0
SciPydata~5 mins

Matrix creation and operations in SciPy - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a matrix in the context of data science?
A matrix is a rectangular grid of numbers arranged in rows and columns. It is used to organize data and perform mathematical operations like addition, multiplication, and finding determinants.
Click to reveal answer
beginner
How do you create a 3x3 matrix using SciPy?
You can create a 3x3 matrix using <code>scipy.sparse</code> or <code>numpy</code>. For example, with NumPy: <br><code>import numpy as np<br>matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])</code>
Click to reveal answer
intermediate
What is matrix multiplication and when is it used?
Matrix multiplication combines two matrices to produce a new matrix. It is used in data transformations, solving systems of equations, and machine learning algorithms.
Click to reveal answer
beginner
How can you find the transpose of a matrix in SciPy or NumPy?
The transpose flips a matrix over its diagonal. In NumPy, use matrix.T. In SciPy sparse matrices, use matrix.transpose().
Click to reveal answer
intermediate
What is the difference between dense and sparse matrices?
Dense matrices store all elements explicitly, even zeros. Sparse matrices store only non-zero elements to save memory and speed up calculations when many elements are zero.
Click to reveal answer
Which function creates a 2x2 identity matrix in NumPy?
Anp.eye(3)
Bnp.identity(2)
Cnp.ones((2,2))
Dnp.zeros((2,2))
What is the result of multiplying a 2x3 matrix by a 3x2 matrix?
AA 2x2 matrix
BA 3x3 matrix
CA 2x3 matrix
DAn error
Which method transposes a sparse matrix in SciPy?
Amatrix.transpose()
Bmatrix.T
Cmatrix.swap()
Dmatrix.flip()
Why use sparse matrices instead of dense matrices?
ATo make matrices denser
BTo increase matrix size
CTo avoid matrix multiplication
DTo save memory when many elements are zero
Which library is commonly used for matrix operations in Python?
ARequests
BPandas
CNumPy
DMatplotlib
Explain how to create and multiply two matrices using SciPy or NumPy.
Think about how rows and columns must match for multiplication.
You got /3 concepts.
    Describe the advantages of using sparse matrices in data science.
    Consider when many matrix elements are zero.
    You got /3 concepts.