Add prediction

This commit is contained in:
Aleksander Piotrowski 2021-04-29 17:14:51 +02:00
parent 60e7521dcc
commit e9683a0e7d
3 changed files with 2026 additions and 0 deletions

1000
dev-0/out.tsv Normal file

File diff suppressed because it is too large Load Diff

26
solution.py Normal file
View File

@ -0,0 +1,26 @@
import numpy
import pandas
import sys
from sklearn.linear_model import LinearRegression
def predict(model, dir):
df = pandas.read_csv(dir+"/in.tsv", sep='\t', header=None, index_col=None)
input_x = numpy.array(df[1].tolist()).reshape(-1, 1)
pred = model.predict(input_x)
numpy.savetxt(dir + "/out.tsv", pred, fmt='%d', delimiter='\n')
trainCsv = pandas.read_csv("train/train.tsv", sep='\t', header=None, index_col=None)
data = {
'x': trainCsv[2].tolist(),
'y': trainCsv[0].tolist(),
}
x = numpy.array(data.get('x')).reshape(-1, 1)
y = numpy.array(data.get('y')).reshape(-1, 1)
model = LinearRegression()
model.fit(x, y)
predict(model, "dev-0")
predict(model, "test-A")

1000
test-A/out.tsv Normal file

File diff suppressed because it is too large Load Diff