This commit is contained in:
Jan Przybylski 2021-04-13 11:34:07 +02:00
parent 5b9ea9d23b
commit dd5ffc0149
2 changed files with 16 additions and 0 deletions

16
prog-dev0.py Normal file
View File

@ -0,0 +1,16 @@
from sklearn.feature_extraction.text import TfidfVectorizer
import numpy as np
import sklearn.metrics
from sklearn.cluster import KMeans
with open("dev-0/in.tsv") as f:
content = f.readlines()
vectorizer = TfidfVectorizer(ngram_range=(1,2), use_idf = False)
vectorizer = TfidfVectorizer()
document_vectors = vectorizer.fit_transform(content)
kmeans = KMeans(n_clusters=77, random_state=0).fit(document_vectors)
pred_y = kmeans.fit_predict(document_vectors)
t=kmeans.labels_
t=np.array2string(t, precision=2, separator='\n',suppress_small=True)
f = open("dev-0/out.tsv", "a")
f.write(t)