Last active
March 31, 2021 06:22
-
-
Save a-agmon/bb032ac769435f653c61d1588f541cbf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# a dictionary consisting of K:user and V:mean of the user's items | |
user_means = {} | |
for user in list(text_parts.keys()): | |
# get a list of artists the user listens to | |
# (but only if we have a vec for it) | |
artists = [artist for artist in text_parts[user] if model.wv.has_index_for(artist)] | |
if len(artists) == 0: | |
continue | |
# take the mean of all the vectors corresponding | |
# to the artists the users listened to | |
artists_mean = np.mean(model.wv[artists], axis=0) | |
# for each user store the mean of the artists they listen to | |
user_means[user] = artists_mean | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment