IIS_2023_1/malkova_anastasia_lab_4/data.py
2023-11-16 22:21:04 +04:00

32 lines
578 B
Python

import pandas as pd
from constants import DATA_SIZE
def load_data():
data = read_data()
Y = data['Model']
X = data[['Year', 'Price', 'Mileage']]
return X, Y
def fit_model(model, x):
transformed = model.fit_transform(x)
return transformed[:, 0], transformed[:, 1]
def create_data():
data = read_data()
return data[['Year', 'Price']]
def read_data():
data = pd.read_csv('true_car_listings.csv')[:DATA_SIZE]
unique_numbers = list(set(data['Model']))
data['Model'] = data['Model'].apply(unique_numbers.index)
return data