I'm training a word2vec model on a corpus and then querying the model.
This works fine, but I am running an experiment and need to call the model for different conditions, save the model for each condition, query the model for each condition, and then save the output from the queries into a csv file, say, for further analyses of all the conditions.
I've studied the gensim documentation and searched around, but can't figure out what to do.
I asked the gensim folks and they said that since the result of "most_similar" is a python object I can save it with pickle or save as txt, csv, whatever format I want.
Sounds great, but I don't have a clue how to start. Here's my code - could you help me "fill in the blanks" even with something simple that I can research further and expand on my own?
#train the model
trained_model = gensim.models.Word2Vec(some hyperparamters)
#save the model in the format that is appropriate for querying by writing it to disk and call it stored_model
trained_model.save(some_filename)
#read in the stored model from disk and call it retrieved_model
retrieved_model = gensim.models.Word2Vec.load(some_filename)
#query the retrieved model
#each of these queries produces a tuple of 10 'word', cosine similarity pairs
retrieved_model.wv.most_similar(positive=['smartthings', 'amazon'], negative=['samsung'])
retrieved_model.wv.most_similar(positive=['light', 'nest'], negative=['hue'])
retrieved_model.wv.most_similar(positive=['shopping', 'new_york_times'], negative=['ebay'])
.
.
.
#store the results of all these queries in a csv so they can be analyzed.
?