Matrix factorization is often used in recommendation systems and dimensionality reduction. What is the primary goal when applying matrix factorization?
Think about how matrix factorization helps reveal hidden patterns or features.
The main goal of matrix factorization is to break down a large matrix into smaller matrices that represent latent (hidden) features. This helps in understanding underlying structures like user preferences or item characteristics.
Given matrices U and V below, what is the product U x V?
import numpy as np U = np.array([[1, 2], [3, 4]]) V = np.array([[2, 0], [1, 3]]) result = U @ V print(result)
Recall how matrix multiplication works: multiply rows of U by columns of V and sum.
Multiplying U and V: first row of U (1,2) times first column of V (2,1) = 1*2 + 2*1 = 4; similarly for other elements.
In matrix factorization, the rank k controls the number of latent features. What is a common effect of choosing a very large k?
Think about what happens when a model is too complex for the data.
A very large rank means many latent features, which can cause the model to memorize training data (overfit) and not generalize well to new data.
After training a matrix factorization model, you calculate the Root Mean Squared Error (RMSE) on test data. What does a lower RMSE indicate?
RMSE measures the average difference between predicted and actual values.
A lower RMSE means the predictions are closer to the true values, showing the model fits the data better.
What error will this Python code raise when performing matrix factorization using numpy?
import numpy as np R = np.array([[5, 3], [4, 0], [1, 1]]) U = np.random.rand(3, 2) V = np.random.rand(2, 3) P = U @ V print(P)
Check the shapes of matrices U and V before multiplication.
Matrix multiplication requires the inner dimensions to match. Here, U is (3,2) and V is (2,3), so multiplication U @ V is valid and results in a (3,3) matrix.