This notebook introduces the da.linalg.svd
algorithms for the Singular Value Decomposition
Starting the Dask Client is optional. It will provide a dashboard which is useful to gain insight on the computation.
The link to the dashboard will become visible when you create the client below. We recommend having it open on one side of your screen while using your notebook on the other side. This can take some effort to arrange your windows, but seeing them both at the same is very useful when learning.
from dask.distributed import Client, progress
client = Client(processes=False, threads_per_worker=4,
n_workers=1, memory_limit='2GB')
client
For many applications the provided matrix has many more rows than columns. In this case a specialized algorithm can be used.
import dask.array as da
X = da.random.random((200000, 100), chunks=(10000, 100)).persist()
import dask
u, s, v = da.linalg.svd(X)
dask.visualize(u, s, v)
v.compute()
When there are also many chunks in columns then we use an approximate randomized algorithm to collect only a few of the singular values and vectors.
import dask.array as da
X = da.random.random((10000, 10000), chunks=(2000, 2000)).persist()
import dask
u, s, v = da.linalg.svd_compressed(X, k=5)
dask.visualize(u, s, v)
v.compute()