Compare commits

..

2 Commits

Author SHA1 Message Date
patrycjalazna
418816f27e minor fix 2021-05-16 20:36:26 +02:00
patrycjalazna
7c67f8511a linear regression 2021-05-16 13:57:39 +02:00
7 changed files with 280773 additions and 0 deletions

20000
dev-0/meta.tsv Normal file

File diff suppressed because it is too large Load Diff

20000
dev-0/out.tsv Normal file

File diff suppressed because it is too large Load Diff

11563
dev-1/meta.tsv Normal file

File diff suppressed because it is too large Load Diff

48
linear-regression.py Normal file
View File

@ -0,0 +1,48 @@
from re import L
import pandas as pd
import numpy as np
import csv
from sklearn.linear_model import LinearRegression
from stop_words import get_stop_words
from sklearn.feature_extraction.text import TfidfVectorizer
def linear_regression():
# odczyt z plików
colnames_train = ['start_date', 'end_date', 'title', 'sort_title', 'data']
colnames_test = ['data']
train = pd.read_csv("train/train.tsv", names = colnames_train, sep = "\t")
dev_0 = pd.read_csv("dev-0/in.tsv", error_bad_lines = False, header = None, sep = "\t", quoting=csv.QUOTE_NONE)
dev_1 = pd.read_csv("dev-1/in.tsv", error_bad_lines = False, header = None, sep = "\t", quoting=csv.QUOTE_NONE,)
test = pd.read_csv("test-A/in.tsv", names = colnames_test, sep = "\t")
# stworzenie instancji TFIDF i regresji liniowej
tf = TfidfVectorizer(stop_words=get_stop_words('polish'))
lin_reg = LinearRegression()
# wydobycie daty
date = (train['start_date'] + train['end_date']) / 2
# regresja liniowa
train_vec = tf.fit_transform(train['data'])
lin_reg.fit(train_vec, date)
# predykcja dla dev-0
evaluate_dev = tf.transform(dev_0['data'])
prediction_dev = lin_reg.predict(evaluate_dev)
pd.DataFrame(prediction_dev).to_csv('dev-0/out2.tsv', sep = "\t", index = False, header = False)
# predykcja dla test-A
evaluate_test = tf.transform(test['data'])
prediction_test = lin_reg.predict(evaluate_test)
pd.DataFrame(prediction_test).to_csv('test-A/out2.tsv', sep = "\t", index = False, header = False)
return None
if __name__ == "__main__":
linear_regression()
# geval: 21.80

14220
test-A/out.tsv Normal file

File diff suppressed because it is too large Load Diff

107471
train/meta.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