This commit is contained in:
Adam Wojdyla 2022-05-10 23:56:45 +02:00
parent 756ef4277a
commit 2194c77c4b
11 changed files with 594885 additions and 1 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
.idea/*
*~
*.swp
*.bak

5272
dev-0/in.tsv Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

5272
dev-0/out.tsv Normal file

File diff suppressed because it is too large Load Diff

BIN
geval Executable file

Binary file not shown.

30
run.py Normal file
View File

@ -0,0 +1,30 @@
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.naive_bayes import MultinomialNB
with open('train/in.tsv', 'r', encoding='utf-8') as f:
x_train = pd.DataFrame([line.strip().split('\t') for line in f.readlines()], columns=['text', 'text_id'])
with open('dev-0/in.tsv', 'r', encoding='utf-8') as f:
x_dev = pd.DataFrame([line.strip().split('\t') for line in f.readlines()], columns=['text', 'text_id'])
with open('train/in.tsv', 'r', encoding='utf-8') as f:
x_test = pd.DataFrame([line.strip().split('\t') for line in f.readlines()], columns=['text', 'text_id'])
y_train = pd.read_csv('train/expected.tsv', sep='\t', names=['paranormal'], encoding='utf-8')
tfidf_vectorizer = TfidfVectorizer(max_df=0.95, max_features=500)
x_train_vectorized = tfidf_vectorizer.fit_transform(x_train['text'].values)
mnb_model = MultinomialNB().fit(x_train_vectorized, y_train.values.ravel())
# Dev data
x_dev_prepared = tfidf_vectorizer.transform(x_dev['text'].values)
predictions = mnb_model.predict(x_dev_prepared)
with open('dev-0/out.tsv', 'w') as f:
for pred in predictions:
f.write(f'{pred}\n')
# Test data
x_test_vectorized = tfidf_vectorizer.transform(x_test['text'].values)
predictions = mnb_model.predict(x_test_vectorized)
with open('test-A/out.tsv', 'w') as f:
for pred in predictions:
f.write(f'{pred}\n')

5152
test-A/in.tsv Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

289579
test-A/out.tsv Normal file

File diff suppressed because it is too large Load Diff

289579
train/in.tsv Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.