forked from kubapok/auta-public
25 lines
1019 B
Python
25 lines
1019 B
Python
import numpy as np
|
|
from sklearn import preprocessing
|
|
from sklearn.pipeline import make_pipeline
|
|
from sklearn.feature_extraction.text import TfidfVectorizer
|
|
from sklearn.linear_model import LinearRegression
|
|
from sklearn import linear_model
|
|
import pandas as pd
|
|
|
|
|
|
train=pd.read_csv('train/train.tsv',sep='\t',names=['price','mileage','year','brand','engineType','engineCapacity'])
|
|
df = pd.DataFrame(train,columns=['price','mileage','year','brand','engineType','engineCapacity'])
|
|
Y=df[['price']]
|
|
X=df[['year','mileage','engineCapacity']]
|
|
reg = linear_model.LinearRegression()
|
|
reg.fit(X, Y)
|
|
inn=pd.read_csv('test-A/in.tsv',sep='\t',names=['mileage','year','brand','engineType','engineCapacity'])
|
|
df = pd.DataFrame(inn,columns=['mileage','year','brand','engineType','engineCapacity'])
|
|
r=df[['year','mileage','engineCapacity']]
|
|
y_pred=reg.predict(r)
|
|
y_pred=np.concatenate(y_pred)
|
|
t=np.array2string(y_pred, precision=5, separator='\n',suppress_small=True)
|
|
t=t.lstrip('[').rstrip(']')
|
|
f = open("test-A/out.tsv", "a")
|
|
f.write(t)
|