SlideShare uma empresa Scribd logo
1 de 37
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

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
Cédric Brun
 
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
Cédric Brun
 

Mais procurados (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!
 

Semelhante a Social Network Analysis With R

Testing Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax ExamTesting Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax Exam
Henryk Konsek
 
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
Henryk Konsek
 
Certificates
CertificatesCertificates
Certificates
Jeff CHen
 

Semelhante 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
 

Mais de David Chiu

Mais 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

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 

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)