Statistics

데이터 과학을 위한 통계(1)Practical Statistics for Data Scientists (1)

정형화된 데이터의 요소

센서 측정, 이미지, 비디오, 텍스트, 이벤트 등을 통해 졍형화되어 있지 않은 데이터를 받는다. 데이터 과학은 이러한 데이터들의 **폭발적인 양의 원시(가공되지 않은) 데이터**를 활용 가능하도록 정형화된 형태로 변환해야 한다. 정형 데이터 중 가장 일반적인 형태는 열이 있는 테이블 형태이다.

정형데이터의 종류

수치형 데이터

  • 연속형 데이터: 풍속이나 지속 시간
  • 이산 데이터: 사건의 발생 빈도

범주형 데이터

도시명(대전, 부산, 서울)과 같이 범위가 정해진 값들을 같은 경우

  • 이진 데이터: 범주형 중에서도 참/거짓, 0과 1, 예/아니요 같은 두 값 중 하나를 갖는 특수한 경우
  • 순서형 데이터: 평점(1, 2, 3, 4, 5)이 대표적

왜 정형화된 데이터로 바꿀까?

데이터를 분석하고 예측을 모델링할 때, 시각화, 해석, 통계 모델 결정 등에 데이터 종류가 중요한 역할을 하기 때문이다.


테이블 데이터

가장 대표적으로 사용되는 객체의 형태로 엑셀이나 데이터베의 테이블과 같은 테이블 데이터이다. 기본적으로 레코드를 나타내는 행과 피쳐(변수)를 나타내는 열로 이루어진 이차원 행렬을 의미한다.

지표 변수가 결과 변수가 되기도 한다.

테이블 형식이 아닌 데이터 구조

  • 시계열 데이터: 동일한 변수 안에 연속적인 측정값을 가진다.
  • 공간 데이터: 객체를 표현할 때는, 어떤 객체(주택)와 그것의 공간 좌표가 데이터의 중심이 된다. 반면 필드 정보는 공간을 나타내는 작은 단위들과 적당한 측정 기준값(픽셀의 밝기)에 중점을 둔다
  • 그래프(혹은 네트워크) 데이터: 물리적 관계, 사회적 관계, 그리고 다소 추상적인 관계들을 표현하기 위해 사용

위치 추정

데이터를 살펴보는 가장 기초적인 단계는 각 피처(변수)의 ‘대푯값’을 구하는 것이다. 대부분의 값이 어디에 위치하는지(중심경향성)을 나타내는 추정값

  • 평균(mean): 모든 값의 총합을 개수로 나눈 값
  • 가중평균(weighted mean): 가중치를 곱한 값의 총합을 가중치의 총합으로 나눈 값
  • 중간값(median): 데이터에서 가장 가운데 위치한 값, 로버스트한 위치 추정 방버
  • 백분위수(percentile): 전체 데이터의 P%P\%를 아래에 두는 값(크기순으로 나열한 데이터를 100등분하여 특정 위치의 값을 나타내는 통계적 수치)
  • **가중 중간값(weighted median)****: 데이터를 정렬한 후, 각 가중치 값을 위에서부터 더할 때, 총합의 중간이 위치하는 데이터 값
  • 절사평균(trimmed mean): 정해진 개수의 극단값을 제외한 나머지 값들의 평균
  • 로버스트(robust): 극단값들에 민감하지 않다는 것을 의미
  • 특잇값(outlier): 대부분의 값과 매우 다른 데이터 값(유의어: 극단값)

지수 가중 평균: 데이터의 이동 평균을 구할 때, 오래된 데이터가 미치는 영향을 지수적으로 감쇠(exponential decay) 하도록 만들어 주는 방법


변이 추정

데이터 값이 얼마나 밀집해 있는지 혹은 퍼져 있는지를 나타내는 산포도를 나타낸다.

  • 편차(deviation): 관측값과 위치 추정값 사이의 차이(유의어: 오차, 잔차)
  • 분산(variance): 평균과의 편차를 제곱한 값들의 합을 n-1로 나눈 값, n은 데이터 개수(유의어: 평균제곱오차)
  • 표준편차(standard deviation): 분산의 제곱근
  • 평균절대편차(mean absolute deviation): 평균과의 편차의 절댓갑의 평균(유의어: L1 노름, 맨해튼 노름, 평균절대오차)
  • 중간값의 중위절대편차(MAD): 중간값과의 편차의 절댓갑의 중간값
  • 순서 통계량(order statistics): 최소에서 최대까지 정렬된 데이터 값에 따른 계량형

출처

데이터 과학을 위한 통계(p.19-38)

Elements of structured data

Data arrives unstructured, from sensor measurements, images, video, text, events and more. Data science has to turn this explosive volume of raw (unprocessed) data into a structured form that can be used. The most common form of structured data is a table with columns.

Types of structured data

Numeric data

  • Continuous data: wind speed or duration
  • Discrete data: how often an event occurs

Categorical data

Values from a fixed set, such as city names (Daejeon, Busan, Seoul)

  • Binary data: a special case of categorical data that takes one of two values, such as true/false, 0 and 1, or yes/no
  • Ordinal data: ratings (1, 2, 3, 4, 5) are the typical example

Why convert to structured data?

Because the type of data plays an important role in visualization, interpretation and choosing a statistical model when analyzing data and building predictive models.


Tabular data

The most commonly used form of object is tabular data, like a table in Excel or a database. It is basically a two-dimensional matrix of rows representing records and columns representing features (variables).

An indicator variable can also become an outcome variable.

Non-tabular data structures

  • Time series data: holds successive measurements of the same variable.
  • Spatial data: when representing objects, the focus is an object (a house) and its spatial coordinates. Field data, on the other hand, focuses on small units of space and an appropriate measurement value (pixel brightness).
  • Graph (or network) data: used to represent physical, social and somewhat abstract relationships

Estimates of location

The most basic step in exploring data is finding a “typical value” for each feature (variable): an estimate of where most of the values are located (central tendency).

  • Mean: the sum of all values divided by the number of values
  • Weighted mean: the sum of values multiplied by weights, divided by the sum of the weights
  • Median: the value in the very middle of the data; a robust estimate of location
  • Percentile: the value below which P%P\% of the data lies (a statistic giving the value at a particular position when the sorted data is divided into 100 equal parts)
  • Weighted median**: after sorting the data, the value where the running sum of the weights from the top reaches half of the total
  • Trimmed mean: the mean of the values remaining after dropping a fixed number of extreme values
  • Robust: not sensitive to extreme values
  • Outlier: a data value very different from most of the others (synonym: extreme value)

Exponentially weighted mean: a way of computing a moving average in which the influence of older data decays exponentially


Estimates of variability

Describes dispersion: how tightly packed or spread out the data values are.

  • Deviation: the difference between an observed value and the estimate of location (synonyms: error, residual)
  • Variance: the sum of squared deviations from the mean divided by n-1, where n is the number of data points (synonym: mean squared error)
  • Standard deviation: the square root of the variance
  • Mean absolute deviation: the mean of the absolute deviations from the mean (synonyms: L1 norm, Manhattan norm, mean absolute error)
  • Median absolute deviation from the median (MAD): the median of the absolute deviations from the median
  • Order statistics: metrics based on the data values sorted from smallest to largest

Source

Practical Statistics for Data Scientists (pp. 19–38)