Quantcast
Channel: r software hub
Viewing all articles
Browse latest Browse all 1015

Analyzing Golden State Warriors’ passing network using GraphFrames in Spark

$
0
0

By Yuki Katoh

Databricks recently announced GraphFrames, awesome Spark extension to implement graph processing using DataFrames.
I performed graph analysis and visualized beautiful ball movement network of Golden State Warriors using rich data provided by NBA.com’s stats

### Passes received & made

The league’s MVP Stephen Curry received the most passes and the team’s MVP Draymond Green provides the most passes.
We’ve seen most of the offense start with their pick & roll or Curry’s off-ball cuts with Green as a pass provider.

via GIPHY

inDegree
id inDegree
CurryStephen 3993
GreenDraymond 3123
ThompsonKlay 2276
LivingstonShaun 1925
IguodalaAndre 1814
BarnesHarrison 1241
BogutAndrew 1062
BarbosaLeandro 946
SpeightsMarreese 826
ClarkIan 692
RushBrandon 685
EzeliFestus 559
McAdooJames Michael 182
VarejaoAnderson 67
LooneyKevon 22
outDegree
id outDegree
GreenDraymond 3841
CurryStephen 3300
IguodalaAndre 1896
LivingstonShaun 1878
BogutAndrew 1660
ThompsonKlay 1460
BarnesHarrison 1300
SpeightsMarreese 795
RushBrandon 772
EzeliFestus 765
BarbosaLeandro 758
ClarkIan 597
McAdooJames Michael 261
VarejaoAnderson 94
LooneyKevon 36

Label Propagation

Label Propagation is an algorithm to find communities in a graph network.
The algorithm nicely classifies players into backcourt and frontcourt without providing label!

name label
Thompson, Klay 3
Barbosa, Leandro 3
Curry, Stephen 3
Clark, Ian 3
Livingston, Shaun 3
Rush, Brandon 7
Green, Draymond 7
Speights, Marreese 7
Bogut, Andrew 7
McAdoo, James Michael 7
Iguodala, Andre 7
Varejao, Anderson 7
Ezeli, Festus 7
Looney, Kevon 7
Barnes, Harrison 7

PageRank can detect important nodes (players in this case) in a network.
It’s no surprise that Stephen Curry, Draymond Green and Klay Thompson are the top three.
The algoritm detects Shaun Livingston and Andre Iguodala play key roles in the Warriors’ passing games.

name pagerank
Curry, Stephen 2.17
Green, Draymond 1.99
Thompson, Klay 1.34
Livingston, Shaun 1.29
Iguodala, Andre 1.21
Barnes, Harrison 0.86
Bogut, Andrew 0.77
Barbosa, Leandro 0.72
Speights, Marreese 0.66
Clark, Ian 0.59
Rush, Brandon 0.57
Ezeli, Festus 0.48
McAdoo, James Michael 0.27
Varejao, Anderson 0.19
Looney, Kevon 0.16
library(networkD3)

setwd('/Users/yuki/Documents/code_for_blog/gsw_passing_network')
passes read.csv("passes.csv")
groups read.csv("groups.csv")
size read.csv("size.csv")

passes$source as.numeric(as.factor(passes$PLAYER))-1
passes$target as.numeric(as.factor(passes$PASS_TO))-1
passes$PASS passes$PASS/50

groups$nodeid groups$name
groups$name as.numeric(as.factor(groups$name))-1
groups$group as.numeric(as.factor(groups$label))-1
nodes merge(groups,size[-1],by="id")
nodes$pagerank nodes$pagerank^2*100

forceNetwork(Links = passes,
Nodes = nodes,
Source = "source",
fontFamily = "Arial",
colourScale = JS("d3.scale.category10()"),
Target = "target",
Value = "PASS",
...read more

Source:: r-bloggers.com


Viewing all articles
Browse latest Browse all 1015

Trending Articles