ium_z444439/create-dataset.py

26 lines
802 B
Python
Raw Normal View History

2023-04-19 20:22:37 +02:00
import pandas as pd
2023-04-19 18:47:42 +02:00
import os
from sklearn.model_selection import train_test_split
2023-05-11 18:37:18 +02:00
import train
2023-04-19 18:47:42 +02:00
CUTOFF = int(os.environ['CUTOFF'])
2023-04-19 20:22:37 +02:00
adults = pd.read_csv('adult.csv')
2023-04-19 18:47:42 +02:00
adults = adults.dropna()
2023-05-11 18:40:03 +02:00
adults = adults.drop(adults.columns[[1, 3, 4, 5, 6, 7, 8, 9, 13, 14]], axis=1)
2023-04-19 18:47:42 +02:00
adults = adults.sample(CUTOFF)
2023-05-11 18:27:25 +02:00
X = adults.copy()
Y = pd.DataFrame(adults.pop('age'))
2023-04-19 18:47:42 +02:00
2023-05-11 18:27:25 +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)
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)
Y_test.to_csv('Y_test.csv', index=False)
Y_train.to_csv('Y_train.csv', index=False)
Y_dev.to_csv('Y_dev.csv', index=False)
2023-05-11 18:37:18 +02:00
train.main()