Run autopep8

This commit is contained in:
Aleksy Wroblewski 2021-04-22 22:03:47 +02:00
parent d2d308a78a
commit 0238b238d2

View File

@ -10,7 +10,7 @@ from nltk.corpus import stopwords
# pogarsza wynik z 0.73 na 0.7 # pogarsza wynik z 0.73 na 0.7
def preprocess(line, stop_words): def preprocess(line, stop_words):
return " ".join([word for word in line.split() if word not in stop_words]) return " ".join([word for word in line.split() if word not in stop_words])
def train_model(train_in, train_expected): def train_model(train_in, train_expected):
@ -29,8 +29,8 @@ def train_model(train_in, train_expected):
# MemoryError # MemoryError
pipeline = Pipeline(steps=[ pipeline = Pipeline(steps=[
('tfidf', TfidfVectorizer()), ('tfidf', TfidfVectorizer()),
('naive-bayes', MultinomialNB()) ('naive-bayes', MultinomialNB())
]) ])
return pipeline.fit(train_data, exp_encoded) return pipeline.fit(train_data, exp_encoded)
@ -42,11 +42,13 @@ def predict(model, in_file, out_file):
prediction = model.predict(lines) prediction = model.predict(lines)
np.savetxt(out_file, prediction, fmt='%d') np.savetxt(out_file, prediction, fmt='%d')
def main(): def main():
#stop_words = set(stopwords.words('english')) #stop_words = set(stopwords.words('english'))
model = train_model("train/in.tsv", "train/expected.tsv") model = train_model("train/in.tsv", "train/expected.tsv")
predict(model, "dev-0/in.tsv", "dev-0/out.tsv") predict(model, "dev-0/in.tsv", "dev-0/out.tsv")
predict(model, "test-A/in.tsv", "test-A/out.tsv") predict(model, "test-A/in.tsv", "test-A/out.tsv")
if __name__ == '__main__': if __name__ == '__main__':
main() main()