Lấy mẫu có trọng số

Phân tích dữ liệu khảo sát bằng Python

EbunOluwa Andrew

Data Scientist

Lấy mẫu có trọng số là gì?

  • Xác suất không đều
  • Giúp nhà nghiên cứu sửa sai lệch khi thu thập dữ liệu

Cân công lý trên bàn, cân nặng, cân bằng

Phân tích dữ liệu khảo sát bằng Python

Biến thường dùng trong lấy mẫu có trọng số

  • Nhân khẩu học: giới, tuổi, nơi ở, học vấn
  • Tính khác biệt giữa người tham gia và không tham gia nghiên cứu

Gia đình, đường viền người ở các độ tuổi khác nhau

Phân tích dữ liệu khảo sát bằng Python

Cân theo ô (cell-based)

1 https://www.geopoll.com/blog/weighting-survey-data-raking-cell-weighting/
Phân tích dữ liệu khảo sát bằng Python

Cân theo ô (cell-based)

1 https://www.geopoll.com/blog/weighting-survey-data-raking-cell-weighting/
Phân tích dữ liệu khảo sát bằng Python

Cân theo ô (cell-based)

1 https://www.geopoll.com/blog/weighting-survey-data-raking-cell-weighting/
Phân tích dữ liệu khảo sát bằng Python

Cân theo ô (cell-based)

1 https://www.geopoll.com/blog/weighting-survey-data-raking-cell-weighting/
Phân tích dữ liệu khảo sát bằng Python

Phân tích chi tiêu thanh niên với 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      |
Phân tích dữ liệu khảo sát bằng Python

Phân tích chi tiêu thanh niên với 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 |

Phân tích dữ liệu khảo sát bằng Python

Phân tích chi tiêu thanh niên với 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 |
Phân tích dữ liệu khảo sát bằng Python

Phân tích chi tiêu thanh niên với 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
Phân tích dữ liệu khảo sát bằng Python

Phân tích chi tiêu thanh niên với Python

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

Phân tích dữ liệu khảo sát bằng Python

Ayo berlatih!

Phân tích dữ liệu khảo sát bằng Python

Preparing Video For Download...