text_html_output_1.png text_plain_output_1.png
from sklearn.model_selection import train_test_split

from sklearn.preprocessing import StandardScaler

import pandas as pd

data = pd.read_csv('/kaggle/input/loan-data-set/loan_data_set.csv')

data = data.dropna()

data_encoded = pd.get_dummies(data, columns=['Property_Area'])

from sklearn.model_selection import train_test_split
data_y = data_encoded[['Loan_Status']]
data_x = data_encoded.drop(columns=['Loan_Status', 'Loan_ID'])
X_train, X_test, y_train, y_test = train_test_split(data_x, data_y, test_size=0.2, random_state=1)

from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
data_encoded = data_encoded.drop(columns=['Loan_ID'])
cols_to_scale = [col for col in data_encoded.columns if col != 'Loan_Status']
data_std = data_encoded[cols_to_scale].copy()
data_std[cols_to_scale] = scaler.fit_transform(data_std[cols_to_scale])
data_std['Loan_Status'] = data_encoded['Loan_Status']
data_std.head(10)