Vous êtes sur la page 1sur 20

How We Chose

Our Senators
Reinabelle Reyes, Ph.D.
AdMU • 12 May 2017
Outline
• Senatorial Elections Dataset: 

COMELEC precinct-level election returns

• Q: Who were voted together? 



Market basket analysis

• Q: Which provinces voted similarly? 



User-collaborative filtering
Published on Stack PH (published by Voyager Innovations)
http://www.stack.com.ph/senators-market-basket-analysis/
The Dataset
• precinct-level election returns from NAMFREL
(downloaded from elections.org.ph)

• transmitted as of May 12, 2016, 3:45PM

• includes 90,357 precincts (~98% of total)

• columns include: precinct_code, contest_code,


candidate_name, party_code, votes, timestamp
Q: Which candidates were
voted together?

Senatorial
candidates

Items in your
supermarket
shopping cart

A: Do a market basket analysis


Market Basket Analysis
Concepts:

• Transaction — purchase of a set of items in a cart

• Association Rule — e.g., {item1} —> {item2, item3}

• Support — measure of how frequently an item appears

Measures of the significance of an association:

• Confidence

• Lift
Market Basket Analysis
Applied to Senatorial Candidates:

• The top 12 senatorial candidates make up the “cart” of


each precinct

• Association rules are combinations of candidates in


each cart: {candidate1} —> {candidate2, candidate3}

• Support is the fraction of precincts for which a


candidate is voted into the top 12
Market Basket Analysis
Applied to Senatorial Candidates:

• Get high-support candidates

• Get high-confidence candidate combinations:

• Confidence(X —> Y) = Support(X,Y) / Support(X)

• Get high-lift candidate combinations:

• Lift(X —> Y) = Confidence(X —> Y) / Support(Y)


High-support Candidates

Top
12
High-confidence Combos
High-lift Combos
Q: Which provinces voted
similarly?

% of Votes

No. of purchases
for an item

A: Run user-collaborative filtering


User-collaborative Filtering
Concepts:

• Customers who purchased similar products are similar

• Cosine Similarity

• sim = (u • v) / |u||v|

where u, v are vectors encoding the frequency of


purchases of items in a customer’s history
User-collaborative Filtering
Applied to Senatorial Candidates:

• Provinces who voted for similar candidates are similar

• Cosine Similarity

• sim = (u • v) / |u||v|

where u, v are vectors encoding the percentage of votes


for a given candidate in a province
User-collaborative Filtering
+
Clustering by Affinity
Propagation

Customer Voting
Segmentation Clusters
15 Voting Clusters
Q: How did
the different
clusters
vote?
Red: fewer votes
Blue: more votes
w/ z-score >= 0.5
How
Mindanao
voted

How
OFWs
voted

How
Pacquiao’s
hometown
voted
How
Mindanao
didn’t
vote

Who
didn’t
vote for
Pacquiao
#clap
Summary
• Precinct-level voting patterns

• identify combinations of senatorial candidates

• can also be applied to President-Vice President


combinations, local-national races, etc.

• Geographical voting patterns

• 15 province clusters (including OAV)

• can be applied at municipality and barangay levels (or


precinct-level if precinct map boundaries are available)

Vous aimerez peut-être aussi