ium_z486867/create-dataset.py

34 lines
1.0 KiB
Python
Raw Normal View History

2023-04-20 20:03:42 +02:00
import os
from sklearn.model_selection import train_test_split
import pandas as pd
2023-04-20 20:15:37 +02:00
2023-04-20 20:03:42 +02:00
pd.set_option('display.max_columns', 100)
2023-04-20 20:15:37 +02:00
DATA_DIRECTORY = './ium_z434686'
2023-04-20 20:03:42 +02:00
CSV_NAME = DATA_DIRECTORY + '/openpowerlifting.csv'
2023-04-20 20:15:37 +02:00
def process_data(csv_name):
CUTOFF = int(os.environ['CUTOFF'])
2023-04-20 20:03:42 +02:00
2023-04-20 20:15:37 +02:00
powerlifting_data = pd.read_csv(csv_name,
engine='python',
encoding='ISO-8859-1',
sep=',')
powerlifting_data.dropna()
powerlifting_data.drop(columns=["Squat4Kg", "Bench4Kg", "Deadlift4Kg"], inplace=True)
2023-04-20 20:03:42 +02:00
2023-04-20 20:15:37 +02:00
powerlifting_data.sample(CUTOFF)
2023-04-20 20:03:42 +02:00
2023-04-20 20:15:37 +02:00
X, Y = powerlifting_data, powerlifting_data
2023-04-20 20:03:42 +02:00
2023-04-20 20:15:37 +02:00
X_train, X_temp, Y_train, Y_temp = train_test_split(X, Y, test_size=0.3, random_state=1)
X_dev, X_test, Y_dev, Y_test = train_test_split(X_temp, Y_temp, test_size=0.3, random_state=1)
2023-04-20 20:03:42 +02:00
2023-04-20 20:15:37 +02:00
X_train.to_csv('X_train.csv', index=False)
X_dev.to_csv('X_dev.csv', index=False)
X_test.to_csv('X_test.csv', index=False)
2023-04-20 20:03:42 +02:00
2023-04-20 19:48:17 +02:00
process_data(CSV_NAME)