Skip to content

Instantly share code, notes, and snippets.

View TheEdoardo93's full-sized avatar

TheEdoardo93 TheEdoardo93

View GitHub Profile
def probabilistic_matrix_factorization_technique(ratings_matrix):
random_state = RandomState(0) # generates a casual number given by the Mersenne Twister pseudo-random number generator
number_of_users = max(ratings_matrix[:, 0]) # max value in the first column (e.g., users)
number_of_items = max(ratings_matrix[:, 1]) # max value in the second column (e.g., items)
# Shift user_id and item_id by 1, in order to let user_id and item_id start from 0
ratings_matrix[:, (0, 1)] -= 1
# Delete all the rows in the ratings matrix which have 0 as rating value
final_ratings_matrix = delete_all_rows_in_the_ratings_matrix_which_have_0_as_rating_value(ratings_matrix)