MLOps 부트캠프 by 한경+토스뱅크/Python

DataFrame - 숫자 데이터 가공하기

나니니 2024. 8. 4. 12:29

스케일링

정규화(Normalization)

예제)

import pandas as pd

patient_df = pd.read_csv('data/patient.csv')

w_min = patient_df['weight'].min()
w_max = patient_df['weight'].max()
patient_df['weight'] = ((patient_df['weight'] - w_min) / (w_max - w_min))
patient_df

#######################
import pandas as pd

patient_df = pd.read_csv('data/patient.csv')

patient_df['weight'] = (patient_df['weight'] - patient_df['weight'].min()) \
                        / (patient_df['weight'].max() - patient_df['weight'].min())
patient_df

결과값

표준화(Standardization)