This commit is contained in:
Mikołaj Pokrywka 2022-04-23 20:16:10 +02:00
parent b775a221e6
commit abbad42ecd
2 changed files with 134659 additions and 0 deletions

41
run.py Normal file
View File

@ -0,0 +1,41 @@
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression
import lzma
if __name__ == "__main__":
X = []
Y = []
with lzma.open('train/in.tsv.xz', 'r') as file:
for line in file:
line = line.strip()
X.append(line.decode("utf-8"))
print("step 1")
with open('train/expected.tsv', 'r') as file:
for line in file:
line = line.strip()
Y.append(int(line))
print("step 2")
vectorizer = TfidfVectorizer()
X = vectorizer.fit_transform(X)
print("step 3")
model = LogisticRegression()
model.fit(X, Y)
print("step 4")
X_dev = []
Y_dev = []
with open('test-A/in.tsv', 'r') as file:
for line in file:
line = line.strip()
X_dev.append(line)
print("step 5")
X_dev = vectorizer.transform(X_dev)
prediction = model.predict(X_dev)
print("step 6")
f = open("test-A/out.tsv", "a")
for p in prediction:
f.write(str(p) + '\n')
f.close()

134618
test-A/out.tsv Normal file

File diff suppressed because it is too large Load Diff