we can also try to explain the concept of matrix factorization as an image based on figure - we can regenerate the original matrix by multiplying the two matrices together to make recommendation to the userwe can multiply the corresponding user' row from the first matrix by the item matrix and determine the items from the row with maximum ratings that will become our recommendations for the user the first matrix represents the association between the users and the latent featureswhile the second matrix takes care of the associations between items (songs in our caseand the latent features figure - depicts typical matrix factorization operation for movie recommender system but the intent is to understand the methodology and extend it to build music recommendation system in this scenario matrix factorization and singular value decomposition there are multiple algorithms available for determining factorization of any matrix we use one of the simplest algorithmswhich is the singular value decomposition or svd remember that we discussed the mathematics behind svd in herewe explain how the decomposition provided by svd can be used as matrix factorization you may remember from that singular value decomposition of matrix returns three different matricesusand you can follow these steps to determine the factorization of matrix using the output of svd function factorize the matrix to obtain usand matrices reduce the matrix to first components (the function we are using will only provide dimensionsso we can skip this step compute the square root of reduced matrix sk to obtain the matrix sk / compute the two resultant matrix *sk / and sk / * as these will serve as our two factorized matricesas depicted in figure - we can then generate the prediction of user for product by taking the dot product of the ith row of the first matrix with the jth column of the second matrix this information gives us all the knowledge required to build matrix factorization based recommendation engine for our data building matrix factorization based recommendation engine after the discussion of the mechanics of matrix factorization based recommendation engineslet' try to create such recommendation engine on our data the first thing that we notice is that we have no concept of "ratingin our dataall we have are the play counts of various songs this is well known problem in the case of recommendation engines and is called the "implicit feedbackproblem there are many ways to solve this problem but we will look at very simple and intuitive solution we will replace the play count with fractional play count the logic being that this will measure the strength of "likenessfor song in the range of [ , we can argue about better methods to address this problembut this is an acceptable solution to our problem the following code will complete the task in [ ]triplet_dataset_sub_song_merged_sum_df triplet_dataset_sub_song_merged[['user','listen_ count']groupby('user'sum(rese t_index(triplet_dataset_sub_song_merged_sum_df rename(columns={'listen_count':'total_listen_ count'},inplace=truetriplet_dataset_sub_song_merged pd merge(triplet_dataset_sub_song_merged,triplet_dataset_ sub_song_merged_sum_dftriplet_dataset_sub_song_merged['fractional_play_count'triplet_dataset_sub_song_ merged['listen_count']/triplet_dataset_s ub_song_merged['total_listen_count'