Compare commits

...

8 Commits

Author SHA1 Message Date
c058f8af8f Execute for full train set 2021-04-27 23:32:39 +02:00
a4edb0ed99 Fiinal main 2021-04-27 21:23:49 +02:00
b82539de84 out for 50k 2021-04-27 21:15:03 +02:00
8edc349b95 Updated files 2021-04-27 21:01:36 +02:00
fa5e5e599e Secon stage 2021-04-27 20:51:28 +02:00
44375fa02b Delete quote 2021-04-27 20:35:41 +02:00
a7746af86b Ecomper file 2021-04-27 20:13:11 +02:00
2ec127e514 First stage 2021-04-27 19:36:55 +02:00
7 changed files with 153300 additions and 0 deletions

Binary file not shown.

20000
dev-0/out.tsv Normal file

File diff suppressed because it is too large Load Diff

11563
dev-1/out.tsv Normal file

File diff suppressed because it is too large Load Diff

BIN
geval Executable file

Binary file not shown.

46
mian.py Normal file
View File

@ -0,0 +1,46 @@
import csv
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LinearRegression
from stop_words import get_stop_words
import os
import pandas as pd
def read_train_file(inDirectory):
colnames = ['start_date', 'end_date', 'title', 'sort_title', 'data']
df_train = pd.read_csv(inDirectory, sep="\t", names=colnames)
return df_train
def read_evaluate_file(inDirectory):
colnames = ['data']
df_evaluate = pd.read_csv(inDirectory, sep="\t", names=colnames, quoting=csv.QUOTE_NONE, error_bad_lines=False)
return df_evaluate
def train_date_mean(df):
date_mean = (df['start_date'] + df['end_date']) / 2
return date_mean
def linearRegresionTrain():
df = read_train_file('train/train.tsv')
date_mean_df = train_date_mean(df)
train_vectorized_corpus = vectorizer.fit_transform(df['data'])
reg.fit(train_vectorized_corpus, date_mean_df)
def linearRegresionEvaluate(inDirectory, outDirectory):
df_evaluate = read_evaluate_file(inDirectory)
evaluate_vectorized_corpus = vectorizer.transform(df_evaluate['data'])
evaluate = reg.predict(evaluate_vectorized_corpus)
with open(outDirectory, 'w') as file:
for e in evaluate:
file.write("%f\n" % e)
vectorizer = TfidfVectorizer(stop_words=get_stop_words('polish'))
reg = LinearRegression()
linearRegresionTrain()
linearRegresionEvaluate('dev-0/in.tsv', 'dev-0/out.tsv')
linearRegresionEvaluate('dev-1/in.tsv', 'dev-1/out.tsv')
linearRegresionEvaluate('test-A/in.tsv', 'test-A/out.tsv')
os.system("./geval -t dev-0")
os.system("./geval -t dev-1")

14220
test-A/out.tsv Normal file

File diff suppressed because it is too large Load Diff

107471
train/train.tsv Normal file

File diff suppressed because one or more lines are too long