Terror Tweets
Wed 03 August 2016Intro¶
From kaggle, someone posted a collection of tweets from accounts that are following ISIS.
This project was focused on the visualization aspect to determine whether or not those who are tweeting at large have large audiences, or like me, have few followers. Looking at the number of the tweets they've put out as well and the followers they've accrued it will be possible to see how broad of an audience the ISIS followers are reaching.
Early Data Analysis¶
tweets = pd.read_csv('tweets.csv')
tweets.head(2)
For the analysis that's needed it's not exactly needed to maintain all of the information present. Although it would be interesting to create a network of the users, it would be more interesting to see who are the most common tweeters and then take a look at what the common bigrams for the most frequent tweeters are versus those who are not.
It will also be interesting to see if spikes of tweets occur following terrorist attacks. Should that turn to be true, then it will be interesting which attacks garnered the most activity.
Finally the majority of the tweets do not have an associated location. However the time is still present so based on the activity of the user their timezone can be infered.
user_count = tweets.name.value_counts()
user_count = pd.DataFrame(user_count)
user_count.describe()
user_count[user_count['name'] > 154][0:20].plot(kind='barh', figsize=(16,8))
plt.legend('Tweets', loc=0)
plt.title('Most Active Users Following ISIS on Twitter')
plt.xlabel('Number of Tweets')
plt.ylabel('Twitter Username')
plt.show()
Looking at the English names above, since I can't read Arabic, none of the names are inheirently indicitive of sympathy towards ISIS, save perhaps for Rami which translates to one who believes. This is only by volume of tweets. It could be that Rami has few to no followers and is just retweeting what he sees. Will look at the accounts with the most followers as well, and finally a metric of the number of followers that the account has relative to the followers they have.
popular = tweets.drop_duplicates(subset=['name']).sort_values(by='followers', ascending=False)[0:20]
popular.plot(kind='barh', figsize=(20,8), use_index=True, x='name', fontsize=14)
plt.title("Follower to Tweet Count of Most Followed Users", fontsize=20)
plt.legend(["Followers", "Total Number of Tweets"], fontsize=12)
plt.xlabel("Count")
plt.ylabel("Name")
plt.show()
tweets['time'] = pd.to_datetime(tweets.time)
tweets['day'] = tweets['time'].map(lambda x: x.strftime('%Y-%m-%d'))
tweets.dtypes
days = pd.DataFrame(tweets.day.value_counts())
days = days.sort_index()
days['Tweets'] = days['day']
del days['day']
fig, ax = plt.subplots(figsize = (20,8))
days.plot(kind='line', ax=ax)
days.rolling(center=False, window=7).mean().plot(color ='r', ax=ax)
ax.legend(['Daily Tweet Count', '7-Day Rolling Mean of Tweets'], loc = 'upper right',
numpoints = 1, labelspacing = 2.0, fontsize = 14)
plt.title('Tweets by Accounts Following ISIS by Date', fontsize=20)
plt.xlabel('Date', fontsize = 14)
plt.ylabel('Total Tweets', fontsize = 14)
plt.show()
There are several peaks that appears to occur after January 29th. With a peak around January 31st. To determine what dates were above the baseline, the date was cut off after January 29th. Through looking at the description of the
(days.ix['2016-01-29' :]).describe()
days[days['Tweets'] >= 187].sort_values('Tweets', ascending=False).head()
All of these days had rather horrific and cowardly terrorist attacks. January 31st was marked by an attack in Syria, the Sayyidah Zaynab bombings, that left more than 60 people dead and over 100 severely wounded. May 12th saw the Zara'a massacre in Syria, with the Alawites suffering at least 49 deaths (42 civilian, 7 military). It was surprising not to see anything following the Brussels attack. As it stands all of these are visible as major peaks following the event and is visible in the above graph.
For the majority of these twitter users, they seem to be nothing more than tin soldiers. People who are tweeting often to a small number of users. As ISIS continues to be driven back there will likely be more tweets to continue to grow the narrative of the organization.