train_matrix = rating_matrix.copy() | |
test_matrix = np.zeros(ratings_matrix.shape) | |
for i in xrange(rating_matrix.shape[0]): | |
rating_idx = np.random.choice( | |
rating_matrix[i, :].nonzero()[0], | |
size=10, | |
replace=True) | |
train_matrix[i, rating_idx] = 0.0 | |
test_matrix[i, rating_idx] = rating_matrix[i, rating_idx] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment