initial commit
This commit is contained in:
parent
756ef4277a
commit
0a9af20404
31
app.py
Normal file
31
app.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
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 getResult(filePath):
|
||||||
|
with open(filePath + 'in.tsv') as input:
|
||||||
|
predictData = input.readlines()
|
||||||
|
pred = model.predict(predictData)
|
||||||
|
with open(filePath + "out.tsv", "w") as result:
|
||||||
|
for prediction in pred:
|
||||||
|
result.write(str(prediction) + '\n')
|
||||||
|
|
||||||
|
|
||||||
|
# trainInData = getData('./train/in.tsv')
|
||||||
|
# trainExpData = getData('./train/expected.tsv')
|
||||||
|
|
||||||
|
expectedTraining = open('./train/expected.tsv').readlines()
|
||||||
|
inTraining = open('./train/in.tsv').readlines()
|
||||||
|
|
||||||
|
afterTransform = LabelEncoder().fit_transform(expectedTraining)
|
||||||
|
pipeline = Pipeline(
|
||||||
|
steps=[('tfidf', TfidfVectorizer()), ('naive-bayes', MultinomialNB())])
|
||||||
|
|
||||||
|
model = pipeline.fit(inTraining, afterTransform)
|
||||||
|
|
||||||
|
|
||||||
|
getResult('./dev-0/')
|
||||||
|
getResult('./test-A/')
|
5272
dev-0/out.tsv
Normal file
5272
dev-0/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
5152
test-A/out.tsv
Normal file
5152
test-A/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user