SlideShare une entreprise Scribd logo
1  sur  32
入門機会学習11章
ソーシャルグラフの分析
@ringtaro
11章でやること
• ソーシャルネットワーク分析・グラフ理
論がどういうものかを知る
• ツイッターのネットワークデータを収集
してみる
• 収集したネットワークデータでクラスタ
リングを試してみる
•
構築する
ソーシャルネットワーク分析
• ソーシャルネットワークとは様々な関係
によって結び付けられたノード(個人や組
織)から成る社会的な構造(Wikipediaより)。
• 「ノード」と「つながり」から分析を行
うので、ツールとしては、主にグラフ理
論を用いている。
ソーシャルネットワーク分析の
例
• エルデシュ数
– エルデシュ=20世紀で最も多くの論文を残した(と言って
も過言ではない)数学者
– ある数学者がエルデシュと共同論文を執筆した場合エルデ
シュ数は1

• ソシオメトリー
–

L・モレノ
• 人々
幸福にと
めに、友人関係をマッピング

影響するかを知るた

–
• 黒人と白人の小学生の子供の間の人種的な亀裂

• 150人の法則(Wikipediaより)
– 現実のソーシャルネットワークにおけるメンバーは150人
に限定される
グラフについて
• グラフはノードの集合とエッジの集合で
構成される。
• ノード
– 節点・頂点
– node,vertex

• エッジ
– 枝・辺・リンク
– edge,link
グラフについて
無向?有向?
• フェイスブックは無向グラフ
• ツイッターは有向グラフ
Rでのグラフのプログラミング
• igraphライブラリを使ってグラフの分析を
行う。
• エッジリストを作り、igraphの形式に変換
する。
• エッジリスト
– グラフを表す2列の行列

• c(integer(0), integer(0))
– 何もないエッジを表すベクトル
試してみる
• グラフのプログラミング
• ringtaro / 11-SNA.R
– https://gist.github.com/ringtaro/7544101
タの収集
• ツイッターの制限があるので必要なデータを
収集するのは厳しい
• なので、Google SocialGraph APIを使った。
• でも、本の執筆時と出版時でSGAの仕様が変
わったのでサンプルを動作させてもちゃんと
した結果は返らない。
• なおかつ、SGAは2012年1月にサービスを終了
している。Σ(゚Д゚;エーッ!
• 試せない!どうしよう!
Google SocialGraphのデータ構造
{
"canonical_mapping": {
"http://twitter.com/drewconway": "http://twitter.com/drewconway"
},
"nodes": {
"http://twitter.com/drewconway": {
"attributes": {
"exists": "1",
"bio": "Hopeful academic, data nerd, average hacker, student of conflict.",
"profile": "http://twitter.com/drewconway",
"rss": "http://twitter.com/statuses/user_timeline/drewconway.rss",
"atom": "http://twitter.com/statuses/user_timeline/drewconway.atom",
"url": "http://twitter.com/drewconway"
},
"nodes_referenced": {
"http://blog.fkoji.com/": {"types": [ "me" ]},
"http://twitter.com/8maki": {"types": [ "contact" ]},
"http://twitter.com/aibamika": { "types": [ "contact" ] },
},
"nodes_referenced_by": {
"http://twitter.com/244": { "types": [ "contact" ] },
"http://twitter.com/37to": { "types": [ "contact" ] },
"http://twitter.com/adamrocker": { "types": [ "contact" ] },
}
}
}
}
試してみる
• JSONのデータからTwitterネットワークを
取り出す。
• ringtaro / 11-SNA.R
– https://gist.github.com/ringtaro/7544101

• ringtaro / ringtaro.json
– https://gist.github.com/ringtaro/7544028
どうやってグラフオブジェクトを
収集するか
• 1つのツイッターユーザーをシードにする
• そのシードからネットワークを構築する
• スノーボールサンプリング(雪だるま式標
本抽出)
– 1つのシードに対する入出力次数接続を見つけ
る
– その接続を新たなシードとして使う
– この処理を決まった次数だけ繰り返す
• このケーススタディでは2周期
– 最初のシードユーザーがフォローすべき人を見つけるた
め
– SGAの制限を超えないため
イメージ

Seed
イメージ

Seed
イメージ

Seed
イメージ

Seed
プログラムの階層
• twitter.snowball(シードと次数を受け取って雪だるま
式標本抽出しigraphグラフオブジェクトを返す)

– twitter.network (ユーザー名を受け取り、SGAに接続して
ネットワークのエッジリストを返す)

• build.ego(ネットワークをJSON形式で受け取り、ツイッターユー
ザーネットワークのエッジリストを返す)

– find.twitter(ツイッターユーザーだけを抽出する)

– get.seeds(エッジリストからシード以外のユーザーを抽出)
試してみる
• スノーボールサンプリング
• ringtaro / 11-SNA.R
– https://gist.github.com/ringtaro/7544101
ツイッターネットワークの分析
• 準備
– ノードにラベルを付ける(Gephi可視化のため)

• スクリーニング
– 2コア
– エゴネットワーク

• 階層的クラスタリング
– 系統樹
– 区分データを追加
– Gephiによる可視化

• おすすめユーザーエンシ
構築
• 区分ごとのおすすめユーザー
ノードにラベルを付ける
• Gephiで可視化するためにノードにラベル
をつける。
• dataフォルダにある.graphmlファイルには
付いてます。
試してみる
• ノードにラベルを付ける
• Gephiで表示してみよう
• ringtaro / 11-SNA.R
– https://gist.github.com/ringtaro/7544101
k-コア
• 最低k個以上の次数を持つ最大サブクラス
• 2コアのサブグラフを作ると、他と密に結
びついていないノードを削除することが
できる
エゴネットワーク
• ネットワーク内の1つのノードを取り囲む
ソーシャルグラフの構造
• シードとその隣接ノード
試してみる
• k-コア
• エゴネットワーク
• ringtaro / 11-SNA.R
– https://gist.github.com/ringtaro/7544101
階層的クラスタリング
• 密接に接続されているノードほどノード
間のホップが少なく類似していると考え
る
• 系統樹(デンドログラム)
試してみる
• 階層的クラスタリング
• 区分ごとに色分けして、Gephiで可視化
• ringtaro / 11-SNA.R
– https://gist.github.com/ringtaro/7544101
おすすめユーザー
• 「シードがフォローしていない「フォロ
アーのフォロアー」」(開いた三角形)の中
で最もフォローされている人
• やってみる
試してみる
• おすすめユーザー
• ringtaro / 11-SNA.R
– https://gist.github.com/ringtaro/7544101
区分ごとのおすすめユーザー
• 階層的クラスタリングで分けた区分ごと
のおすすめユーザー
– 似たようなユーザーの間で共通してフォロー
されているならより精度が高まるだろうとい
う考え

• やってみる
• 可視化されたおすすめユーザー
試してみる
• おすすめユーザー
• ringtaro / 11-SNA.R
– https://gist.github.com/ringtaro/7544101
まとめ
• ツイッターの「
構築する ことにより、
ネットワークデータの収集から分析まで、
ソーシャルネットワーク分析の一通りを
体験した

Contenu connexe

En vedette

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

En vedette (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

入門機会学習11章ソーシャルグラフの分析