[업무 지식]/Python
[Scaler] StandardScaler, MinMaxScaler
by 에디터 윤슬
2024. 11. 22.
정규화
# 정규화
def get_numeric_sc(df):
from sklearn.preprocessing import StandardScaler, MinMaxScaler
col_sdsc = ['column1', 'column2', 'column3']
col_mmsc = ['column1']
sd_sc = StandardScaler()
mm_sc = MinMaxScaler()
for column in col_sdsc:
sd_sc.fit(df[[column]])
new_column = f'{column}_sdsc'
df[[new_column]] = sd_sc.transform(df[[column]])
for column1 in col_mmsc:
mm_sc.fit(df[[column1]])
new_column1 = f'{column1}_mmsc'
df[[new_column1]] = mm_sc.transform(df[[column1]])
return df
get_numeric_sc(df)