Section 4. Chapter 3
single
Challenge: Computing an SVD
Swipe to show menu
Task
Swipe to start coding
Singular Value Decomposition (SVD) is a matrix factorization technique used in recommendation systems to analyze and compress large, sparse user-item matrices. By factorizing a matrix A into three matrices U, Sigma, and V^T, SVD reveals hidden patterns and relationships. You can approximate the original matrix by keeping only the top k singular values and corresponding vectors, which captures the most significant information and reduces noise.
Your task is to implement a function compute_svd_recommendation that:
- Takes as input a user-item ratings matrix (2D numpy array) and an integer
k(number of latent factors); - Factorizes the matrix using SVD into (U), Sigma, and V^T;
- Constructs a rank-
kapproximation of the original matrix using only the topksingular values and vectors; - Returns the reconstructed matrix (as a numpy array) that can be used for making recommendations.
Solution
Everything was clear?
Thanks for your feedback!
Section 4. Chapter 3
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat