Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
f979826241 |
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
30
result.py
Normal file
30
result.py
Normal file
@ -0,0 +1,30 @@
|
||||
from sklearn.feature_extraction.text import TfidfVectorizer
|
||||
from sklearn.linear_model import LinearRegression
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import csv
|
||||
|
||||
def getData(path):
|
||||
with open(path, encoding="utf-8") as source:
|
||||
return source.readlines()
|
||||
|
||||
def changeToDf(input):
|
||||
return pd.read_csv(input, sep="\t")
|
||||
|
||||
vectorizer = TfidfVectorizer()
|
||||
linear = LinearRegression()
|
||||
train = pd.read_csv("./train/train.tsv", sep="\t", names=['start_date', 'end_date', 'title', 'sort_title', 'data'])
|
||||
mean = (train['start_date'] + train['end_date']) / 2
|
||||
tv = vectorizer.fit_transform(train['data'])
|
||||
linear.fit(tv, mean)
|
||||
|
||||
def calculateResult(in_, out):
|
||||
tmp = getData(in_)
|
||||
df = pd.DataFrame(data = tmp)
|
||||
data = vectorizer.transform(df[0])
|
||||
evaluate = linear.predict(data)
|
||||
np.savetxt(out, evaluate, fmt='%f', delimiter='\n')
|
||||
|
||||
calculateResult("./dev-0/in.tsv", "./dev-0/out.tsv")
|
||||
calculateResult("./dev-1/in.tsv", "./dev-1/out.tsv")
|
||||
calculateResult("./test-A/in.tsv", "./test-A/out.tsv")
|
14220
test-A/out.tsv
Normal file
14220
test-A/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
107471
train/train.tsv
Normal file
107471
train/train.tsv
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user