forked from kubapok/auta-public
27 lines
701 B
Python
27 lines
701 B
Python
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")
|