25 lines
1.6 KiB
Python
25 lines
1.6 KiB
Python
|
import pandas as pd
|
||
|
from sklearn.preprocessing import MinMaxScaler
|
||
|
from sklearn.model_selection import train_test_split
|
||
|
gender_classification = pd.read_csv('gender_classification_v7.csv.csv')
|
||
|
|
||
|
gender_classification_train_final, gender_classification_test = train_test_split(gender_classification, test_size=0.2, random_state=1)
|
||
|
gender_classification_test_final, gender_classification_val_final = train_test_split(gender_classification_test, test_size=0.5, random_state=1)
|
||
|
|
||
|
numeric_cols_train = gender_classification_train_final.select_dtypes(include='number').columns
|
||
|
numeric_cols_test = gender_classification_test_final.select_dtypes(include='number').columns
|
||
|
numeric_cols_val = gender_classification_val_final.select_dtypes(include='number').columns
|
||
|
|
||
|
scaler = MinMaxScaler()
|
||
|
|
||
|
gender_classification_train_final[numeric_cols_train] = scaler.fit_transform(gender_classification_train_final[numeric_cols_train])
|
||
|
gender_classification_test_final[numeric_cols_test] = scaler.fit_transform(gender_classification_test_final[numeric_cols_test])
|
||
|
gender_classification_val_final[numeric_cols_val] = scaler.fit_transform(gender_classification_val_final[numeric_cols_val])
|
||
|
|
||
|
gender_classification_train_final = gender_classification_train_final.dropna()
|
||
|
gender_classification_test_final = gender_classification_test_final.dropna()
|
||
|
gender_classification_val_final = gender_classification_val_final.dropna()
|
||
|
|
||
|
gender_classification_train_final.to_csv('gender_classification_train.csv', index=False)
|
||
|
gender_classification_test_final.to_csv('gender_classification_test.csv', index=False)
|
||
|
gender_classification_val_final.to_csv('gender_classification_val.csv', index=False)
|