from sklearn.manifold import MDS from sklearn.decomposition import PCA from sklearn.manifold import TSNE import urllib.request from gensim.models import Word2Vec sonad=urllib.request.urlopen("https://minitorn.tlu.ee/~jaagup/oma/too/23/05/word2vec/sonaindeksid.txt").read().decode("utf-8").split("\n") sonad=[rida.split()[0] for rida in sonad if rida] print("sinad") mudel=Word2Vec.load("https://minitorn.tlu.ee/~jaagup/oma/too/23/05/word2vec/lemmad1.model") print("loetud") kohad2=PCA(n_components=5).fit_transform(mudel.wv.get_normed_vectors()) print(kohad2) #kohad3=MDS().fit_transform(kohad2) kohad3=TSNE().fit_transform(kohad2) print(kohad3) vastus=[rida[0]+","+str(rida[1][0])+","+str(rida[1][1]) for rida in zip(sonad, kohad3)] f2=open("paigutus1.txt", "w", encoding="utf-8") print("\n".join(vastus), file=f2) f2.close()