the modified dataframe is shown in figure - figure - dataset with implicit feedback the next transformation of data that is required is to convert our dataframe into numpy matrix in the format of utility matrix we will convert our dataframe into sparse matrixas we will have lot of missing values and sparse matrices are suitable for representation of such matrix since we won' be able to transform our song ids and user ids into numpy matrixwe will convert these indices into numerical indices then we will use these transformed indices to create our sparse numpy matrix the following code will create such matrix in [ ]from scipy sparse import coo_matrix small_set triplet_dataset_sub_song_merged user_codes small_set user drop_duplicates(reset_index(song_codes small_set song drop_duplicates(reset_index(user_codes rename(columns={'index':'user_index'}inplace=truesong_codes rename(columns={'index':'song_index'}inplace=truesong_codes['so_index_value'list(song_codes indexuser_codes['us_index_value'list(user_codes indexsmall_set pd merge(small_set,song_codes,how='left'small_set pd merge(small_set,user_codes,how='left'mat_candidate small_set[['us_index_value','so_index_value','fractional_play_count']data_array mat_candidate fractional_play_count values row_array mat_candidate us_index_value values col_array mat_candidate so_index_value values data_sparse coo_matrix((data_array(row_arraycol_array)),dtype=floatin [ ]data_sparse out with stored elements in coordinate formatonce we have converted our matrix into sparse matrixwe will use the svds function provided by the scipy library to break down our utility matrix into three different matrices we can specify the number of latent factors we want to factorize our data in the example we will use latent factors but users are encouraged to experiment with different values of latent factors and observe how the recommendation change as result the following code creates the decomposition of our matrix and predicts the recommendation for the same user as in the item similarity recommendation use case we leverage our compute_svdfunction to perform the svd operation and then use the compute_estimated_matrixfor the low rank matrix approximation after factorization detailed steps with function implementations as always are present in the jupyter notebook