Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering...

30
Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social Sciences 1

Transcript of Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering...

Page 1: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

Discovering Voting Patterns

Feb. 14, 2012

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

Page 2: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

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 how liberal other senators are

CSV Format

Votes on Bills Only

Page 3: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

Finish ACT1-3

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

Page 4: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

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/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

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/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

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/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

We can do this in one table. How?

Akaka Alexander Allard Allen

Akaka

Alexander

Allard

Allen

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

Allard vs. Alexander

Page 8: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

We can do this in one table. How?

Akaka Alexander Allard Allen

Akaka

Alexander

Allard

Allen

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

Allard vs. Alexander

Question: What values are on the diagonals?

Page 9: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

We can do this in one table. How?

Akaka Alexander Allard Allen

Akaka 1

Alexander 1

Allard 1

Allen 1

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

Allard vs. Alexander

Question: What values are on the diagonals?

Page 10: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

We can do this in one table. How?

Akaka Alexander Allard Allen

Akaka 1 0.3125 0.333333 0.393939

Alexander 0.3125 1 1 0.9375

Allard 0.333333 1 1 0.939394

Allen 0.393939 0.9375 0.939394 1

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

Allard vs. Alexander

Question: What values are on the diagonals?

Page 11: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

Akaka Alexander Allard Allen

Akaka 1 0.3125 0.333333 0.393939

Alexander 0.3125 1 1 0.9375

Allard 0.333333 1 1 0.939394

Allen 0.393939 0.9375 0.939394 1

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/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

Break

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

Page 13: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

Project 1

• NOTE: New Deadline for Project

Last Year’s Projects https://sites.google.com/site/theteapartyvotes11

https://sites.google.com/site/cs0931project1/

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

Due Dates Proposal: Th 2/16

Project: T 2/28

Page 14: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

Project 1

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

Due Dates Proposal: Th 2/16

Project: T 2/28

Page 15: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

Project 1

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

Due Dates Proposal: Th 2/16

Project: T 2/28

A final note about identifying trends…

http://xkcd.com/925/

Page 16: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

Akaka Alexander Allard Allen

Akaka 1 0.3125 0.333333 0.393939

Alexander 0.3125 1 1 0.9375

Allard 0.333333 1 1 0.939394

Allen 0.393939 0.9375 0.939394 1

Next Goal

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

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 17: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

Next Goal

Akaka Alexander Allard Allen

Akaka 1 0.3125 0.333333 0.393939

Alexander 0.3125 1 1 0.9375

Allard 0.333333 1 1 0.939394

Allen 0.393939 0.9375 0.939394 1

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

1:1 1:2 1:3 1:4

Akaka Yea Yea Nay Not Voting

Alexander Nay Yea Nay Nay

Allard Yea Not Voting Yea Yea

Allen Nay Nay Nay Nay

What We Have:

What We Want:

Page 18: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

Next Goal

Akaka Alexander Allard Allen

Akaka 1 0.3125 0.333333 0.393939

Alexander 0.3125 1 1 0.9375

Allard 0.333333 1 1 0.939394

Allen 0.393939 0.9375 0.939394 1

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

1:1 1:2 1:3 1:4

Akaka Yea Yea Nay Not Voting

Alexander Nay Yea Nay Nay

Allard Yea Not Voting Yea Yea

Allen Nay Nay Nay Nay

What We Have:

What We Want:

Page 19: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

Next Goal

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

Akaka Alexander Allard Allen

Akaka 33 10 11 13

Alexander 10 32 32 30

Allard 11 32 33 31

Allen 13 30 31 33

Akaka Alexander Allard Allen

Akaka 33 32 33 33

Alexander 32 32 32 32

Allard 33 32 33 33

Allen 33 32 33 33

1:1 1:2 1:3 1:4

Akaka Yea Yea Nay Not Voting

Alexander Nay Yea Nay Nay

Allard Yea Not Voting Yea Yea

Allen Nay Nay Nay Nay

What We Have:

What We Want: num_agree – num_disagree num_agree + num_disagree

Page 20: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

We Need a Few More Tools: ACT1-4

• Do Task 1

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

Page 21: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

We Need a Few More Tools: ACT1-4

• Do Task 1

• Do Task 2

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

Page 22: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

We Need a Few More Tools: ACT1-4

• Do Task 1

• Do Task 2

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

Wikipedia

Page 23: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

How Can Matrix Multiplication Help?

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

Akaka Alexander Allard Allen

Akaka 33 10 11 13

Alexander 10 32 32 30

Allard 11 32 33 31

Allen 13 30 31 33

Akaka Alexander Allard Allen

Akaka 33 32 33 33

Alexander 32 32 32 32

Allard 33 32 33 33

Allen 33 32 33 33

1:1 1:2 1:3 1:4

Akaka Yea Yea Nay Not Voting

Alexander Nay Yea Nay Nay

Allard Yea Not Voting Yea Yea

Allen Nay Nay Nay Nay

What We Have:

What We Want: num_agree – num_disagree num_agree + num_disagree

Page 24: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

How Can Matrix Multiplication Help?

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

Akaka Alexander Allard Allen

Akaka 33 10 11 13

Alexander 10 32 32 30

Allard 11 32 33 31

Allen 13 30 31 33

Akaka Alexander Allard Allen

Akaka 33 32 33 33

Alexander 32 32 32 32

Allard 33 32 33 33

Allen 33 32 33 33

1:1 1:2 1:3 1:4

Akaka 1 1 -1 0

Alexander -1 1 -1 -1

Allard 1 0 1 1

Allen -1 -1 -1 -1

What We Have:

What We Want: num_agree – num_disagree num_agree + num_disagree

Page 25: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

How Can Matrix Multiplication Help?

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

Akaka Alexander Allard Allen

Akaka 33 10 11 13

Alexander 10 32 32 30

Allard 11 32 33 31

Allen 13 30 31 33

Akaka Alexander Allard Allen

Akaka 33 32 33 33

Alexander 32 32 32 32

Allard 33 32 33 33

Allen 33 32 33 33

1:1 1:2 1:3 1:4

Akaka 1 1 -1 0

Alexander -1 1 -1 -1

Allard 1 0 1 1

Allen -1 -1 -1 -1

What We Have:

What We Want: num_agree – num_disagree num_agree + num_disagree

MMULT(Akaka’s Row, TRANSPOSE(Alexander’s Row))

Page 26: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

How Can Matrix Multiplication Help?

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

Akaka Alexander Allard Allen

Akaka 33 10 11 13

Alexander 10 32 32 30

Allard 11 32 33 31

Allen 13 30 31 33

Akaka Alexander Allard Allen

Akaka 33 32 33 33

Alexander 32 32 32 32

Allard 33 32 33 33

Allen 33 32 33 33

1:1 1:2 1:3 1:4

Akaka 1 1 -1 0

Alexander -1 1 -1 -1

Allard 1 0 1 1

Allen -1 -1 -1 -1

What We Have:

What We Want: num_agree – num_disagree num_agree + num_disagree

MMULT(Akaka’s Row, TRANSPOSE(Alexander’s Row))

?

Page 27: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

How Can Matrix Multiplication Help?

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

Akaka Alexander Allard Allen

Akaka 33 10 11 13

Alexander 10 32 32 30

Allard 11 32 33 31

Allen 13 30 31 33

Akaka Alexander Allard Allen

Akaka 33 32 33 33

Alexander 32 32 32 32

Allard 33 32 33 33

Allen 33 32 33 33

1:1 1:2 1:3 1:4

Akaka 1 1 -1 0

Alexander -1 1 -1 -1

Allard 1 0 1 1

Allen -1 -1 -1 -1

What We Have:

What We Want: num_agree – num_disagree num_agree + num_disagree

MMULT(Akaka’s Row, TRANSPOSE(Alexander’s Row))

MMULT(ABS(Akaka’s Row), TRANSPOSE(ABS(Alexander’s Row)))

Page 28: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

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 28

Page 29: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

Akaka Alexander Allard Allen

Akaka 1 0.3125 0.333333 0.393939

Alexander 0.3125 1 1 0.9375

Allard 0.333333 1 1 0.939394

Allen 0.393939 0.9375 0.939394 1

Next Class

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

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 30: Discovering Voting Patternscs.brown.edu/courses/cs0931/2012/lectures/LEC1-6.pdf · Discovering Voting Patterns Feb. 14, 2012 CS0931 - Intro. to Comp. for the Humanities and Social

Reminders

• Proposals due Thursday 2/16

• Degree of Difficulty & comments back by Tuesday 2/21

• Long Weekend: No Class on Tues 2/21

• Final Projects due the following Tuesday 2/28

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

Sun Mon Tues Wed Thurs Fri Sat

2/12 2/13 2/14 2/15 2/16 2/17 2/18

Today Finish Voting Proposal Due

2/19 2/20 2/21 2/22 2/23 2/24 2/25

No Class Comments & Code Back

Start Textual Analysis HW2-1 Out

2/26 2/27 2/28 2/29 3/1 3/2 3/3

Project 1 Due HW2-1 Due