가중 표본추출

Python으로 설문 데이터 분석하기

EbunOluwa Andrew

Data Scientist

가중 표본추출이란?

  • 불균등 확률
  • 데이터 수집 중 발생한 문제를 보정 가능

책상 위 정의의 저울, 무게 저울, 밸런스

Python으로 설문 데이터 분석하기

가중 표본추출의 공통 변수

  • 성별, 나이, 지역, 교육 등 인구통계 특성
  • 연구 참여 여부에 따른 차이를 반영

가족, 다양한 연령대 사람들 아이콘 스타일

Python으로 설문 데이터 분석하기

셀 기반 가중치 부여

1 https://www.geopoll.com/blog/weighting-survey-data-raking-cell-weighting/
Python으로 설문 데이터 분석하기

셀 기반 가중치 부여

1 https://www.geopoll.com/blog/weighting-survey-data-raking-cell-weighting/
Python으로 설문 데이터 분석하기

셀 기반 가중치 부여

1 https://www.geopoll.com/blog/weighting-survey-data-raking-cell-weighting/
Python으로 설문 데이터 분석하기

셀 기반 가중치 부여

1 https://www.geopoll.com/blog/weighting-survey-data-raking-cell-weighting/
Python으로 설문 데이터 분석하기

파이썬으로 청년 소비 패턴 분석

yp_survey
| Gender | Age | Entertainment |
|--------|-----|---------------|
| female |  19 | Agree         |
| female |  20 | Agree         |
| male   |  19 | Agree         |
| female |  19 | Disagree      |
| female |  24 | Disagree      |
| male   |  18 | Agree         |
| male   |  18 | Agree         |
| male   |  20 | Disagree      |
Python으로 설문 데이터 분석하기

파이썬으로 청년 소비 패턴 분석

import pandas as pd
yp_crosstab = pd.crosstab(
  yp_survey['Gender'],
  yp_survey['Entertainment'])
yp_crosstab
yp_crosstab.plot.barh()
|        | Agree | Disagree |
|--------|-------|----------|
| female |    81 |       84 |
| male   |    84 |       46 |

Python으로 설문 데이터 분석하기

파이썬으로 청년 소비 패턴 분석

survey = yp_survey.groupby(['Gender', 'Entertainment'])['Age'].count().reset_index()

survey.columns = ['Gender', 'Entertainment', 'Respondents'] survey
| Gender | Entertainment | Respondents |
|--------|---------------|-------------|
| female | Agree         |          81 |
| female | Disagree      |          84 |
| male   | Agree         |          84 |
| male   | Disagree      |          46 |
Python으로 설문 데이터 분석하기

파이썬으로 청년 소비 패턴 분석

survey['% total respondents'] = survey.Respondents * 100./survey.Respondents.sum()
survey['% of population'] = [35, 25, 20, 20]
survey['Weight'] = survey['% of population']/survey['% total respondents']
survey['Weighted Respondents'] = survey.Weight * survey.Respondents
Python으로 설문 데이터 분석하기

파이썬으로 청년 소비 패턴 분석

survey[['Gender','Entertainment',
        'Respondents','Weighted Respondents']].set_index(
  ['Gender','Entertainment']).plot.barh()

Python으로 설문 데이터 분석하기

Ayo berlatih!

Python으로 설문 데이터 분석하기

Preparing Video For Download...