Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
09a5050dc5 |
37
app.py
Normal file
37
app.py
Normal file
@ -0,0 +1,37 @@
|
||||
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
Normal file
1000
dev-0/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
1000
test-A/out.tsv
Normal file
1000
test-A/out.tsv
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user