It is common to use SVD for recommendation systems. Let’s say that we have a data frame called user_ratings that can be the score of each user to each movie.
from scipy.sparse.linalg import svds import numpy as np # Decompose the matrix U, sigma, Vt = svds(user_ratings_centered, k=6) # Convert sigma into a diagonal matrix sigma = np.diag(sigma) # U x Sigma U_x_Sigma = np.dot(U, sigma) # (U x Sigma) x Vt U_Sigma_Vt = np.dot(U_x_Sigma , Vt)
The U_Sigma_Vt is the product of the three decomposed matrices