ium_z487179/createDataset/createDataset.py

22 lines
1.2 KiB
Python
Raw Normal View History

2023-04-20 19:37:30 +02:00
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
from sklearn.model_selection import train_test_split
home_loan_train = pd.read_csv('loan_sanction_train.csv')
home_loan_test = pd.read_csv('loan_sanction_test.csv')
2023-05-13 11:25:49 +02:00
home_loan_train_final, home_loan_test = train_test_split(home_loan_train, test_size=0.2, random_state=1)
home_loan_test_final, home_loan_val_final = train_test_split(home_loan_test, test_size=0.5, random_state=1)
2023-04-20 19:37:30 +02:00
numeric_cols_train = home_loan_train_final.select_dtypes(include='number').columns
numeric_cols_test = home_loan_test_final.select_dtypes(include='number').columns
numeric_cols_val = home_loan_val_final.select_dtypes(include='number').columns
scaler = MinMaxScaler()
home_loan_train_final[numeric_cols_train] = scaler.fit_transform(home_loan_train_final[numeric_cols_train])
home_loan_test_final[numeric_cols_test] = scaler.fit_transform(home_loan_test_final[numeric_cols_test])
home_loan_val_final[numeric_cols_val] = scaler.fit_transform(home_loan_val_final[numeric_cols_val])
home_loan_train_final.to_csv('home_loan_train.csv', index=False)
home_loan_test_final.to_csv('home_loan_test.csv', index=False)
home_loan_val_final.to_csv('home_loan_val.csv', index=False)