Dodanie rozwiązania
This commit is contained in:
parent
756ef4277a
commit
4b9abc42d4
5272
dev-0/out.tsv
Normal file
5272
dev-0/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
28
result.py
Normal file
28
result.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
from sklearn import preprocessing
|
||||||
|
from sklearn.naive_bayes import MultinomialNB
|
||||||
|
from sklearn.preprocessing import LabelEncoder
|
||||||
|
from sklearn.pipeline import make_pipeline
|
||||||
|
from sklearn.feature_extraction.text import TfidfVectorizer
|
||||||
|
import numpy as np
|
||||||
|
import lzma
|
||||||
|
|
||||||
|
def openXZ(path):
|
||||||
|
with lzma.open(path, mode='rt') as f:
|
||||||
|
return f.readlines()
|
||||||
|
|
||||||
|
def readFile(path):
|
||||||
|
with open(path) as source:
|
||||||
|
return source.readlines()
|
||||||
|
|
||||||
|
lines = openXZ('./paranormal-or-skeptic-ISI-public/dev-0/in.tsv.xz')
|
||||||
|
inData = openXZ('./paranormal-or-skeptic-ISI-public/train/in.tsv.xz')
|
||||||
|
expData = readFile('./paranormal-or-skeptic-ISI-public/train/expected.tsv')
|
||||||
|
expected = LabelEncoder().fit_transform(expData)
|
||||||
|
pipeline = make_pipeline(TfidfVectorizer(),MultinomialNB())
|
||||||
|
model = pipeline.fit(inData, expected)
|
||||||
|
result = model.predict(lines)
|
||||||
|
np.savetxt('./paranormal-or-skeptic-ISI-public/dev-0/out.tsv', result, fmt='%d', delimiter='\n')
|
||||||
|
lines = openXZ('./paranormal-or-skeptic-ISI-public/test-A/in.tsv.xz')
|
||||||
|
result = model.predict(lines)
|
||||||
|
np.savetxt('./paranormal-or-skeptic-ISI-public/test-A/out.tsv', result, fmt='%d', delimiter='\n')
|
||||||
|
#dla dev wynik był: 0.7367223065250379, ściezki sa troche dziwne, ponieważ pracowałem na google colab
|
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