This commit is contained in:
Klaudia 2021-05-08 15:14:21 +02:00
parent 5c4bb10ddf
commit fde7215c96
3 changed files with 2078 additions and 0 deletions

78
Skrypt.py Normal file
View File

@ -0,0 +1,78 @@
#!/usr/bin/env python
# coding: utf-8
from sklearn.linear_model import LinearRegression
import pandas as pd
import string
import csv
price = []
mileage = []
year = []
brand = []
enginetype = []
enginecapacity = []
with open("train/train.tsv") as tsv:
for line in csv.reader(tsv, delimiter="\t"):
price.append(line[0])
mileage.append(line[1])
year.append(line[2])
brand.append(line[3])
enginetype.append(line[4])
enginecapacity.append(line[5])
cena = pd.DataFrame(list(zip(price)))
reszta = pd.DataFrame(list(zip(mileage,year,enginecapacity)))
model = LinearRegression().fit(reszta,cena)
out1 = open("dev-0/out.tsv", "w")
mileage_dev = []
year_dev = []
brand_dev = []
enginetype_dev = []
enginecapacity_dev = []
with open("dev-0/in.tsv") as tsv:
for line in csv.reader(tsv, delimiter="\t"):
mileage_dev.append(line[0])
year_dev.append(line[1])
brand_dev.append(line[2])
enginetype_dev.append(line[3])
enginecapacity_dev.append(line[4])
do_predykcji1 = pd.DataFrame(list(zip(mileage_dev,year_dev,enginecapacity_dev)))
predict1 = model.predict(do_predykcji1)
for x in predict1:
new1 = str(x).replace('[','')
new1 = str(new1).replace(']','')
out1.write(str(new1) + '\n')
out1.close()
out2 = open("test-A/out.tsv", "w")
mileage_test = []
year_test = []
brand_test = []
enginetype_test = []
enginecapacity_test = []
with open("test-A/in.tsv") as tsv:
for line in csv.reader(tsv, delimiter="\t"):
mileage_test.append(line[0])
year_test.append(line[1])
brand_test.append(line[2])
enginetype_test.append(line[3])
enginecapacity_test.append(line[4])
do_predykcji2 = pd.DataFrame(list(zip(mileage_test,year_test,enginecapacity_test)))
predict2 = model.predict(do_predykcji2)
for y in predict2:
new2 = str(y).replace('[','')
new2 = str(new2).replace(']','')
out2.write(str(new2) + '\n')
out2.close()

1000
dev-0/out.tsv Normal file

File diff suppressed because it is too large Load Diff

1000
test-A/out.tsv Normal file

File diff suppressed because it is too large Load Diff