Twitterユーザー分析

Rで学ぶソーシャルメディアデータ分析

Vivek Vijayaraghavan

Data Science Coach

レッスン概要

  • ユーザーのfriends_countfollowers_count
  • ブランド訴求のためのゴールデンレシオ解釈
  • 製品に関心のあるユーザー特定にTwitterリストを活用
Rで学ぶソーシャルメディアデータ分析

FollowersとFriends

Twitterのfriendsとfollowers

  • Followers: そのユーザーをフォローする人
  • Friends: そのユーザーがフォローしている人
Rで学ぶソーシャルメディアデータ分析

Twitterのフォロワー/フォロー比

ゴールデンレシオの式

  • マーケターがプロモーション戦略に活用
Rで学ぶソーシャルメディアデータ分析

正の比・負の比

  • 正の比: followersがfriendsより多い
  • 負の比: friendsがfollowersより多い
Rで学ぶソーシャルメディアデータ分析

ユーザー情報の抽出

# #fitnessのツイートを1000件検索
tweet_fit <- search_tweets("#fitness", n = 1000)
# ユーザー情報を抽出
user_fit <- users_data(tweet_fit)
Rで学ぶソーシャルメディアデータ分析

ユーザー情報の抽出

# ユーザーデータの列名を表示
names(user_fit)

ユーザーデータの列名

Rで学ぶソーシャルメディアデータ分析

followers_countとfriends_countの抽出

  • ユーザーのscreen_nameごとにfollowersとfriends数を集計
# screen_name, followers_count, friends_countを集計
library(dplyr)
counts_df <- user_fit %>%
               group_by(screen_name) %>%
               summarize(follower = mean(followers_count),
               friend = mean(friends_count))
Rで学ぶソーシャルメディアデータ分析

followers_countとfriends_countの抽出

head(counts_df)
screen_name      follower     friend
<chr>              <dbl>       <dbl>
__seokjinnie124     209        454        
_Aminata            623        523        
_amsvn              167        126        
_arweeennn          539        801        
_asof_             1336        455        
_blendac            833        195
Rで学ぶソーシャルメディアデータ分析

ゴールデンレシオ

# ゴールデンレシオを計算する列を作成
counts_df$ratio <- follow_df$follower/follow_df$friend
head(counts_df$ratio)
[1] 0.4603524 1.1912046 1.3253968 0.6729089 2.9362637 4.2717949
Rで学ぶソーシャルメディアデータ分析

比率に基づくユーザー探索

  • ゴールデンレシオを見てユーザータイプを把握
# follower数の降順で並べ替え
counts_sort <- arrange(counts_df, desc(follower))
Rで学ぶソーシャルメディアデータ分析

比率に基づくユーザー探索

# follower数が30000を超える行を抽出
counts_sort[counts_sort$follower>30000,]
screen_name    follower    friend    ratio        
<chr>            <dbl>      <dbl>    <dbl>
mashable         9817699    2783     3528    
MensHealthMag    4528421    1111     4076    
Sophie_Choudry   2367827    157      15082    
thewebmaster_    103936     6508     16    
qwikad           92932      89557    1    
Rharvley         90464      19484    5    
SayWhenLA        68122      6680     10
  • フィットネス商品のプロモーション媒体に適する
Rで学ぶソーシャルメディアデータ分析

比率に基づくユーザー探索

# follower数が2000未満の行を抽出
counts_sort[counts_sort$follower<2000,]
screen_name    follower     friend    ratio        
<chr>            <dbl>       <dbl>    <dbl>
workout_ehime    1960        1027       2    
SardImperium     1932        256        8    
Deem_Hoops       1912        1520       1    
kaykay_inem      1890        443        4    
bhealhty         1855        3066       1
  • 個別アカウントに広告を出し、精緻にターゲティング
Rで学ぶソーシャルメディアデータ分析

リストによるユーザー分析

  • Twitterリストは厳選されたアカウントの集合
  • ユーザーは関心のあるリストを購読
Rで学ぶソーシャルメディアデータ分析

購読リストの抽出

# 「Playstation」が購読しているリストを取得
lst_playstation <- lists_users("PlayStation")
lst_playstation[,1:4]
list_id          name                      uri               subscriber_count
<chr>            <chr>                    <chr>                      <int>
58505230       PS Family         /PlayStation/lists/ps-family         136    
4747423        GameDevelopers    /PlayStation/lists/gamedevelopers    467    
2490894        gaming            /PlayStation/lists/gaming            658
Rで学ぶソーシャルメディアデータ分析

リスト購読者の抽出

# "Playstation"の"gaming"リストの購読者を100人取得
list_PS_sub <- lists_subscribers(slug = "gaming", owner_user = "PlayStation", n = 100)
Rで学ぶソーシャルメディアデータ分析

購読者のscreen_nameを確認

# 購読者のscreen_nameを表示
list_PS_sub$screen_name

購読者のscreen_name

Rで学ぶソーシャルメディアデータ分析

リスト購読者のユーザー情報

# 4つのscreen_nameを用意
users <- c("Morten83032201","ndugumr", "WOLF210_Warrior", "souransb")
# ユーザー情報を取得
users_PS_gaming <- lookup_users(users)
user_id                   status_id              created_at          screen_name
<chr>                       <chr>               <S3: POSIXct>          <chr>
1158299850573791233    1172604921121824769    2019-09-13 20:16:13    Morten83032201    
894525207620321280     1183293767215992832    2019-10-13 08:09:53    ndugumr    
325760816              1182867378293616640    2019-10-12 03:55:34    WOLF210_Warrior    
469270931              511997829384904704     2014-09-16 21:59:29    souransb
Rで学ぶソーシャルメディアデータ分析

Vamos praticar!

Rで学ぶソーシャルメディアデータ分析

Preparing Video For Download...