Is Emotion Contagion independent of Information ?

In a social network, each node is influenced by it’s neighboring nodes. This influence can be observed primarily in two forms;

  1. Change in the knowledge state of a node, or
  2. Change in the emotional state of a node.

It will be interesting to figure out how their dependency on one another. However that will a topic for the future. What this post will address is whether the two are independent.

Imagine two people. One in an agitated state, start to lash out on the other person. In this exchange between the two people, few things are transferred between the two. The context and the emotion. The information/context could be the location, time, past events, future anticipation, and words spoken by the angry person, and the emotion is arguably ‘anger’.

While there can be anecdotal evidence on how the context information is dependent or independent on the emotion, it’s not concrete. More specifically, the question that I’m asking is what effect does it have on the victim, in terms of his behavior ?
Generally, what has been observed is a person will either go into introspection if he feels that the other person’s emotion was justified, otherwise vent his frustration onto someone else irrespective of the context.

So how does this translate into a problem ?

well well well, since you asked.

The problem statement is as follows:

Given a social network and the text/opinion data of each node in the network, partitioned w.r.t. time,

Que 1) Does the emotion/sentiment of a node affects the sentiment of it’s neighboring nodes ?

Approach:

Part 1

Getting a social network. Using the twitter API, it’s possible to get few key information. The individual user, his friends list (people who the user follows), his tweets with timestamps, and all of his friends tweets.

For any twitter app, you first need to access the API. Here’s an great playlist for you to cover your basics.

https://www.youtube.com/watch?v=wlnx-7cm4Gg&list=PL5tcWHG-UPH2zBfOz40HSzcGUPAVOOnu1

from tweepy import API
from tweepy import OAuthHandler
auth = OAuthHandler(twitter_credentials.CONSUMER_KEY, twitter_credentials.CONSUMER_SECRET)
auth.set_access_token(twitter_credentials.ACCESS_TOKEN, twitter_credentials.ACCESS_TOKEN_SECRET)

api = API(auth)

Once the you have the access, we use the following line of code to access all their friends.

form tweepy import Cursor
friends_ids = []
for page in Cursor(api.friends_ids, screen_name='wadu_hek').pages():
friends_ids.extend(page)
time.sleep(60)
screen_names = []
num_statuses = []
for id in friends_ids:
u = api.get_user(id)
screen_names.append(u.screen_name)
num_statuses.append(u.statuses_count)

Now you have node, with all of its neighbors. For starters(cos’ I am one), I will make an reasonable assumption: A person’s emotional/information state is affected only by their immediate neighbors. Now in order to get the tweets of everyone in this small network. We iterate over the screen_names and pass the those names to the following function.

def get_all_tweets(screen_name):
alltweets = []
new_tweets = api.user_timeline(screen_name=screen_name, count=200)
alltweets.extend(new_tweets)

oldest = alltweets[-1].id - 1

while len(new_tweets) > 0:
print('getting tweets before %s' % oldest)

new_tweets = api.user_timeline(screen_name=screen_name, count=200, max_id=oldest)
alltweets.extend(new_tweets)
if len(alltweets) > 500:
break
oldest = alltweets[-1].id - 1

print('%d tweets downloaded so far' % len(alltweets))

out_tweets = [[tweet.id_str, tweet.created_at, tweet.text.encode("utf-8")] for tweet in alltweets]

with open('%s_tweets.csv' % screen_name, 'w') as f:
writer = csv.writer(f)
writer.writerow(['id', 'created_at', 'text'])
writer.writerows(out_tweets)

Now I have the following information.

  1. The test node, on which we try to predict and observe the effects
  2. All the neighbors of the test node.
  3. The tweets of the test node and all of its neighbors with timestamps.

Part 2

Building a twitter sentiment analyser. This is fairly easy. There are lots of great resources.

This will help to figure out the sentiment of its of any node in every specified time frame.

Now, the next step is to observe whether the sentiment of neighbors affect the sentiment of the test node. I still have to lay down a specific method.

As for now, I’ll do a crude step of averaging out the emotions in each time step of all of it’s neighbors and comparing this will the actual sentiment of the test node. There may be a variations, in terms of emotion not being portrayed, in the same time steps, and which will even vary from one test node to another.

So in order to suppress such cases’s effect on the experiment, I will possibly have to scale the social network. Also different neighbors ought to portray, different influence on the test node, this means that each edge will have to have a weight associated with it.

These weights could be inferred from the how the emotional state of the test node depends in respect to each of it’s neighbors. I am still working on the exact methodology to do so.. (future work :) )

A more granular emotional state(happy, sad, afraid/surprised, and angry/disgusted) will help to better answer the questions of emotional contagion and it’s dependency on the information/context, but of all such data sets, I haven’t yet found one large enough to train a sentiment analyser on.

Part 3

If the test node shows the expected behavior, the next step is to test whether this behavior is independent of the context. In order to do so, we need to summarize the tweets at each time step in terms of a ‘topic’.

The following is a good guide to extract topics. I have yet to test it on tweets.

What I am trying to observe here is whether the topics and emotions of the neighboring nodes and test nodes are independent.

So if a node y (belongs to) neighbors’s sentiment is negative and is talking about sports, does the test node, given the influence of this neighbor.. will the the test node have similar emotion while talking about different topic.

A thing that bothers me is whether emotional contagion occur if the exchange isn’t directed towards the node itself by another node.

I believe scaling the social network to include even more layers of nodes and timely tracking their sentiments could help to ignore more of this kinks that otherwise occur in a small network (a node and neighbor).

More work to be done.. Until next time.

--

--

--

Interested in AI, ML, Music and Poetry. Love the nature, like to travel and explore.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Anuvesh Kumar

Anuvesh Kumar

Interested in AI, ML, Music and Poetry. Love the nature, like to travel and explore.

More from Medium

Looking at Bias in Amazon’s Search Results

How We’re Bringing Our Movement Health Platform to Healthcare Organizations

Ranking the Best and Worst Players in the LCS using Machine Learning

Are you targeting the right customers with your campaign offers ?