Skip to content
Justice Tech School

Singular Value Decomposition

SVD splits a matrix into U, S and Vt. It is used for compression, recommendation and noise removal.

Example
import numpy as np
a = np.array([[3, 0], [0, 4]])
u, s, vt = np.linalg.svd(a)
print(s)
print(np.allclose(u @ np.diag(s) @ vt, a))

Result

[4. 3.]
True

Exercise

Compute the decomposition.

np.linalg.(a)

Quiz Test

What can SVD be used for?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.