Compare commits

..

1 Commits

Author SHA1 Message Date
Aleksander Piotrowski
872a0a53b7 Add my solution 2021-04-22 06:53:29 +02:00
3 changed files with 10459 additions and 0 deletions

5272
dev-0/out.tsv Normal file

File diff suppressed because it is too large Load Diff

35
solution.py Normal file
View File

@ -0,0 +1,35 @@
import numpy as np
from sklearn import preprocessing
from sklearn.naive_bayes import MultinomialNB
from sklearn.pipeline import make_pipeline
from sklearn.feature_extraction.text import TfidfVectorizer
import lzma
le=preprocessing.LabelEncoder()
def open_file_xz(file: str):
with lzma.open(file, mode='rt') as f:
return f.readlines()
def open_file(file: str):
with open(file) as f:
return f.readlines()
def train_model(train_in, train_exp):
train_exp = le.fit_transform(train_exp)
pipeline = make_pipeline(TfidfVectorizer(),MultinomialNB())
model=pipeline.fit(train_in, train_exp)
return model
def make_prediction(catalog: str):
train_in = open_file_xz("train/in.tsv.xz")
train_exp = open_file("train/expected.tsv")
to_be_predict = open_file_xz(catalog + "/in.tsv.xz")
model = train_model(train_in,train_exp)
prediction=model.predict(to_be_predict)
np.savetxt(catalog + "/out.tsv", prediction, fmt='%d', delimiter='\n')
make_prediction("dev-0")
make_prediction("test-A")

5152
test-A/out.tsv Normal file

File diff suppressed because it is too large Load Diff