Compare commits

...

3 Commits

Author SHA1 Message Date
JPogodzinski
a0e14fe99d change config.txt 2021-05-01 12:57:20 +02:00
JPogodzinski
11ce81b395 change place of main.py 2021-04-29 15:52:53 +02:00
JPogodzinski
8293ebe7be done learning 2021-04-29 13:10:09 +02:00
5 changed files with 2052 additions and 1 deletions

View File

@ -1 +1 @@
--precision 1 --metric RMSE --precision 1

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.

51
main.py Normal file
View File

@ -0,0 +1,51 @@
import pandas as pd
import numpy as np
from pathlib import Path
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
with open('names') as f_names:
names = f_names.read().rstrip('\n').split('\t')
cars_train = pd.read_csv('train/train.tsv', sep='\t', names=names)
cars_train = pd.get_dummies(cars_train, columns=['engineType'])
y_train = pd.DataFrame(cars_train['price'])
cars_train.drop('price', inplace=True, axis=1)
cars_train.drop('brand', inplace=True, axis=1)
x_train = pd.DataFrame(cars_train)
model = LinearRegression()
model.fit(x_train, y_train)
names.remove('price')
cars_dev = pd.read_csv('dev-0/in.tsv', sep='\t', names=names)
with open('dev-0/expected.tsv', 'r') as dev_exp_f:
Y_dev = np.array([float(x.rstrip('\n')) for x in dev_exp_f.readlines()])
cars_dev = pd.get_dummies(cars_dev, columns=['engineType'])
cars_dev.drop('brand', inplace=True, axis=1)
X_dev = pd.DataFrame(cars_dev)
Y_dev_predicted = model.predict(X_dev)
print(Y_dev_predicted)
pd.DataFrame(Y_dev_predicted).to_csv('dev-0/out.tsv', sep='\t', index=False, header=False)
cars_test=pd.read_csv('test-A/in.tsv', sep='\t', names=names)
cars_test = pd.get_dummies(cars_test, columns=['engineType'])
cars_test.drop('brand', inplace=True, axis=1)
X_test = pd.DataFrame(cars_test)
Y_test_predicted = model.predict(X_test)
pd.DataFrame(Y_test_predicted).to_csv('test-A/out.tsv', sep='\t', index=False, header=False)
error = np.sqrt(mean_squared_error(Y_dev, Y_dev_predicted))
print(error)

1000
test-A/out.tsv Normal file

File diff suppressed because it is too large Load Diff