forked from kubapok/retroc2
Compare commits
No commits in common. "master" and "master" have entirely different histories.
20000
dev-0/out.tsv
20000
dev-0/out.tsv
File diff suppressed because it is too large
Load Diff
11563
dev-1/out.tsv
11563
dev-1/out.tsv
File diff suppressed because it is too large
Load Diff
30
result.py
30
result.py
@ -1,30 +0,0 @@
|
|||||||
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
14220
test-A/out.tsv
File diff suppressed because it is too large
Load Diff
107471
train/train.tsv
107471
train/train.tsv
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user