naive bayes
This commit is contained in:
parent
9cb2fb2612
commit
898e74309d
5452
dev-0/out.tsv
Normal file
5452
dev-0/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
19
run.py
Normal file
19
run.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
from sklearn.feature_extraction.text import TfidfVectorizer
|
||||||
|
from sklearn.naive_bayes import MultinomialNB
|
||||||
|
from sklearn.pipeline import make_pipeline
|
||||||
|
import sys
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
train_file = sys.argv[1]
|
||||||
|
pred_x_file = sys.argv[2]
|
||||||
|
|
||||||
|
train = pd.read_csv(train_file, sep='\t', header=None)
|
||||||
|
pred_x = pd.read_csv(pred_x_file, sep='\t', header=None)
|
||||||
|
train_x, train_y = train[1], train[0]
|
||||||
|
|
||||||
|
model = make_pipeline(TfidfVectorizer(), MultinomialNB())
|
||||||
|
|
||||||
|
model.fit(train_x, train_y)
|
||||||
|
pred_y = model.predict(pred_x.stack())
|
||||||
|
|
||||||
|
pd.DataFrame(pred_y).to_csv('out.tsv', header=False, index=None)
|
5447
test-A/out.tsv
Normal file
5447
test-A/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user