기술(Tech, IT)/머신 러닝(Machine Learning)

[ML] Normalization Technique(정규화 기법)

Daniel803 2023. 3. 26. 08:18

Normalization(정규화)란?

: In data processing, normalization is the process of transforming and scaling numerical data to bring it to a common range or scale, without distorting the differences in the ranges of the individual values. The main goal of normalization is to reduce or eliminate the effects of different measurement scales, so that different variables can be compared on an equal footing.

: 데이터 처리에서 정규화란 개별값의 범위의 차에 대한 왜곡 없이 수치 데이터를 많이 쓰이는 범위나 규모(흔히 0부터 1까지)로 변형시키는 처리다. 목적은 규모가 달라서 오는 영향을 줄이거나 없애, 각 값들은 같은 규모에서 비교할 수 있도록 하는 것이다.

 

 Google 머신 러닝 교육은 아래와 같이 4가지 Normalization 기법을 소개하고 있고, 간단한 설명을 덧붙인다.

(Scaling to a range, Clipping, Log scaling, Z-score)

 

1. Scaling to a range

: Convert floating-point feature values from their natural range (for example, 100 to 900) into a standard range—usually 0 and 1 (or sometimes -1 to +1). Use the following simple formula to scale to a range
: 예를 들어 100부터 900까지의 값을 갖는 데이터를 일반적인 표준 범위(대개 0부터 1까지, 종종 -1부터 1까지)로 변경하는 것이고 식은 다음과 같다

2. Clipping

:If your data set contains extreme outliers, you might try feature clipping, which caps all feature values above (or below) a certain value to fixed value. For example, you could clip all temperature values above 40 to be exactly 40.

: Clipping은 경계값으로 생각하는 지점을 넘어가면 해당 경계값으로 데이터의 값을 고정시키는 것이다. 예를 들어, 온도에 대한 데이터인데 40도를 넘어가는 데이터는 모두 40도로 고정시키는 것이다. 데이터 집합이 극단적인 이상치를 퐇마하고 있다면 Clipping을 적용하는 것을 고려해봄직한다. 

 

3. Log scaling

: Log scaling computes the log of your values to compress a wide range to a narrow range.

: 데이터의 값에 로그를 취하는 것으로 매우 간단하고 식으로 나타내면 아래와 같다. 수학적 직관이 부족한지 얼마나 효과가 있을까 싶었는데 데이터에 따라 아래와 같이 효과적인 영향을 가져올 수 있다.

4. Z-score

: Z-score is a variation of scaling that represents the number of standard deviations away from the mean. You would use z-score to ensure your feature distributions have mean = 0 and std = 1. It’s useful when there are a few outliers, but not so extreme that you need clipping.

: Z-score는 데이터가 평균(μ​)으로부터(x-μ​) 몇 배(/σ)의 표준편차(σ)만큼 떨어져 있는지를 나타내준다. 특징(feature)의 분포가 평균이 0, 표준편차가 1로 만들어 줄 수 있다. Z-score는 약간의 이상치 데이터가 있지만 Clipping을 해야할만큼 극단적이지 않은 경우 유용하다. 아래 식을 이해하면 정의를 좀 더 쉽게 이해할 수 있다.

 Google 머신러닝 교육 자료는 매우 이해하기 쉽게 소개하고 있지만, Normalization(정규화)라는 제목 때문에 개념이 다소 혼란스러웠다. 위 기법들은 Normalization 기법이라기보다 Data transforming(processing) 기법으로 알고 있는 것이 낫다. Normalization는 일반적으로 value(값)을 0과 1 사이로 바꿔주는 것으로 Scaling to a range의 경우 Normalization이지만 Log scaling이나 Z-score의 경우 결과물을 보면 Normalization보다는 Standardization*에 가깝다.

 

Scikit-learn에서 Normalization은 MinMaxScaler를 통해, Standardization은 StandardScaler를 이용해 처리가 가능하다.

 

* Standardization(표준화)

: 데이터의 mean(평균)을 0으로, variance(분산)을 1로 변형.

 

참고

- https://developers.google.com/machine-learning/data-prep/transform/normalization