← 返回数据练习

用民调数据建模选民支持倾向,给选民名单打分,并向竞选团队说明

3 张表 · 2.1万 行畅练卡解锁

这道题的中文翻译正在进行中,下面先显示英文原文。

Civic Signal is a political analytics firm working for a Democratic campaign. A scientifically conducted survey asked 5,511 voters which candidate they support. The campaign wants a score for each person on a larger list: the probability that they support the Democratic candidate rather than the Republican.

The scores will be used at every level of the campaign, from the campaign manager deciding where to spend money to field organizers choosing which doors to knock on. There is no single best model; what matters is an appropriate model, sound reasoning about what the variables mean, and a clear account of what the scores can and cannot be used for.

The data

  • modeling_set — one row per survey respondent (5,511 rows). support = 1 if the respondent supports the Democratic candidate, 0 if the Republican. id is the respondent id.
  • scoring_set — one row per person to score (15,511 rows), with the same columns except support.
  • codebook — one row per column of the other two tables (variable, description). The 96 columns cover demographics, modeled ideology and income, past turnout and primary votes, household votes, consumer flags, census-area statistics, state_region and ethnicity.
    • earliest_reg_year is the year of earliest voter registration (dates were coarsened to years).
    • Some numeric-looking columns are stored as text, and there are missing values.

Your task

  1. Build a model that predicts support and score everyone in scoring_set. Describe the method you used and why it suits this problem, including the trade-off between accuracy and how easily campaign staff can understand it.
  2. Explain how you handled missing values and badly typed columns, and the assumptions behind those choices. Which variables did you transform or combine, and why?
  3. Describe the main predictors in your final model and how you decided what to include. Discuss variables you considered but excluded, including any that might leak the answer or would be unavailable or unreliable for the people being scored.
  4. Describe how you protected against overfitting and how you validated the scores (discrimination and calibration, and performance across subgroups such as state_region). Does scoring_set look like the survey sample? What validation would you run later if other data became available, for example election results or a new survey wave?
  5. Explain how the campaign manager and field organizers should interpret the scores. What does a score of 0.7 mean for one person, and for a list of a thousand people? How should the scores be used differently for persuasion and turnout work, and what are their limitations?
  6. If you had more time, what else would you do: which other variables would you ask for or construct, and which other model specifications would you try?

What to deliver

A memo (3–5 pages) for the campaign’s leadership, an educated but non-technical audience, covering the questions above with at least one chart that shows how well the model works or helps diagnose it. Also provide a table of scores keyed by id for every row of scoring_set, output that describes the final model (coefficients, a tree or a variable-importance chart), and annotated code that reproduces the scores.

All company names in this question are fictional.

数据预览

codebook前 5 行
variabledescription
ageAge in years
apparel_1Consumer apparel purchaser
bankcard_1Consumer bank card holder
boatownr_1Consumer boat owner
bookmusc_1Consumer book/music purchaser
modeling_set前 5 行 · 另有 72 列
density_sq_kmland_sq_kmwater_sq_kmchildcntconservativeliberalownrentincomedem_performance_pctpersuasion_pctturnout_pctagesexvote_g2008vote_g2010vote_g2012vote_p2004party_dvote_p2004party_rvote_p2006party_dvote_p2006party_rvote_p2008party_dvote_p2008party_rvote_p2009party_dvote_p2009party_r
67.583843.1316001080619500037NULL39.350F11100000000
637.99171.5392000780771500046.4NULL46.966F00100000000
3626.00490.2033001021049NULL90.2NULL21.825F10000000000
7999.0520.1013000780771500064.5NULL34.124M10100000000
44.221813.92630.3201080617500032.5NULL47.332F10100000000
scoring_set前 5 行 · 另有 71 列
density_sq_kmland_sq_kmwater_sq_kmchildcntconservativeliberalownrentincomedem_performance_pctpersuasion_pctturnout_pctagesexvote_g2008vote_g2010vote_g2012vote_p2004party_dvote_p2004party_rvote_p2006party_dvote_p2006party_rvote_p2008party_dvote_p2008party_rvote_p2009party_dvote_p2009party_r
459.75841.4181011020797500088.3NULL42.626F10100000000
44.59225.22320.02801280628500043.2NULL39.486F11100000000
67.583843.1316001080619500037NULL39.350F11100000000
5531.32730.2658000641251NULL54.8NULL32.252F10100000000
2925.83330.5339000640991500047NULL31.839F00000000000