This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |