def visualize_words(self, words_fname, palette="Viridis256"): words = set() for line in open(words_fname, 'r'): if not line.startswith("#"): for word in line.strip().split(" "): words.add(word) vecs = np.array([self.get_sentence_vector(word) for word in words]) visualize_words(words, vecs, palette)
def visualize_movies(self, n_sample=30, palette="Viridis256", type="between"): movie_ids = self.get_titles_in_corpus(n_sample=n_sample) movie_titles = [movie_ids[key] for key in movie_ids.keys()] movie_vecs = [ self.model.docvecs[self.doc2idx[movie_id]] for movie_id in movie_ids.keys() ] if type == "between": visualize_between_words(movie_titles, movie_vecs, palette) else: visualize_words(movie_titles, movie_vecs, palette)
def my_visualize_words(self, words_set, palette="Viridis256"): words = words_set vecs = np.array([self.get_sentence_vector(word) for word in words]) visualize_words(words, vecs, palette, "./words.png")