forked from kubapok/auta-public
Compare commits
No commits in common. "master" and "master" have entirely different histories.
37
app.py
37
app.py
@ -1,37 +0,0 @@
|
||||
import gzip
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
from sklearn.linear_model import LinearRegression
|
||||
from sklearn.utils import shuffle
|
||||
from sklearn.metrics import accuracy_score
|
||||
|
||||
|
||||
def preprocess(x):
|
||||
x = pd.concat([x, x['engineType'].str.get_dummies().astype(bool)], axis=1)
|
||||
x = x.drop(['engineType', 'brand'], axis=1)
|
||||
return x
|
||||
|
||||
|
||||
def makePrediction(path):
|
||||
x_pred = pd.read_table(path + '/in.tsv', error_bad_lines=False, header=None,
|
||||
names=names[1:])
|
||||
x_pred = preprocess(x_pred)
|
||||
|
||||
y_pred = model.predict(x_pred)
|
||||
y_pred.tofile(path + '/out.tsv', sep='\n')
|
||||
|
||||
|
||||
names = ['price', 'mileage', 'year', 'brand', 'engineType', 'engineCap']
|
||||
|
||||
train = pd.read_table('train/train.tsv', error_bad_lines=False, header=None,
|
||||
names=names)
|
||||
|
||||
y_train = train['price']
|
||||
x_train = train.iloc[:, 1:]
|
||||
x_train = preprocess(x_train)
|
||||
|
||||
model = LinearRegression()
|
||||
model.fit(x_train, y_train)
|
||||
|
||||
makePrediction('dev-0')
|
||||
makePrediction('test-A')
|
1000
dev-0/out.tsv
1000
dev-0/out.tsv
File diff suppressed because it is too large
Load Diff
1000
test-A/out.tsv
1000
test-A/out.tsv
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user