Why Preprocessing?

데이터 전처리가 필요한 이유

  • 실제 데이터는 다양한 소스 및 프로세스에 의해 수집되며 데이터 집합의 품질을 떨어트리는 이상값 또는 손상된 값이 포함될 수 있다.
  • 데이터 분석에 용이하도록 적절한 처리 필요

데이터전처리를 위한 대표적인 Tool

  • Python -> scikit-learn -> sklearn.preprocessing

Methods for Preprocessing

대표적인 방법들

  1. Standardzation, or mean removal and variance scaling (Z-score)
  2. Min-Max Normalization
  3. Normalized vector or Unit vector
  4. Outlier Detection
  5. Missing Value Imputation
  6. Binarization by threshold
  7. One-hot-encoding or One-hot-representation or One-hot-vector
  8. Method for Specific Data Types
    • Images : Resizing, Cropping, etc.
    • Speech, Video : Sampling, Interpolation

Standardization

Standardization

  • mean removal and variance scaling(Z-score)
  • 표준화, 정규화
  • 데이터의 분포를 Standard normal distribution인 표준 정규 분포 형태로 변환
  • 평균 0, 분산 1인 Gaussian distribution

Min-Max Normalization

Min-Max Normalization

  • [0, 1]값으로 변환, feature의 domain 조절 위해 많이 사용
    이때, 0은 min값, 1은 max값이다.
  • preprocessing.minmax_scale() 함수
  • preprocessing.MinMaxScaler() 및 fit_transform() 함수

Unit Vector Nomalization

Normalized vector or Unit Vector

  • scaling individual samples to have unit norm
  • unit vector - 길이(norm, length)가 1인 벡터
|u| = 1

이때 norm이란 x/|x|=1 이다. (여기서 x = [x1, x2, x3, … , xn]의 n차원 data이다.)

  • preprocessing.normalize() 함수

Normalize -> standardization, min-max -> vector 가능


Treating Outlier

Outlier Detection and Deletion

  • 학습에 좋지 않은 영향을 주는 data를 detect하여 제거
  • Outlier의 정의
    • median인 중앙값을 중심으로 데이터의 50%가 분포하는 범위를 기준 -> IQR
    • 4분위값 + 1.5*IQR을 넘어서는 데이터를 outlier로 정의 -> 제거
  • 추정할때 방해 데이터를 제거
  • 데이터를 들고 왔을때 ‘box plot’을 찍어볼 필요가 있다.

Treating Missing Value

Missing Value Imputation

  • 데이터에서 NaN으로 처리된 값 채워넣기
  • preprocessing.Imputer() 함수
    -NaN 값을 각 속성의 mean(평균), median(중간값), most_frequent(제일 많은 값)으로 대체
ex. 설문조사

Binarization

Binarization by threshold

  • thresholding numerical features to get Boolean values, 쉽게 말해 Bool값을 얻기위해 임계값 수치 특정한다.
  • preprocessing.Binarizer() 함수

One-hot-encoding

One-hot-encoding, One-hot-representation, One-hot-vector

  • 벡터에서 하나의 값만 1로 만드는 것
  • 분류기 학습 시 이진분류기 형태로 만들기 위한 정보 표시 방법
  • 범주형 속성값을 벡터로 표현 (k개 범주 -> k차원 one-hot-vector)
  • 변환 형태
    • 문자열 -> Numerical value -> one-hot-vector preprocessing.LabelEncoder() 및 preprocessing.One-hot-vector 또는 preprocessing.LabelBinarizer()
    • Numerical value -> one-hot-vector preprocessing.OneHotEncoder()
3-dim vector (3차원 vector 변형) : [[1 0 0], [0 1 0], [0 0 1]]
 - 하나만 1인 vector
profile
수현입니다만, 무슨 문제라도 ?

0개의 댓글