Top Banner
Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities and Social Sciences 1
23

Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

Jun 20, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

Discovering Voting Patterns

Feb. 12, 2012

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 1

Page 2: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

Last Class (& HW1-2)

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 2

Redefine Problem

Find Data

Modify existing

instructions

Solution

Computer (Excel)

XML Format

Make HUGE Excel Table

Use Senator X’s votes to compare other senators

to them CSV Format

Votes on Bills Only

Page 3: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

Finish ACT1-3

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 3

Page 4: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

Finish ACT1-3

• The spreadsheet is now interactive

• But what if we want to look at how all senators rank compared to all others?

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 4

Page 5: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

This Class

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 5

Redefine Problem

Find Data

Modify existing

instructions

Solution

Computer (Excel)

XML Format

Make HUGE Excel Table

Rank all senators according to all others CSV Format

Votes on Bills Only

Page 6: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

We can do this in one table. How?

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 6

Here’s a Hint:

Page 7: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

We can do this in one table. How? Akaka Alexander Ayotte Barraso

Akaka

Alexander

Ayotte

Barrasso

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 7

Ayotte vs. Alexander

Page 8: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

We can do this in one table. How?

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 8

Ayotte vs. Alexander

Question: What values are on the diagonals?

Akaka Alexander Ayotte Barraso

Akaka

Alexander

Ayotte

Barrasso

Page 9: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

We can do this in one table. How?

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 9

Ayotte vs. Alexander

Question: What values are on the diagonals?

Akaka Alexander Ayotte Barraso

Akaka 1

Alexander 1

Ayotte 1

Barrasso 1

Page 10: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

We can do this in one table. How?

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 10

Ayotte vs. Alexander

Question: What values are on the diagonals?

Akaka Alexander Ayotte Barraso

Akaka 1 0.314285714 0.085714286 0.117647059

Alexander 0.314285714 1 0.657142857 0.647058824

Ayotte 0.085714286 0.657142857 1 0.764705882

Barrasso 0.117647059 0.647058824 0.764705882 1

Page 11: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

Akaka Alexander Ayotte Akaka 1 0.314285714 0.085714286 Alexander 0.314285714 1 0.657142857 Ayotte 0.085714286 0.657142857 1 Barrasso 0.117647059 0.647058824 0.764705882

Next Goal

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 11

Redefine Problem

Find Data

Modify existing

instructions

Solution

Computer (Excel)

XML Format

Make HUGE Excel Table

Rank all senators according to all others CSV Format

Votes on Bills Only

Page 12: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

Project 1

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 12

Due Dates Proposal: Th 2/14 Project: Th 2/21

Page 13: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

Next Goal

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 13

Redefine Problem

Find Data

Modify existing

instructions

Solution

Computer (Excel)

XML Format

Make HUGE Excel Table

Rank all senators according to all others CSV Format

Votes on Bills Only

Akaka Alexander Ayotte Akaka 1 0.314285714 0.085714286 Alexander 0.314285714 1 0.657142857 Ayotte 0.085714286 0.657142857 1 Barrasso 0.117647059 0.647058824 0.764705882

Page 14: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

Next Goal

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 14

1:101 1:115 1:129 1:138 Akaka Yea Yea Yea Yea Alexander Yea Yea Yea Yea Ayotte Nay Yea Yea Yea Barrasso Yea Yea Yea Yea

What We Have:

What We Want: Akaka Alexander Ayotte Barraso

Akaka 1 0.314285714 0.085714286 0.117647059

Alexander 0.314285714 1 0.657142857 0.647058824

Ayotte 0.085714286 0.657142857 1 0.764705882

Barrasso 0.117647059 0.647058824 0.764705882 1

Page 15: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

Next Goal

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 15

Akaka Alexander Ayotte Barrasso

Akaka 33 10 11 13 Alexander 10 32 32 30 Ayotte 11 32 33 31 Barrasso 13 30 31 33

Akaka Alexander Ayotte Barrasso

Akaka 33 32 33 33 Alexander 32 32 32 32 Ayotte 33 32 33 33 Barrasso 33 32 33 33

What We Have:

What We Want: num_agree – num_disagree num_agree + num_disagree

1:101 1:115 1:129 1:138 Akaka Yea Yea Yea Yea Alexander Yea Yea Yea Yea Ayotte Nay Yea Yea Yea Barrasso Yea Yea Yea Yea

Page 16: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

We Need a Few More Tools: ACT1-4

• Do Task 1

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 16

Page 17: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

We Need a Few More Tools: ACT1-4

• Do Task 1 • Do Task 2

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 17

Page 18: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

We Need a Few More Tools: ACT1-4

• Do Task 1 • Do Task 2

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 18

Wikipedia

Page 19: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

We Need a Few More Tools: ACT1-4

• Do Task 1 • Do Task 2 • Do Task 3

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 19

Page 20: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

How Can Matrix Multiplication Help?

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 20

Akaka Alexander Ayotte Barrasso

Akaka 33 10 11 13 Alexander 10 32 32 30 Ayotte 11 32 33 31 Barrasso 13 30 31 33

Akaka Alexander Ayotte Barrasso

Akaka 33 32 33 33 Alexander 32 32 32 32 Ayotte 33 32 33 33 Barrasso 33 32 33 33

What We Have:

What We Want: num_agree – num_disagree num_agree + num_disagree

1:101 1:115 1:129 1:138 Akaka Yea Yea Yea Yea Alexander Yea Yea Yea Yea Ayotte Nay Yea Yea Yea Barrasso Yea Yea Yea Yea

Page 21: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

How Can Matrix Multiplication Help?

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 21

Akaka Alexander Ayotte Barrasso

Akaka 33 10 11 13 Alexander 10 32 32 30 Ayotte 11 32 33 31 Barrasso 13 30 31 33

Akaka Alexander Ayotte Barrasso

Akaka 33 32 33 33 Alexander 32 32 32 32 Ayotte 33 32 33 33 Barrasso 33 32 33 33

What We Have:

What We Want: num_agree – num_disagree num_agree + num_disagree

1:101 1:115 1:129 1:138 Akaka 1 1 1 1 Alexander 1 1 1 1 Ayotte -1 1 1 1 Barrasso 1 1 1 1

Page 22: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

Steps in the Analysis

1. Create a formula that is 1 if a senator votes “Yea”, -1 if a senator votes “Nay”, and 0 otherwise.

2. Use MMULT() to create a Numerator sheet 3. Use MMULT() to create a Denominator

sheet 4. Make the final table

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 22

Page 23: Discovering Voting Patternscs.brown.edu/courses/csci0931/2013/1-voting/LEC1-5.pdf · 2013-02-12 · Discovering Voting Patterns Feb. 12, 2012 CS0931 - Intro. to Comp. for the Humanities

Next Class

CS0931 - Intro. to Comp. for the Humanities and Social Sciences 23

Redefine Problem

Find Data

Modify existing

instructions

Solution

Computer (Excel)

XML Format

Make HUGE Excel Table

Rank all senators according to all others CSV Format

Votes on Bills Only

Akaka Alexander Ayotte Akaka 1 0.314285714 0.085714286 Alexander 0.314285714 1 0.657142857 Ayotte 0.085714286 0.657142857 1 Barrasso 0.117647059 0.647058824 0.764705882