Skip to content

Instantly share code, notes, and snippets.

@risenW
Created July 14, 2020 08:36
Show Gist options
  • Save risenW/bb359ae0b35cfbf5e6481e9b243efd02 to your computer and use it in GitHub Desktop.
Save risenW/bb359ae0b35cfbf5e6481e9b243efd02 to your computer and use it in GitHub Desktop.
b_id =list(ratings_df.book_id.unique())
b_id.remove(10000)
dict_map = {}
for i in b_id:
dict_map[i] = books_df_copy.iloc[i]['title']
out_v = open('vecs.tsv', 'w')
out_m = open('meta.tsv', 'w')
for i in b_id:
book = dict_map[i]
embeddings = book_em_weights[i]
out_m.write(book + "\n")
out_v.write('\t'.join([str(x) for x in embeddings]) + "\n")
out_v.close()
out_m.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment