# Visualise given word embeddings
# words is a list of words
# data is the vector representation of each word
# Train the algorithm
from sklearn.manifold import TSNE
vis_algo = TSNE(random_state=0, verbose=10, init='pca', n_iter=200)
vis = vis_algo.fit_transform(data)
# Plot the resulting visualisation
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(50, 50))
ax.scatter(vis[:, 0], vis[:, 1])
for i, w in enumerate(words):
ax.annotate(w, (vis[i, 0], vis[i, 1]))
plt.savefig('/path/to/visualisation.eps')
plt.show()