SlideShare una empresa de Scribd logo
1 de 37
Descargar para leer sin conexión
SOCIAL NETWORK ANALYSIS WITH R
David Chiu @ 中興大學
ABOUT ME
Co-founder of NumerInfo
Trend Micro Engineer
ywchiu-tw.appspot.com
AGENDA
What is Social Network?
Why to Analyze Social Network?
How to Analyze
Social Network Connection (Oauth, Oauth2, OpenID)
Social Network Analysis With R
Social Network Visualization (Gephi)
Facebook Post Liked Analysis
Conclusion
SOCIAL NETWORK

http://libeltyseo.com/wp-content/uploads/2013/03/social-networking.png
HUMAN NATURE

http://cdn.macado.com/assets/2010/03/peeping-tom.gif
WHAT DO WE WANT TO KNOW?
Who knows whom, and which people are common to their
social networks?
How frequently are particular people communicating with one
another?
Which social network connections generate the most value for
a particular niche?
How does geography affect your social connections in an
online world?
Who are the most influential/popular people in a social
network?
What are people chatting about (and is it valuable)?
What are people interested in based upon the human language
that they use in a digital world?
EXPLORE FACEBOOK
LESSON 1: CONNECT TO SOCIAL NETWORK
OAuth Flow
Oauth v.s. OAuth2
OpenID
OAUTH FLOW
Open standard for authorization. OAuth provides a method for
clients to access server resources on behalf of a resource owner
DIFFERENCE BETWEEN OAUTH AND OAUTH2
More OAuth Flows to allow better support for non-browser
based applications
OAuth 2.0 no longer requires client applications to have
cryptography
OAuth 2.0 signatures are much less complicated
OAuth 2.0 Access tokens are "short-lived"
OAuth 2.0 is meant to have a clean separation of roles
between the server responsible for handling OAuth requests
and the server handling user authorization
OPENID
Open standard that allows users to be authenticated by certain
co-operating sites
CONNECT TO FACEBOOK

https://developers.facebook.com/
GET ACCESS TOKEN

https://developers.facebook.com/tools/explorer/
USER PERMISSION
PERMISSION LIST
User Data Permissions:
user_hometown
user_location
user_interests
user_likes
user_relationships
Friends Data Permissions:
friends_hometown
friends_location
friends_interests
friends_likes
friends_relationships
Extended Permissions:
read_friendlists
COPY TOKEN
LESSON 2: SOCIAL NETWORK ANALYSIS WITH
R
Let's Hack
REQUIRED PACKAGES
RCurl
General network (HTTP/FTP/...) client interface for R
rjson
JSON for R
XML
Tools for parsing and generating XML within R and S-Plus
igraph
Network analysis and visualization
bitops
Bitwise Operations
REQUIRED PACKAGE
i sa lp ca e( ( rs n,Ru l ,X L, ir p'' io s) dp ne c e= RE
n tl . ak gs c' jo ''C r' 'M ' ' g ah,b tp ' ,e ed ni sT U)
l ba yr sn
i rr ( jo )
l ba yR ul
i rr ( Cr )
l ba yX L
i rr ( M)
l ba yi rp )
i rr ( ga h
l ba yb tp )
i rr ( io s
FACEBOOK CONNECT

f _o nc < f nt o ( p t = " e, ac s_ oe = tk n ot os {
b cn e t - u c in a h
m" ce s tk n
o e, p in )
i ( !i sn (p i n) )
f m si go to s {
o to s< s rn f "% " ps e nm s o to s ,"" ul s( pi n) c la s ="
p i n - p i t( ?s, a t( ae ( pi n) =, ni to t os , ol pe
&
o to s< g u( ,, "2 " o to s
p i n - s b "" %C, p in )
u l< s rn f "t p: / r p .a eo kc m% % &c es tk n % " pt , ot os a c
r - p it ( ht s /g ah fc bo . o/ssac s _o e= s, a h pi n , c
}e s {
le
u l< s rn f "t p: / r p .a eo kc m% ? ce st kn %" p t, a cs _o e )
r - p it ( ht s /g ah fc bo . o/sa cs _ oe=s , ah c es t kn
}
dt < gt R ( u l s l vr fp e =F LE )
aa - e UL r , s. ei y er
AS
fo JO (d t )
rm S N aa
}
TEST ON API EXPLORER
EXECUTED RESULT
> f_ on c( m" a cs _o e)
bc n et "e ,c es t kn
$d
i
[ ]" 72 48 "
1 7 8 28 9
$ ae
nm
[ ]" ai C i"
1 Dvd hu
$ is _a e
f rt n m
[ ]" ai "
1 Dvd
$ at nm
l s_ a e
[ ]" hu
1 Ci"
$ ik
ln
[ ]" tp :/ w. a eo kc mC i Y"
1 h t s/ ww fc bo . o/ hu W
$ sr ae
u en m
[ ]" hu W
1 C i Y"
GET FRIEND LIST
> fi ns < f_ on c (a h" ef in s,a cs _o e=c es tk n
re d - bc n et pt =m / re d" c es t kn ac s_ oe )
> fi ns
re d
GET FRIEND GROUP LIST
f in go p < f _ on c( pt = m/ re di t" a cs _ oe =c es tk n
r ed r us - bc ne t a h" ef in l ss, ce st kn ac s _o e)
f in go p. d < sp l (r ed ru s d t,f nt o()xi)
r ed r us i
- a py fi n go p$ aa u c inx $d
f in go p. ae < sp l (r ed ru s d t,f nt o()xn m)
r ed r us nm - a py fi n go p$ aa u c inx $a e
FACEBOOK ELEMENT EXTRACTOR

# Gt Fi ns If r ai nF o F
e r ed n om to rm B
m < f_ on c( a h" e, ac s _o e= ce st k n o t osls (f ed ""d nm ,o
e - b cn et pt =m " c es tk na c s_ oe , pi n=it " il s=i, a el c
m nm < m$ ae
y ae - e nm
f in s< m $r ed
r ed - e fi n s
# Et at Fc bo I s
xr c a eo k D
f in si < sp l (r ed $a a fn to ( )x i)
r ed . d - a py fi n sd t , u ci nx $ d

# Et at F Mt I fr ai n
xr c B ea n om t o
f in sn m < u l s( ap yf i ns dt ,f nt o () i ov xn m , o' T 8, u= " )
r ed . ae - ni ts p l( re d$ aa uc in x
c n( $a e t= UF 's b " ) )
f in sg ne < s pl (r ed $ aa fn t o( )u ls ( fi . u l x gn e ) " o e e
r ed . ed r - a py f in sd t, u ci nx ni ti (s nl ( $e dr ) nn " l
f in sl ct o. d < u l s( ap yf in s dt,f nt o () xl ct o$ d )
r ed . oa in i - ni ts p l( re d$ aa uc in x $o a in i)
f in sl ct o. a e< u ls (a py fi n sd t , fn t o( ){ f( s n l ( $ oa in
r ed . oa in nm - n it s pl (r ed $a a u ci nx i i. ulxl c to$
f in sh mt w. a e< u ls (a py fi n sd t , fn t o( ){ f( s n l ( $ oe on
r ed . oe on nm - n it s pl (r ed $a a u ci nx i i. ulxh m tw$
GET FRIENDSHIP MATRIX

f in si s< f nt o( {
r ed h p - u c in )
pi t" ee ai g fi ns i mt i"
rn ( Gn rt n re d hp a rx)
N< l nt (r ed .d
- e gh fi n si )
fi ns i. ar x < m t i(,, )
re d hp mt i - ar x0N N
fr ( i 1N {
o i n :)
p it ps ei f in sn m[ ] )
r n (a t( ,r ed . ae i)
t p< f cb o( pt = at (m /u ul r ed " fi nsi [ ] sp"" , ac s _o e
m - a e o k a h p s e " e m t a f i n s , r e d . d i , e =/ )
c es tk
m ta fi ns < sp l (m $a a fn to () xi)
u u lr ed - a py tp d t, uc i nx $d
f in si .a r xi fi ns i %n m ta fi n s < 1
r e dh pm ti [, r ed .d i % u u lr ed ] }
#C et c ne to sw t m fi ns
r a e o nc i n ih y r ed
fi ns cn < c1N
re d _o - ( :)
fi ns cn ]< 1
re d _o [ #A dt i vc o a a c lm t te fi n si m ti
d hs et r s
o un o h r ed hp a rx
fi ns i. ar x < c i df in si .a r xf in sc n
re d hp mt i - bn (r e dh pm ti ,r e d_ o)
#A pn m fi n si w t m s l
p e d y r ed hp i h ye f
fi ns i. ar x < r i df in si .a r xa pn (r e d_ o, )
re d hp mt i - bn (r e dh pm ti ,p e df in sc n 0 )
rw ae (r ed h pm ti )< a pn (r e d. aemn m )
on m sf in si .a r x - pe df in sn m,y ae
cl ae (r ed h pm ti )< a pn (r e d. aemn m )
on m sf in si .a r x - pe df in sn m,y ae
rt r (r ed hpmt i )
eu n fi ns i.a rx
}
FRIEND GRAPH

f in ga h< f nt o( r ed hpmt i ) {
r ed r p - u c in fi ns i.a rx
f i n s i . r p < g a h a j c n y f i n s i . a r x m d = (u d r c e " , w i h e =
re d hp ga h - r p.d ae c ( re d hp mt i, o ec"n i et d) e g tdN
Vf in si .r p )g ne < a pn (r ed .e d r m s l$ ed r
(r e dh pg ah $e d r - p ed fi n sg ne , ye fg ne )
V f i n s i . r p ) l c t o < a p n ( r e d . o a i nn m , m s l $ o a i n n m )
(r e dh pg ah $o a in - pe df i ns lc to . ae y ef lc t o$ ae
V f i n s i . r p ) h m t w < a p n ( r e d . o e o nn m , m s l $ o e o n n m )
(r e dh pg ah $o e on - pe df i ns hm tw . ae y ef hm t w$ ae
Vf in si .r p )L bl < Vf in si . rp )n m
(r e dh pg ah $a e - ( re dh pg ah $ ae
rt r ( re dh p ga h
eu n fi ns i. rp )
}
DRAW FRIENDSHIP GRAPH
f mt i < f in s is )
_ ar x - re dh p(
f ga h< f in ga hf m ti)
_ rp - r ed r p( _a rx
w ie ga hf ga h "r e d. rp m" fr a =g ah l )
r t. r p ( _r p, f in sg a hl ,o mt "r p m"
GRAPH XML FORAMT (GRAPHML)
LESSON 3: SOCIAL NETWORK VISUALIZATION
Using Gephi
GEPHI
Gephi, an open source graph visualization and manipulation
software
MODULARITY
Measure of the structure of networks or graphs. It was
designed to measure the strength of division of a network into
modules
Networks with high modularity have dense connections
between the nodes within modules but sparse connections
between nodes in different modules
LEARN MORE ABOUT GEPHI
https://www.udemy.com/gephi/
GET LIKES COUNT OF POSTS

r qi ep y)
e ur ( lr
p ss < f_ on c( ah " ep ss ,a cs _ oe =c es t kn ot o sl s( fe d "" i
o t - bc ne t pt =m /o t " ce st kn a cs _o e, p in =i t "i ls =l
p s. ie < sp l (o t$ aa f nt o( ) xl ks
o tl k s - a py ps s dt , uc in x $i e )
p s. ie .a a< s pl ( ot lk s fn to () x dt )
o tl k sd t - ap yp s. i e, uc i nx $ aa
l =l s (
i
it )
f r( i 1l nt ( ot lk sd t ){
o i n : eg hp s. i e. aa )
fr ( i 1(e g hp s. ie . aa [])1)
o j n :l nt (o t lk sd t [ i]- ){
l < a p n ( i p s . i e . a a [ ] [ j ]n m )
i - p ed l, o tl ks d t[ i] []$a e
}
}
d =d. al ri dd t. r m, l)
f
oc l( bn . aa fa e i
c la e( f < c " ae )
o nm s d) - (n m"
d py d, .n m) s ma i e N m us =l nt (a e )
d l( f ( ae , um rz , uS b
e g hn m)
CONCLUSION REMARK
Interesting Fact Abour Friends
Value Behind The Network
Statstic Is Worth More Than Thousand of Words
YOUR TURN TO DO SOME ANALYSIS
Find Popular Checkins Among Your Friends
Common Interest Between Your Friends
Female/Male Distribution of Your Know Friends
Most Pupular Photos Being Liked
Asociation Rule of Friends (Gossip)
THANK YOU

Más contenido relacionado

La actualidad más candente

Piotr Szotkowski about "Ruby smells"
Piotr Szotkowski about "Ruby smells"Piotr Szotkowski about "Ruby smells"
Piotr Szotkowski about "Ruby smells"Pivorak MeetUp
 
Evolving the Android Core with Aspects
Evolving the Android Core with AspectsEvolving the Android Core with Aspects
Evolving the Android Core with AspectsCarlo Pescio
 
PostgreSQL Day italy 2016 Unit Test
PostgreSQL Day italy 2016 Unit TestPostgreSQL Day italy 2016 Unit Test
PostgreSQL Day italy 2016 Unit TestAndrea Adami
 
穏やかにファイルを削除する
穏やかにファイルを削除する穏やかにファイルを削除する
穏やかにファイルを削除する鉄次 尾形
 
Profiling Web Archives IIPC GA 2015
Profiling Web Archives IIPC GA 2015Profiling Web Archives IIPC GA 2015
Profiling Web Archives IIPC GA 2015Sawood Alam
 
Vim your Python, Python your Vim
Vim your Python, Python your VimVim your Python, Python your Vim
Vim your Python, Python your VimMiroslav Šedivý
 
Додаток 3
Додаток 3Додаток 3
Додаток 3ymcmb_ua
 
Modeling avengers – open source technology mix for saving the world
Modeling avengers – open source technology mix for saving the worldModeling avengers – open source technology mix for saving the world
Modeling avengers – open source technology mix for saving the worldCédric Brun
 
Demystifying Unicode - Longhorn PHP 2021
Demystifying Unicode - Longhorn PHP 2021Demystifying Unicode - Longhorn PHP 2021
Demystifying Unicode - Longhorn PHP 2021Colin O'Dell
 
Modeling avengers – open source technology mix for saving the world econ fr
Modeling avengers – open source technology mix for saving the world econ frModeling avengers – open source technology mix for saving the world econ fr
Modeling avengers – open source technology mix for saving the world econ frCédric Brun
 
SecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play FrameworkSecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play Frameworkjaliss
 
Petunjuk pengisian lhkpn model a
Petunjuk pengisian lhkpn model aPetunjuk pengisian lhkpn model a
Petunjuk pengisian lhkpn model aGolden Saragih
 
Breathe life into your designer!
Breathe life into your designer!Breathe life into your designer!
Breathe life into your designer!Cédric Brun
 

La actualidad más candente (14)

Piotr Szotkowski about "Ruby smells"
Piotr Szotkowski about "Ruby smells"Piotr Szotkowski about "Ruby smells"
Piotr Szotkowski about "Ruby smells"
 
Evolving the Android Core with Aspects
Evolving the Android Core with AspectsEvolving the Android Core with Aspects
Evolving the Android Core with Aspects
 
PostgreSQL Day italy 2016 Unit Test
PostgreSQL Day italy 2016 Unit TestPostgreSQL Day italy 2016 Unit Test
PostgreSQL Day italy 2016 Unit Test
 
穏やかにファイルを削除する
穏やかにファイルを削除する穏やかにファイルを削除する
穏やかにファイルを削除する
 
Profiling Web Archives IIPC GA 2015
Profiling Web Archives IIPC GA 2015Profiling Web Archives IIPC GA 2015
Profiling Web Archives IIPC GA 2015
 
Vim your Python, Python your Vim
Vim your Python, Python your VimVim your Python, Python your Vim
Vim your Python, Python your Vim
 
Додаток 3
Додаток 3Додаток 3
Додаток 3
 
Modeling avengers – open source technology mix for saving the world
Modeling avengers – open source technology mix for saving the worldModeling avengers – open source technology mix for saving the world
Modeling avengers – open source technology mix for saving the world
 
Demystifying Unicode - Longhorn PHP 2021
Demystifying Unicode - Longhorn PHP 2021Demystifying Unicode - Longhorn PHP 2021
Demystifying Unicode - Longhorn PHP 2021
 
Modeling avengers – open source technology mix for saving the world econ fr
Modeling avengers – open source technology mix for saving the world econ frModeling avengers – open source technology mix for saving the world econ fr
Modeling avengers – open source technology mix for saving the world econ fr
 
SecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play FrameworkSecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play Framework
 
Petunjuk pengisian lhkpn model a
Petunjuk pengisian lhkpn model aPetunjuk pengisian lhkpn model a
Petunjuk pengisian lhkpn model a
 
TicsDzm
TicsDzmTicsDzm
TicsDzm
 
Breathe life into your designer!
Breathe life into your designer!Breathe life into your designer!
Breathe life into your designer!
 

Similar a Social Network Analysis With R

Using Phing for Fun and Profit
Using Phing for Fun and ProfitUsing Phing for Fun and Profit
Using Phing for Fun and ProfitNicholas Jansma
 
Testing Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax ExamTesting Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax ExamHenryk Konsek
 
Piotr Szotkowski about "Bits of ruby"
Piotr Szotkowski about "Bits of ruby"Piotr Szotkowski about "Bits of ruby"
Piotr Szotkowski about "Bits of ruby"Pivorak MeetUp
 
From simple to more advanced: Lessons learned in 13 months with Tableau
From simple to more advanced: Lessons learned in 13 months with TableauFrom simple to more advanced: Lessons learned in 13 months with Tableau
From simple to more advanced: Lessons learned in 13 months with TableauSergii Khomenko
 
Frontend architecture on big and small sites
Frontend architecture on big and small sitesFrontend architecture on big and small sites
Frontend architecture on big and small sitesToni Pinel
 
Create Custom Post Type Plugin
Create Custom Post Type PluginCreate Custom Post Type Plugin
Create Custom Post Type PluginJan Wilson
 
IPC13 Munich: Planning the Unplannable
IPC13 Munich: Planning the UnplannableIPC13 Munich: Planning the Unplannable
IPC13 Munich: Planning the UnplannableRobert Lemke
 
WordPress in 30 minutes
WordPress in 30 minutesWordPress in 30 minutes
WordPress in 30 minutesOwen Winkler
 
Escalas hglvf set 2015
Escalas hglvf set 2015Escalas hglvf set 2015
Escalas hglvf set 2015Fred Oliveira
 
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet Pôle Systematic Paris-Region
 
Spring Roo 2.0 Preview at Spring I/O 2016
Spring Roo 2.0 Preview at Spring I/O 2016 Spring Roo 2.0 Preview at Spring I/O 2016
Spring Roo 2.0 Preview at Spring I/O 2016 DISID
 
Spring scala - Sneaking Scala into your corporation
Spring scala  - Sneaking Scala into your corporationSpring scala  - Sneaking Scala into your corporation
Spring scala - Sneaking Scala into your corporationHenryk Konsek
 
SC4 Workshop 1: Helena Gellerman: data analyses in transport
SC4 Workshop 1: Helena Gellerman: data analyses in transport SC4 Workshop 1: Helena Gellerman: data analyses in transport
SC4 Workshop 1: Helena Gellerman: data analyses in transport BigData_Europe
 
Certificates
CertificatesCertificates
CertificatesJeff CHen
 
Accessible Web Components_Techshare India 2014
Accessible Web Components_Techshare India 2014Accessible Web Components_Techshare India 2014
Accessible Web Components_Techshare India 2014BarrierBreak
 

Similar a Social Network Analysis With R (20)

Using Phing for Fun and Profit
Using Phing for Fun and ProfitUsing Phing for Fun and Profit
Using Phing for Fun and Profit
 
Testing Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax ExamTesting Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax Exam
 
Piotr Szotkowski about "Bits of ruby"
Piotr Szotkowski about "Bits of ruby"Piotr Szotkowski about "Bits of ruby"
Piotr Szotkowski about "Bits of ruby"
 
From simple to more advanced: Lessons learned in 13 months with Tableau
From simple to more advanced: Lessons learned in 13 months with TableauFrom simple to more advanced: Lessons learned in 13 months with Tableau
From simple to more advanced: Lessons learned in 13 months with Tableau
 
Geb for browser automation
Geb for browser automationGeb for browser automation
Geb for browser automation
 
Frontend architecture on big and small sites
Frontend architecture on big and small sitesFrontend architecture on big and small sites
Frontend architecture on big and small sites
 
Create Custom Post Type Plugin
Create Custom Post Type PluginCreate Custom Post Type Plugin
Create Custom Post Type Plugin
 
IPC13 Munich: Planning the Unplannable
IPC13 Munich: Planning the UnplannableIPC13 Munich: Planning the Unplannable
IPC13 Munich: Planning the Unplannable
 
WordPress in 30 minutes
WordPress in 30 minutesWordPress in 30 minutes
WordPress in 30 minutes
 
Escalas hglvf set 2015
Escalas hglvf set 2015Escalas hglvf set 2015
Escalas hglvf set 2015
 
JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
 
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
 
Spring Roo 2.0 Preview at Spring I/O 2016
Spring Roo 2.0 Preview at Spring I/O 2016 Spring Roo 2.0 Preview at Spring I/O 2016
Spring Roo 2.0 Preview at Spring I/O 2016
 
Spring scala - Sneaking Scala into your corporation
Spring scala  - Sneaking Scala into your corporationSpring scala  - Sneaking Scala into your corporation
Spring scala - Sneaking Scala into your corporation
 
SC4 Workshop 1: Helena Gellerman: data analyses in transport
SC4 Workshop 1: Helena Gellerman: data analyses in transport SC4 Workshop 1: Helena Gellerman: data analyses in transport
SC4 Workshop 1: Helena Gellerman: data analyses in transport
 
kidaagacertificates
kidaagacertificateskidaagacertificates
kidaagacertificates
 
Certificates
CertificatesCertificates
Certificates
 
Winload.efi.mui
Winload.efi.muiWinload.efi.mui
Winload.efi.mui
 
Accessible Web Components_Techshare India 2014
Accessible Web Components_Techshare India 2014Accessible Web Components_Techshare India 2014
Accessible Web Components_Techshare India 2014
 
Fast api
Fast apiFast api
Fast api
 

Más de David Chiu

無中生有 - 利用外部數據打造新商業模式
無中生有 - 利用外部數據打造新商業模式無中生有 - 利用外部數據打造新商業模式
無中生有 - 利用外部數據打造新商業模式David Chiu
 
洞見未來,用python 與 r 結合深度學習技術預測趨勢
洞見未來,用python 與 r 結合深度學習技術預測趨勢洞見未來,用python 與 r 結合深度學習技術預測趨勢
洞見未來,用python 與 r 結合深度學習技術預測趨勢David Chiu
 
python 實戰資料科學工作坊
python 實戰資料科學工作坊python 實戰資料科學工作坊
python 實戰資料科學工作坊David Chiu
 
新聞 X 謊言 用文字探勘挖掘財經新聞沒告訴你的真相(丘祐瑋)
新聞 X 謊言 用文字探勘挖掘財經新聞沒告訴你的真相(丘祐瑋)新聞 X 謊言 用文字探勘挖掘財經新聞沒告訴你的真相(丘祐瑋)
新聞 X 謊言 用文字探勘挖掘財經新聞沒告訴你的真相(丘祐瑋)David Chiu
 
Data Analysis - Making Big Data Work
Data Analysis - Making Big Data WorkData Analysis - Making Big Data Work
Data Analysis - Making Big Data WorkDavid Chiu
 
PyCon APAC 2014 - Social Network Analysis Using Python (David Chiu)
PyCon APAC 2014 - Social Network Analysis Using Python (David Chiu)PyCon APAC 2014 - Social Network Analysis Using Python (David Chiu)
PyCon APAC 2014 - Social Network Analysis Using Python (David Chiu)David Chiu
 
Big Data Analysis With RHadoop
Big Data Analysis With RHadoopBig Data Analysis With RHadoop
Big Data Analysis With RHadoopDavid Chiu
 
Machine Learning With R
Machine Learning With RMachine Learning With R
Machine Learning With RDavid Chiu
 
R language tutorial
R language tutorialR language tutorial
R language tutorialDavid Chiu
 
Hidden Markov Model & Stock Prediction
Hidden Markov Model & Stock PredictionHidden Markov Model & Stock Prediction
Hidden Markov Model & Stock PredictionDavid Chiu
 

Más de David Chiu (10)

無中生有 - 利用外部數據打造新商業模式
無中生有 - 利用外部數據打造新商業模式無中生有 - 利用外部數據打造新商業模式
無中生有 - 利用外部數據打造新商業模式
 
洞見未來,用python 與 r 結合深度學習技術預測趨勢
洞見未來,用python 與 r 結合深度學習技術預測趨勢洞見未來,用python 與 r 結合深度學習技術預測趨勢
洞見未來,用python 與 r 結合深度學習技術預測趨勢
 
python 實戰資料科學工作坊
python 實戰資料科學工作坊python 實戰資料科學工作坊
python 實戰資料科學工作坊
 
新聞 X 謊言 用文字探勘挖掘財經新聞沒告訴你的真相(丘祐瑋)
新聞 X 謊言 用文字探勘挖掘財經新聞沒告訴你的真相(丘祐瑋)新聞 X 謊言 用文字探勘挖掘財經新聞沒告訴你的真相(丘祐瑋)
新聞 X 謊言 用文字探勘挖掘財經新聞沒告訴你的真相(丘祐瑋)
 
Data Analysis - Making Big Data Work
Data Analysis - Making Big Data WorkData Analysis - Making Big Data Work
Data Analysis - Making Big Data Work
 
PyCon APAC 2014 - Social Network Analysis Using Python (David Chiu)
PyCon APAC 2014 - Social Network Analysis Using Python (David Chiu)PyCon APAC 2014 - Social Network Analysis Using Python (David Chiu)
PyCon APAC 2014 - Social Network Analysis Using Python (David Chiu)
 
Big Data Analysis With RHadoop
Big Data Analysis With RHadoopBig Data Analysis With RHadoop
Big Data Analysis With RHadoop
 
Machine Learning With R
Machine Learning With RMachine Learning With R
Machine Learning With R
 
R language tutorial
R language tutorialR language tutorial
R language tutorial
 
Hidden Markov Model & Stock Prediction
Hidden Markov Model & Stock PredictionHidden Markov Model & Stock Prediction
Hidden Markov Model & Stock Prediction
 

Último

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Último (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

Social Network Analysis With R

  • 1. SOCIAL NETWORK ANALYSIS WITH R David Chiu @ 中興大學
  • 2. ABOUT ME Co-founder of NumerInfo Trend Micro Engineer ywchiu-tw.appspot.com
  • 3. AGENDA What is Social Network? Why to Analyze Social Network? How to Analyze Social Network Connection (Oauth, Oauth2, OpenID) Social Network Analysis With R Social Network Visualization (Gephi) Facebook Post Liked Analysis Conclusion
  • 6. WHAT DO WE WANT TO KNOW? Who knows whom, and which people are common to their social networks? How frequently are particular people communicating with one another? Which social network connections generate the most value for a particular niche? How does geography affect your social connections in an online world? Who are the most influential/popular people in a social network? What are people chatting about (and is it valuable)? What are people interested in based upon the human language that they use in a digital world?
  • 8. LESSON 1: CONNECT TO SOCIAL NETWORK OAuth Flow Oauth v.s. OAuth2 OpenID
  • 9. OAUTH FLOW Open standard for authorization. OAuth provides a method for clients to access server resources on behalf of a resource owner
  • 10. DIFFERENCE BETWEEN OAUTH AND OAUTH2 More OAuth Flows to allow better support for non-browser based applications OAuth 2.0 no longer requires client applications to have cryptography OAuth 2.0 signatures are much less complicated OAuth 2.0 Access tokens are "short-lived" OAuth 2.0 is meant to have a clean separation of roles between the server responsible for handling OAuth requests and the server handling user authorization
  • 11. OPENID Open standard that allows users to be authenticated by certain co-operating sites
  • 15. PERMISSION LIST User Data Permissions: user_hometown user_location user_interests user_likes user_relationships Friends Data Permissions: friends_hometown friends_location friends_interests friends_likes friends_relationships Extended Permissions: read_friendlists
  • 17. LESSON 2: SOCIAL NETWORK ANALYSIS WITH R Let's Hack
  • 18. REQUIRED PACKAGES RCurl General network (HTTP/FTP/...) client interface for R rjson JSON for R XML Tools for parsing and generating XML within R and S-Plus igraph Network analysis and visualization bitops Bitwise Operations
  • 19. REQUIRED PACKAGE i sa lp ca e( ( rs n,Ru l ,X L, ir p'' io s) dp ne c e= RE n tl . ak gs c' jo ''C r' 'M ' ' g ah,b tp ' ,e ed ni sT U) l ba yr sn i rr ( jo ) l ba yR ul i rr ( Cr ) l ba yX L i rr ( M) l ba yi rp ) i rr ( ga h l ba yb tp ) i rr ( io s
  • 20. FACEBOOK CONNECT f _o nc < f nt o ( p t = " e, ac s_ oe = tk n ot os { b cn e t - u c in a h m" ce s tk n o e, p in ) i ( !i sn (p i n) ) f m si go to s { o to s< s rn f "% " ps e nm s o to s ,"" ul s( pi n) c la s =" p i n - p i t( ?s, a t( ae ( pi n) =, ni to t os , ol pe & o to s< g u( ,, "2 " o to s p i n - s b "" %C, p in ) u l< s rn f "t p: / r p .a eo kc m% % &c es tk n % " pt , ot os a c r - p it ( ht s /g ah fc bo . o/ssac s _o e= s, a h pi n , c }e s { le u l< s rn f "t p: / r p .a eo kc m% ? ce st kn %" p t, a cs _o e ) r - p it ( ht s /g ah fc bo . o/sa cs _ oe=s , ah c es t kn } dt < gt R ( u l s l vr fp e =F LE ) aa - e UL r , s. ei y er AS fo JO (d t ) rm S N aa }
  • 21. TEST ON API EXPLORER
  • 22. EXECUTED RESULT > f_ on c( m" a cs _o e) bc n et "e ,c es t kn $d i [ ]" 72 48 " 1 7 8 28 9 $ ae nm [ ]" ai C i" 1 Dvd hu $ is _a e f rt n m [ ]" ai " 1 Dvd $ at nm l s_ a e [ ]" hu 1 Ci" $ ik ln [ ]" tp :/ w. a eo kc mC i Y" 1 h t s/ ww fc bo . o/ hu W $ sr ae u en m [ ]" hu W 1 C i Y"
  • 23. GET FRIEND LIST > fi ns < f_ on c (a h" ef in s,a cs _o e=c es tk n re d - bc n et pt =m / re d" c es t kn ac s_ oe ) > fi ns re d
  • 24. GET FRIEND GROUP LIST f in go p < f _ on c( pt = m/ re di t" a cs _ oe =c es tk n r ed r us - bc ne t a h" ef in l ss, ce st kn ac s _o e) f in go p. d < sp l (r ed ru s d t,f nt o()xi) r ed r us i - a py fi n go p$ aa u c inx $d f in go p. ae < sp l (r ed ru s d t,f nt o()xn m) r ed r us nm - a py fi n go p$ aa u c inx $a e
  • 25. FACEBOOK ELEMENT EXTRACTOR # Gt Fi ns If r ai nF o F e r ed n om to rm B m < f_ on c( a h" e, ac s _o e= ce st k n o t osls (f ed ""d nm ,o e - b cn et pt =m " c es tk na c s_ oe , pi n=it " il s=i, a el c m nm < m$ ae y ae - e nm f in s< m $r ed r ed - e fi n s # Et at Fc bo I s xr c a eo k D f in si < sp l (r ed $a a fn to ( )x i) r ed . d - a py fi n sd t , u ci nx $ d # Et at F Mt I fr ai n xr c B ea n om t o f in sn m < u l s( ap yf i ns dt ,f nt o () i ov xn m , o' T 8, u= " ) r ed . ae - ni ts p l( re d$ aa uc in x c n( $a e t= UF 's b " ) ) f in sg ne < s pl (r ed $ aa fn t o( )u ls ( fi . u l x gn e ) " o e e r ed . ed r - a py f in sd t, u ci nx ni ti (s nl ( $e dr ) nn " l f in sl ct o. d < u l s( ap yf in s dt,f nt o () xl ct o$ d ) r ed . oa in i - ni ts p l( re d$ aa uc in x $o a in i) f in sl ct o. a e< u ls (a py fi n sd t , fn t o( ){ f( s n l ( $ oa in r ed . oa in nm - n it s pl (r ed $a a u ci nx i i. ulxl c to$ f in sh mt w. a e< u ls (a py fi n sd t , fn t o( ){ f( s n l ( $ oe on r ed . oe on nm - n it s pl (r ed $a a u ci nx i i. ulxh m tw$
  • 26. GET FRIENDSHIP MATRIX f in si s< f nt o( { r ed h p - u c in ) pi t" ee ai g fi ns i mt i" rn ( Gn rt n re d hp a rx) N< l nt (r ed .d - e gh fi n si ) fi ns i. ar x < m t i(,, ) re d hp mt i - ar x0N N fr ( i 1N { o i n :) p it ps ei f in sn m[ ] ) r n (a t( ,r ed . ae i) t p< f cb o( pt = at (m /u ul r ed " fi nsi [ ] sp"" , ac s _o e m - a e o k a h p s e " e m t a f i n s , r e d . d i , e =/ ) c es tk m ta fi ns < sp l (m $a a fn to () xi) u u lr ed - a py tp d t, uc i nx $d f in si .a r xi fi ns i %n m ta fi n s < 1 r e dh pm ti [, r ed .d i % u u lr ed ] } #C et c ne to sw t m fi ns r a e o nc i n ih y r ed fi ns cn < c1N re d _o - ( :) fi ns cn ]< 1 re d _o [ #A dt i vc o a a c lm t te fi n si m ti d hs et r s o un o h r ed hp a rx fi ns i. ar x < c i df in si .a r xf in sc n re d hp mt i - bn (r e dh pm ti ,r e d_ o) #A pn m fi n si w t m s l p e d y r ed hp i h ye f fi ns i. ar x < r i df in si .a r xa pn (r e d_ o, ) re d hp mt i - bn (r e dh pm ti ,p e df in sc n 0 ) rw ae (r ed h pm ti )< a pn (r e d. aemn m ) on m sf in si .a r x - pe df in sn m,y ae cl ae (r ed h pm ti )< a pn (r e d. aemn m ) on m sf in si .a r x - pe df in sn m,y ae rt r (r ed hpmt i ) eu n fi ns i.a rx }
  • 27. FRIEND GRAPH f in ga h< f nt o( r ed hpmt i ) { r ed r p - u c in fi ns i.a rx f i n s i . r p < g a h a j c n y f i n s i . a r x m d = (u d r c e " , w i h e = re d hp ga h - r p.d ae c ( re d hp mt i, o ec"n i et d) e g tdN Vf in si .r p )g ne < a pn (r ed .e d r m s l$ ed r (r e dh pg ah $e d r - p ed fi n sg ne , ye fg ne ) V f i n s i . r p ) l c t o < a p n ( r e d . o a i nn m , m s l $ o a i n n m ) (r e dh pg ah $o a in - pe df i ns lc to . ae y ef lc t o$ ae V f i n s i . r p ) h m t w < a p n ( r e d . o e o nn m , m s l $ o e o n n m ) (r e dh pg ah $o e on - pe df i ns hm tw . ae y ef hm t w$ ae Vf in si .r p )L bl < Vf in si . rp )n m (r e dh pg ah $a e - ( re dh pg ah $ ae rt r ( re dh p ga h eu n fi ns i. rp ) }
  • 28. DRAW FRIENDSHIP GRAPH f mt i < f in s is ) _ ar x - re dh p( f ga h< f in ga hf m ti) _ rp - r ed r p( _a rx w ie ga hf ga h "r e d. rp m" fr a =g ah l ) r t. r p ( _r p, f in sg a hl ,o mt "r p m"
  • 29. GRAPH XML FORAMT (GRAPHML)
  • 30. LESSON 3: SOCIAL NETWORK VISUALIZATION Using Gephi
  • 31. GEPHI Gephi, an open source graph visualization and manipulation software
  • 32. MODULARITY Measure of the structure of networks or graphs. It was designed to measure the strength of division of a network into modules Networks with high modularity have dense connections between the nodes within modules but sparse connections between nodes in different modules
  • 33. LEARN MORE ABOUT GEPHI https://www.udemy.com/gephi/
  • 34. GET LIKES COUNT OF POSTS r qi ep y) e ur ( lr p ss < f_ on c( ah " ep ss ,a cs _ oe =c es t kn ot o sl s( fe d "" i o t - bc ne t pt =m /o t " ce st kn a cs _o e, p in =i t "i ls =l p s. ie < sp l (o t$ aa f nt o( ) xl ks o tl k s - a py ps s dt , uc in x $i e ) p s. ie .a a< s pl ( ot lk s fn to () x dt ) o tl k sd t - ap yp s. i e, uc i nx $ aa l =l s ( i it ) f r( i 1l nt ( ot lk sd t ){ o i n : eg hp s. i e. aa ) fr ( i 1(e g hp s. ie . aa [])1) o j n :l nt (o t lk sd t [ i]- ){ l < a p n ( i p s . i e . a a [ ] [ j ]n m ) i - p ed l, o tl ks d t[ i] []$a e } } d =d. al ri dd t. r m, l) f oc l( bn . aa fa e i c la e( f < c " ae ) o nm s d) - (n m" d py d, .n m) s ma i e N m us =l nt (a e ) d l( f ( ae , um rz , uS b e g hn m)
  • 35. CONCLUSION REMARK Interesting Fact Abour Friends Value Behind The Network Statstic Is Worth More Than Thousand of Words
  • 36. YOUR TURN TO DO SOME ANALYSIS Find Popular Checkins Among Your Friends Common Interest Between Your Friends Female/Male Distribution of Your Know Friends Most Pupular Photos Being Liked Asociation Rule of Friends (Gossip)