s444356
This commit is contained in:
parent
33b70ce7b1
commit
f055e54100
20000
dev-0/out.tsv
Normal file
20000
dev-0/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
11563
dev-1/out.tsv
Normal file
11563
dev-1/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
49
run.py
Normal file
49
run.py
Normal file
@ -0,0 +1,49 @@
|
||||
from sklearn.feature_extraction.text import TfidfVectorizer
|
||||
from sklearn.linear_model import LinearRegression
|
||||
|
||||
with open('train/train.tsv', 'r', encoding='utf8') as f:
|
||||
train = f.readlines()
|
||||
|
||||
with open('train/meta.tsv', 'r', encoding='utf8') as f:
|
||||
expected = f.readlines()
|
||||
|
||||
for i in range(0, len(expected)):
|
||||
expected[i] = expected[i].split('\t')[5]
|
||||
|
||||
vectorizer = TfidfVectorizer()
|
||||
train = vectorizer.fit_transform(train)
|
||||
model = LinearRegression()
|
||||
model.fit(train, expected)
|
||||
|
||||
with open('dev-0/in.tsv', 'r', encoding='utf8') as f:
|
||||
dev_0 = f.readlines()
|
||||
|
||||
dev_0 = vectorizer.transform(dev_0)
|
||||
predicted_dev_0 = model.predict(dev_0)
|
||||
|
||||
with open('dev-0/out.tsv', 'wt') as f:
|
||||
for p in predicted_dev_0:
|
||||
f.write(str(p) + '\n')
|
||||
f.close()
|
||||
|
||||
with open('dev-1/in.tsv', 'r', encoding='utf8') as f:
|
||||
dev_1 = f.readlines()
|
||||
|
||||
dev_1 = vectorizer.transform(dev_1)
|
||||
predicted_dev_1 = model.predict(dev_1)
|
||||
|
||||
with open('dev-1/out.tsv', 'wt') as f:
|
||||
for p in predicted_dev_1:
|
||||
f.write(str(p) + '\n')
|
||||
f.close()
|
||||
|
||||
with open('test-A/in.tsv', 'r', encoding='utf8') as f:
|
||||
test_A = f.readlines()
|
||||
|
||||
test_A = vectorizer.transform(test_A)
|
||||
predicted_test_A = model.predict(test_A)
|
||||
|
||||
with open('test-A/out.tsv', 'wt') as f:
|
||||
for p in predicted_test_A:
|
||||
f.write(str(p) + '\n')
|
||||
f.close()
|
14220
test-A/out.tsv
Normal file
14220
test-A/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user