본문 바로가기
[업무 지식]/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)

'[업무 지식] > Python' 카테고리의 다른 글

[시계열분석] polyfit, propher  (0) 2024.11.26
[범주형 인코딩] LabelEncoder, OnehotEncording  (0) 2024.11.23
[2차원 배열 저장] for문  (0) 2024.11.21
[이상치 처리] Python  (0) 2024.11.07
[결측값 처리] python 기초  (0) 2024.11.07