linear regr

This commit is contained in:
s470611 2021-05-09 21:26:15 +02:00
parent 5c4bb10ddf
commit 979991c0d8
4 changed files with 2034 additions and 0 deletions

1000
dev-0/out.tsv Normal file

File diff suppressed because it is too large Load Diff

BIN
geval Executable file

Binary file not shown.

34
script.py Normal file
View File

@ -0,0 +1,34 @@
from sklearn.linear_model import LinearRegression
import pandas as pd
import numpy as np
def get_model():
df = pd.read_csv('./train/train.tsv', sep='\t',
names=["price", "mileage", "year", "brand", "engine_type", "engine_capacity"])
X = df.loc[:, df.columns != 'price']
y = df['price']
X = X.drop(["brand"], axis=1)
X = pd.get_dummies(X, columns= ["engine_type"], drop_first=True)
regr = LinearRegression()
return regr.fit(X, y)
def predict_and_write(path, model):
with open(f'{path}out.tsv', 'w') as out:
df_dev = pd.read_csv(f'{path}in.tsv', sep='\t',
names=["mileage", "year", "brand", "engine_type", "engine_capacity"])
df_dev = df_dev.drop(["brand"], axis=1)
df_dev = pd.get_dummies(df_dev, columns= ["engine_type"], drop_first=True)
predictions = model.predict(df_dev).astype(int)
for prediction in predictions:
out.write(f"{prediction}\n")
def main():
model = get_model()
predict_and_write('./dev-0/', model)
predict_and_write('./test-A/', model)
if __name__ == '__main__':
main()

1000
test-A/out.tsv Normal file

File diff suppressed because it is too large Load Diff