Skip to content

Instantly share code, notes, and snippets.

@Wann-Jiun
Last active January 20, 2017 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wann-Jiun/d91f7ccbd20659e9725052a9ac5aed10 to your computer and use it in GitHub Desktop.
Save Wann-Jiun/d91f7ccbd20659e9725052a9ac5aed10 to your computer and use it in GitHub Desktop.
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