implicit icon indicating copy to clipboard operation
implicit copied to clipboard

question about plays csr_matrix in Lastfm data

Open nicolaneo opened this issue 6 years ago • 1 comments

In the get_lastfm() function in lastfm.py, there are these lines: with h5py.File(filename, 'r') as f: m = f.get('artist_user_plays') plays = csr_matrix((m.get('data'), m.get('indices'), m.get('indptr'))) return np.array(f['artist']), np.array(f['user']), plays

The shape of the plays csr matrix is (number of artists x number of users), but printing the first few lines as examples outputs:

(0, 73470) 32.0 (0, 97856) 24.0 (0, 235382) 1339.0 (0, 266072) 211.0 (1, 171865) 23.0 (2, 180892) 70.0 (3, 285031) 23.0 (4, 15103) 9.0

I just wanted to check I was interpreting this right - does the first element of the tuple indicate the artist, and the second tuple element indicate the user, and then the following float is the number of plays, i.e. the number of times this user listened to this artist? So are the elements of the tuple indices which point to the artist and user arrays, respectively, so (index of artist array, index of user array)?

nicolaneo avatar Aug 10 '20 08:08 nicolaneo

the get_lastfm method returns 3 items: an array of artist, an array of user, and a sparse matrix of artist/user/playcount.

The artist array maps to the rowid in the sparse matrix (so the artist name at position 0 in the array artist array corresponds to the row 0 of the plays sparse matrix).

hope this helps!

benfred avatar Aug 20 '20 18:08 benfred