Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
c4eef02f76 |
5272
dev-0/in.tsv
Normal file
5272
dev-0/in.tsv
Normal file
File diff suppressed because one or more lines are too long
5272
dev-0/out.tsv
Normal file
5272
dev-0/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
26
main.py
Normal file
26
main.py
Normal file
@ -0,0 +1,26 @@
|
||||
from sklearn.naive_bayes import MultinomialNB
|
||||
from sklearn.preprocessing import LabelEncoder
|
||||
from sklearn.pipeline import Pipeline
|
||||
from sklearn.feature_extraction.text import TfidfVectorizer
|
||||
import numpy as np
|
||||
|
||||
def getData(path):
|
||||
with open(path) as source:
|
||||
return source.readlines()
|
||||
|
||||
trainInData = getData('./train/in.tsv')
|
||||
trainExpData = getData('./train/expected.tsv')
|
||||
afterTransform = LabelEncoder().fit_transform(trainExpData)
|
||||
pipeline = Pipeline(steps=[('tfidf', TfidfVectorizer()),('naive-bayes', MultinomialNB())])
|
||||
|
||||
model = pipeline.fit(trainInData, afterTransform)
|
||||
|
||||
def getResult(path):
|
||||
dataToPredict = getData(path + 'in.tsv')
|
||||
pred = model.predict(dataToPredict)
|
||||
with open(path + "out.tsv", "w") as result:
|
||||
for prediction in pred:
|
||||
result.write(str(prediction) + '\n')
|
||||
|
||||
getResult('./dev-0/')
|
||||
getResult('./test-A/')
|
5152
test-A/in.tsv
Normal file
5152
test-A/in.tsv
Normal file
File diff suppressed because one or more lines are too long
5152
test-A/out.tsv
Normal file
5152
test-A/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
289579
train/in.tsv
Normal file
289579
train/in.tsv
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user