update
This commit is contained in:
parent
e92ad61864
commit
bf6bbf28ff
10544
dev-0/out.tsv
10544
dev-0/out.tsv
File diff suppressed because it is too large
Load Diff
32
program.py
32
program.py
@ -1,30 +1,24 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from sklearn import preprocessing
|
from sklearn import preprocessing
|
||||||
from sklearn.naive_bayes import GaussianNB
|
from sklearn.naive_bayes import MultinomialNB
|
||||||
|
from sklearn.pipeline import make_pipeline
|
||||||
from sklearn.feature_extraction.text import TfidfVectorizer
|
from sklearn.feature_extraction.text import TfidfVectorizer
|
||||||
|
|
||||||
le=preprocessing.LabelEncoder()
|
le=preprocessing.LabelEncoder()
|
||||||
|
|
||||||
|
|
||||||
with open("train/in.tsv") as f:
|
with open("train/in.tsv") as f:
|
||||||
data = f.readlines()
|
X = f.readlines()
|
||||||
vectorizer = TfidfVectorizer(ngram_range=(1,2), use_idf = False)
|
|
||||||
vectorizer = TfidfVectorizer()
|
|
||||||
x = vectorizer.fit_transform(data)
|
|
||||||
X=x.toarray()
|
|
||||||
with open("train/expected.tsv") as ff:
|
with open("train/expected.tsv") as ff:
|
||||||
Y = ff.readlines()
|
Y = ff.readlines()
|
||||||
Y=le.fit_transform(Y)
|
Y= le.fit_transform(Y)
|
||||||
with open("dev-0/in.tsv") as d:
|
with open("test-A/in.tsv") as d:
|
||||||
fil = d.readlines()
|
r = d.readlines()
|
||||||
vectorizer = TfidfVectorizer(ngram_range=(1,2), use_idf = False)
|
gnb = make_pipeline(TfidfVectorizer(),MultinomialNB())
|
||||||
vectorizer = TfidfVectorizer()
|
|
||||||
r=vectorizer.fit_transform(fil)
|
|
||||||
r=r.toarray()
|
|
||||||
r=r.reshape(-1,1)
|
|
||||||
gnb = GaussianNB()
|
|
||||||
model=gnb.fit(X, Y)
|
model=gnb.fit(X, Y)
|
||||||
y_pred=model.predict(X)
|
y_pred=model.predict(r)
|
||||||
print(y_pred)
|
|
||||||
y_pred=np.array(y_pred)
|
y_pred=np.array(y_pred)
|
||||||
t=np.array2string(y_pred, precision=2, separator='\n',suppress_small=True)
|
np.set_printoptions(threshold=np.inf)
|
||||||
f = open("dev-0/out.tsv", "a")
|
t=np.array2string(y_pred.flatten(), precision=2, separator='\n',suppress_small=True)
|
||||||
|
f = open("test-A/out.tsv", "a")
|
||||||
f.write(t)
|
f.write(t)
|
||||||
|
10304
test-A/out.tsv
10304
test-A/out.tsv
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user