auta-public-s416089/solution.ipynb
2021-05-06 11:28:34 +02:00

5.0 KiB

import pandas as pd
import numpy as np
from pathlib import Path
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
from sklearn.linear_model import LinearRegression

TRENING

NAMES = ["Price","Mileage","Year","Brand","EngineType","EngineCapacity"]
TRAIN_BASE = pd.read_csv("train/train.tsv", sep ='\t', names=NAMES)
Y_TRAIN = np.array(TRAIN_BASE["Price"])
X_TRAIN = np.array(TRAIN_BASE[["Mileage","Year","EngineCapacity"]])
MODEL = LinearRegression().fit(X_TRAIN,Y_TRAIN)

DEV-0

NAMES = ["Mileage","Year","Brand","EngineType","EngineCapacity"]
FILE_BASE = pd.read_csv("dev-0/in.tsv", sep ='\t', names=NAMES)
X_TEST = np.array(FILE_BASE[["Mileage","Year","EngineCapacity"]])
Y_TEST = MODEL.predict(X_TEST)
VALUES = np.array2string(Y_TEST, precision=5, separator='\n',suppress_small=True)
VALUES = VALUES.split(".\n")
OUTFILE = open("dev-0/out.tsv", "w")
for x in VALUES:
    RESULT = x.replace(" ","")
    RESULT = RESULT.replace("[","")
    RESULT = RESULT.replace("]","")
    OUTFILE.write(str(RESULT))
OUTFILE.close()

TEST A

NAMES = ["Mileage","Year","Brand","EngineType","EngineCapacity"]
FILE_BASE = pd.read_csv("test-A/in.tsv", sep ='\t', names=NAMES)
X_TEST = np.array(FILE_BASE[["Mileage","Year","EngineCapacity"]])
Y_TEST = MODEL.predict(X_TEST)
VALUES = np.array2string(Y_TEST, precision=5, separator='\n',suppress_small=True)
VALUES = VALUES.split(".\n")
OUTFILE = open("test-A/out.tsv", "w")
for x in VALUES:
    RESULT = x.replace(" ","")
    RESULT = RESULT.replace("[","")
    RESULT = RESULT.replace("]","")
    OUTFILE.write(str(RESULT) )
OUTFILE.close()