network graph scullem

26
UP AND RUNNING WITH NETWORK GRAPHS Connections Sarah Cullem

Upload: sarah-cullem

Post on 23-Jan-2018

370 views

Category:

Data & Analytics


0 download

TRANSCRIPT

Page 1: Network graph scullem

UP AND RUNNING WITH NETWORK GRAPHS

Connections

Sarah Cullem

Page 2: Network graph scullem

Inspiration

Page 3: Network graph scullem

Node Edge

Systems of nodes and edges that form a

structured representation of connected things and

how they are related

What is a network graph?

Page 4: Network graph scullem

Node Edge

Edges can have weight that describes the strength of a

relationship

What is a network graph?

Page 5: Network graph scullem

Node Edge

Edges can be lines (undirected graphs) or

arrows (directed graphs)

What is a network graph?

Page 6: Network graph scullem

Node Edge

Nodes can vary in size based on the degree of

their relationships to other nodes

What is a network graph?

Page 7: Network graph scullem

Node Edge

Nodes can vary in color based on selected

attributes

What is a network graph?

Page 8: Network graph scullem

Network graphs allow you to visualize patterns in complex, multidimensional data

Who/what is the most central in the network?

How strong are the connections between nodes?

What is the shortest path between nodes?

Are there communities within the larger network?

How dense is the network?

Who/what is the most influential?

Page 9: Network graph scullem

Micro vs. MacroLevel

Static vs. TimeSeries

Social Semantic Geographic

One vs. ManyDimensions

Types of Relationships

Analytical Decisions

Page 10: Network graph scullem

Graph Type: DirectedNodes: Girls in a 1960s dormitoryEdges: 1st & 2nd choices when asked which other girls they liked best as their dining partners

http://www.slideshare.net/ValaAliRohani/social-network-analysis-part-1-40046689

Page 11: Network graph scullem

Graph Type: UndirectedNodes: Adverse drug reactions in instagram postsEdges: Co-occurrence of adverse reactions to drugs treating depression

http://psb.stanford.edu/psb-online/proceedings/psb16/brattigcorreia.pdf

Page 12: Network graph scullem

http://truthy.indiana.edu/highlights/

Social Butterflies or Frequent Fliers?Twitter trends follow similar patterns as epidemics, diffusing across the

country along the same pathways as human travelers

Page 13: Network graph scullem

And now for an example using the Congressional Voting Records dataset

https://archive.ics.uci.edu/ml/datasets/Congressional+Voting+Records

Page 14: Network graph scullem

Type: Undirected GraphNodes: Names of bills and party affiliationEdges: Every pairing of “yes” on bills or party affiliationWeight: # of times each bill-bill or bill- party pairing appears as “yes” together

Example 1: Which bills share common voters/parties?

Page 15: Network graph scullem

Education Religious Republican Democrat

Voter A Yes Yes Yes No

Voter B Not Yes Yes No YesVoter C Yes Not Yes Yes NoVoter D Not Yes Not Yes No Yes

Our initial dataset consists of each voter, their vote on each bill, and their party affiliation

Note: Using “Not Yes” for bills instead of “No” because data set contains cases of “?” where the vote was neither “yes” nor “no”

Page 16: Network graph scullem

Education Religious Republican Democrat

Voter A 1 1 1 0

Voter B 0 1 0 1Voter C 1 0 1 0Voter D 0 0 0 1

We recode all “Yes” votes to 1 and “No/Not Yes” votes to 0

Note: Using “Not Yes” for bills instead of “No” because data set contains cases of “?” where the vote was neither “yes” nor “no”

Page 17: Network graph scullem

Education Religious Republican Democrat

Voter A 1 1 1 0

Voter B 0 1 0 1Voter C 1 0 1 0Voter D 0 0 0 1

Nodes

Education

Religious

Republican

Democrat

Our nodes are the bill and party “tags” for each voter

Page 18: Network graph scullem

Edges Weights

Education, Religious

Education, Republican

Education, Democrat

Religious, Republican

Religious, Democrat

Republican, Democrat

Our edges are all possible “bill-bill” and “bill-party” combinations in the dataset

Education Religious Republican Democrat

Voter A 1 1 1 0

Voter B 0 1 0 1Voter C 1 0 1 0Voter D 0 0 0 1

Page 19: Network graph scullem

Edges Weights

Education, Religious

Education, Republican

Education, Democrat

Religious, Republican

Religious, Democrat

Republican, Democrat

Our weights are the number of times our

nodes/tags occur together

Education Religious Republican Democrat

Voter A 1 1 1 0

Voter B 0 1 0 1Voter C 1 0 1 0Voter D 0 0 0 1

Page 20: Network graph scullem

Education Religious Republican Democrat

Voter A 1 1 1 0

Voter B 0 1 0 1Voter C 1 0 1 0Voter D 0 0 0 1

Edges Weights

Education, Religious 1

Education, Republican 2

Education, Democrat 0

Religious, Republican 1

Religious, Democrat 1

Republican, Democrat 0

There is one case where a voter voted “yes” on

Education and on Religious

Page 21: Network graph scullem

Education Religious Republican Democrat

Voter A 1 1 1 0

Voter B 0 1 0 1Voter C 1 0 1 0Voter D 0 0 0 1

There are two cases where a voter was Republican and also

voted “yes” on Education

Edges Weights

Education, Religious 1

Education, Republican 2

Education, Democrat 0

Religious, Republican 1

Religious, Democrat 1

Republican, Democrat 0

Page 22: Network graph scullem

Which bills share common voters/parties?

Network graph created with open source tool Gephi: https://gephi.org/

Page 23: Network graph scullem

On average, 70% of democrats and 20%

of republicans voted yes

On average, 30% of democrats and 79%

of republicans voted yes

Network graph created with open source tool Gephi: https://gephi.org/

Page 24: Network graph scullem

Network graph created with open source tool Gephi: https://gephi.org/

56% of democrats and 56% of

republicans voted yes

20% of democrats and 89% of

republicans voted yes

72% of democrats and 14% of

republicans voted yes

Page 25: Network graph scullem

Do members of both parties vote together?

Network graph created with open source tool Gephi: https://gephi.org/

Page 26: Network graph scullem

• My GitHub repo: https://github.com/scullem/network_graphs• NetworkX python: https://networkx.github.io/• NetworkX tutorial: https://github.com/sarguido/networkx-tutorial• Gephi download: https://gephi.org/• Sebastien Heymann Exploratory Network Analysis with Gephi

Part 1: https://www.youtube.com/watch?v=Y7Ah6VylIak• Gephi guides: http://meta-guide.com/videography/100-best-gephi-

videos• Graph Analysis and Visualization: Discovering Business

Opportunity in Linked Data: http://www.amazon.com/Graph-Analysis-Visualization-Discovering-Opportunity-ebook/dp/B00T1JQUQE

Resources