Hi everyone, it's a big pleasure to be here.
My name is Armin Purnaki and I'm a PhD candidate in Applied Mathematics and I work on building
tools for discourse analysis and we build tools for discourse analysis based on methods
from graph theory, network science and natural language processing and today I want to present
a tool called the Twitter Explorer that is already a bit older but that was built in
the Max Planck Institute for Mathematics and Sciences in my previous group and the idea
was to build a tool that allows researchers who don't necessarily have programming skills
to collect Twitter data, visualize them using graphs and explore the data and maybe generate
hypotheses in their pipelines.
So this kind of tool building and this research happens in the field called computational
social science so when I was preparing my slides two days ago I thought it would be
good to maybe give a little overview of computational social science then say why we built the Twitter
Explorer and where we saw somehow the need for a new tool, of course introduce the features
of the tool because it's kind of a talk on programming, the architecture and maybe give
some insights on the usage but when I was sitting down to make the slides two days ago
I was confronted with this and of course since the tool is essentially an entry point into
the free API there is also a part of it that uses the research API which of course led
us directly to this question, what happens to the research API?
It's also not entirely clear, right?
So I want to maybe instead of giving this the talk the way I was planning to do it, I will
do it but maybe I wanted to ask a few questions first that we might then discuss maybe in
the discussion also and I think there is even some kind of something planned later right
so some kind of panel discussion so I'm just going to throw some questions out there that
I think are really pressing now especially in the research field.
How serious is this but this I don't mean the implications of it because I know a few
people whose thesis is now in jeopardy because they can't collect data in a way but how serious
is it in the sense, how serious is it in the sense, will it actually happen or is it some
scare tactic so I think this is something that is hard to predict and then these are
questions also I think that we can discuss here is how or is there a way for us as users
and not necessarily only as researchers to claim our data or our digital traces that
we use and that we leave on these platforms and how can things like the Digital Services
Act play a role in this and the last question is very broad but how do we move on in the
sense of how can we see this as some kind of wake up call maybe and how can we use this
new development to maybe on one hand move to different platforms but on the other hand
also to think about how we do computational social science in the future.
So with these questions that we're going to discuss later I'm still going to give my
original talk so in computational social science a typical pipeline for a project is you have
a research question then you collect data related to it and in this case it may be data
from online social platforms and then you analyze it and ideally you generated some
more insights on the research question you had in the beginning and sometimes the exploration
and the analysis of the data can help you maybe refine also the questions you had in
the beginning so it's some kind of loop that you can see in this way and the tool that
I'm going to present the Twitter Explorer is precisely made for this second part for
both facilitating the collection and also the exploration of such data and this pipeline
is that we start with text so in our case it's tweets that are annotated with some kind
of metadata we have on Twitter different types of interactions so you can mention someone
you can reply to someone or retweet and we choose one type of metadata and cast it into
an interaction network and then we want to find the most significant for instance clusters
or the significant correlations in this data by using 2D spatializations and typically
these are done using force layouts but today for instance in the graph room there were
also some talks about new methods of node embedding and so I think this is also something
that we can discuss maybe in the question section but one reason why I think force layouts
are good is that especially if you use them in a context where you work with social science
researchers who don't necessarily have a lot of knowledge about the latest machine learning
algorithms they are quite straightforward to explain in the sense that you have a spring
system and nodes that are strongly connected tend to attract each other and especially if
you look at interaction networks on Twitter since retweeting can be considered endorsement
open clusters in such 2D spatializations can then correspond to something like opinion
clusters and there's a lot of research being done in that way but one question that we
always had when we look at these networks is how do we actually go back to the data
that generated them and this is something that we try to tackle with building these
tools so why we built it is firstly to provide an interface for researchers without programming
skills also to collect and visualize the data because we were working a lot with social
scientists that did not have these programming skills but had a lot of hypotheses about the
data that they could not test then of course to facilitate the exploration of controversial
issues on social media and this is the point that I was making before is add some layer
of interpretability to these 2D spatializations by providing an access from within the interface
to the actual data that created these node positions and finally we see it in the context
of a larger scientific scope of using the network paradigm as something like a sampling
mechanism for the data because if you're confronted with a large number of tweets for instance
of course everyone knows that you can't read all of them manually so you need some kind
of way to get to the tweets that are relevant for you to read and this is what we use the
network for essentially so when we look at read-read networks immediately identify for
instance the most influential actors in the debate and then read precisely those tweets
that they made to maybe influence other actors and we call this guided close reading because
if you do only close reading then you have to read all the text if you have distant reading
you kind of look only at the network on a structure level and this is something in between
so what can the tool do it collects tweets I mean I think we have like one week left
for the v2 and the v1 so far the v2 academic is safe but we don't know that so you can
search for it from the past seven days using the API and in the second part in the visualizer
you can do display just a simple time series of the tweets to see maybe if there's some
kind of special activity during one day you can build these interaction networks build
co-hashtag networks so we divide it into some kind of two types of networks which we call
semantic networks and interaction networks and then you can compute the typical measures
people compute on networks and especially compute clusters like using modularity based
algorithms and all this happens in some kind of interactive interface using JavaScript
and D3JS and this is essentially the part where it gets interesting because so far all
the other things you can do it with a lot of other tools especially like AFI or I think
you can even collect tweets right with some plugins so I think all of this is not new
and this is kind of where it gets interesting and I think this is time for a quick demo
I don't know how much okay I have plenty of time I think I talk too fast okay so I have
prepared some Python environments that already have the Twitter Explorer installed but usually
you would do it like this and then all you need to do to fire up this interactive interface
is type Twitter Explorer collector and this will open a browser window from which you
can choose your API access choose the path to which the tweets will be downloaded and
insert your search query maybe adding some advanced settings and saving options so I
don't know this is a question to the audience now what we should search for this is easy
and I already this is you're looking into the future I already have this network prepared
for the last slide sorry we could but what would we look for then API is there maybe
a hashtag like API shutdown maybe we need to go to Twitter itself API something like
this we ideally would find some kind of hashtag know that okay let's just use maybe this as
a search query no okay now it's collecting in the background
then we can open another browser window here fire up the visualizer now we see that while
this is still collecting we can already access oh there were only 400 tweets so there seems
to be so we can
look at a time series of tweets and then we can choose different types of networks to
create we can filter them by language if we want and this is the language of the Twitter
API returns so it's not there's no language detection going on here we can do some network
reduction methods like taking only the largest connected component of the graph then we have
this option here to remove the metadata of nodes that are not what we call public figures
so if you want to publish some explorable networks it is advisable to do so there is
not as far as I know not a very distinctive or clear rule after which point one is considered
such a public figure but within our consortium we decided that it's 5000 followers this is
also something we could discuss but since Twitter is public by default in a way anything
you post is somehow post potentially to be used in displays somewhere then you can export
the graph to all sorts of formats then you can aggregate nodes this means that for instance
removing them based on how many retweets they have or how many retweets they did themselves
and remove for instance nodes that only retweeted one person so is there a chalk maybe somewhere
so if you have a graph and then there are some nodes that only retweet this person they
I don't know if everyone can see that actually but they tend to clutter the force directed
algorithm and structurally they do not necessarily add anything to the network so if you have
very very large graphs it makes sense to remove these and somehow englobe them into this super
node and then you can do traditional community detection
and then it will be saved as a HTML but you can then open so we see here that this is
again now in a retweet network every node is a user and the link is drawn from A to
B if A retweets B and now we can look at this user t-chambers and look at the actual tweets
that were made for them to end up at this part of the visualization okay so the data
we collect this kind of sparse so this network doesn't look that interesting but I have prepared
some fallback option so what we did in a case study a few months ago was to look at the
repercussion of some discussions in the US about red flag laws and red flag laws are
specific kinds of laws for gun control that allow state level judges to confiscate temporarily
guns from people that are deemed to be a threat to themselves or to the public and these laws
created very big repercussions especially on social media and especially in the conservative
camps and this is one typical example where people then can analyze on Twitter if there
is something like echo chambers or if people then maybe retweet each other only from the
similar camps and then people draw very quick conclusions very fast and what we want to
do with this tool is to show that maybe things are not that simple as they seem so I have
prepared these networks but I think I will make it a bit smaller so this is now a bit
bigger than what we had before we have roughly 25,000 nodes and 90,000 links and this is
already one limitation of the tool that I think I would also like to discuss in the
end is that you can't display mentally huge graphs so 100,000 links approximately is
kind of the limit and I think this is also where integrating it with other tools such
as Sigma or Gaffrey might actually make a lot of sense and so now I can call it a nodes
by the Louvain community we can turn off the light also and now we can wonder what are
these two communities and right now the node size is proportional to the in-degree meaning
how often a given node was retweeted but if we want to so these may then be considered
as something like the opinion leaders of the given camps and so if we go here we see for
instance on this side Donald Trump Jr. and we can then look exactly at the tweets that
led the visualization to put him where where he was so okay we don't need to go into the
details of what he said but you see you see the point we can also change the node size
to the number of followers and then we get an immediate view at who the who the main
actors are that in general are also influential on Twitter so we have the New York Times here
and Wall Street Journal so so we can see that we have something like of a more liberal
versus a more conservative camp but if we look only at the retweet behavior we might think
that okay these are separated echo chambers and people do not talk to each other but what
is interesting is if we look at other types of networks in these example so we can look
at the replies I think I will make it a bit smaller and all of the sudden we don't see
this very strong segregated clustering anymore that we saw here maybe it's easier if I put
it in but we see something more of a hairball layout and when we look at the nodes we see
that indeed the path of going for instance from Donald Trump to Hillary Clinton or New
York Times of those people that were very far apart in the retweet network is maybe
not that not that long in the reply network meaning that these opposing camps actually
maybe do talk to each other and it might be more interesting to see how they talk to each
other and what they say and this is something that is that you can do when you when you
use this interface and look at the tweets and that the actual replies so so it allows
you to then actually go to the parts of the platform that that generate this data and
that then generate these networks and finally as a small example of the semantic networks
we can look at the hashtags that are used again and you see that for instance there
is one kind of hateful conservative hashtag cluster which which and again okay maybe I
should have said that in the hashtag networks every node is a hashtag and they are connected
if they appear together in the same tweet so this is a very very low level way of seeing
what is going on in the data in a way you don't need to do some kind of topic modeling
and or complicated techniques you can literally just by looking at the hashtags already get
a hint at how the different camps speak about the same topic so if you go here in this area
this is about gun confiscation laws so Marxism in this case is also good good example right
now we don't really know how it is used right and it can be used either by conservatives
or by liberals and and and it's important to look at it in the context of of the data
so then we would have to okay five minutes left good I will go back to the slides okay
so under the hood this this whole backend of the collector individualizer is written
in python and it's using the streamlit python library to serve it on a local front end so
this is actually a very convenient library and I guess a lot of people also know it but
you can write your code in python and then it essentially serves it in interfaces that
look like this and the explorer is written in html and javascript and it uses d3 and
prints the graph on canvas which is also why it's probably not as as fast as sigma is but
it has some nice other features that are that are especially due to this force graph library
so I think if anyone has questions I'm going to go into the details in the questions and
so this is how we install it it's fairly simple if you have a running python bigger than 3.7
and there's also an API so of course especially here probably people will not be so interested
in using the streamlit interface but you may want to include it into some kind of existing
code pipeline that you have and this is essentially the API for semantic networks and interaction
networks so I invite you to try it out yourself while you still can you have five days of course
if you have the research API you might be able to use it for a bit longer but otherwise go on
these websites fast and I will stop the talk with some questions actually I came here with more
questions than answers and I'm really hoping for a lively discussion now because I'm not I'm not
originally a developer so I kind of wrote this a bit on my own and I wonder if this
interact integration of python and javascript is actually a good idea because in theory it would
also be possible to probably do everything in javascript and maybe do it on the client side
so you wouldn't have to install all these libraries then okay maybe one thing that I would like to
show is that I experimented with temporal networks so of course doing temporal force
layouts is kind of a non-trivial task but we can kind of look a little bit at the temporality
of these networks by at least displaying only the links that that are active during a given day
so this is also kind of nice I think but I would like to discuss maybe other visualization paradigms
for this kind of network then one thing that would be really interesting I think is to dig
deeper into a visualization paradigm for hierarchical structure of communities meaning that okay in
theory I can either run stochastic block models or Luvain community detections and stop them at a
certain level and then have some kind of hierarchical node structure but how to visualize that is
another question but I think it would be very interesting especially for very large graphs
and then another question is force layouts should we still use them now that everyone is
doing node2vec and all these other things I think yes but maybe there's good arguments against it
and on a more like deeper conceptual level is and this is a question the first one is a question
for people who already have more much more experience in building tools for the social
sciences is how do you kind of further integrate these kinds of methods into existing maybe also
more qualitative social science pipelines so yes it's kind of an open question and how can we
devise something like a research protocol for these kinds of interactive network visualizations
because as you saw in my demo we kind of look at the big nodes we look at the tweets they made
and it gives us some kind of intuition of what's going on in the debate but how can we formalize
such kinds of visual network analysis and I think I mean there's people in the audience who
actually work on this so I will be very interesting for me to talk about this and finally to end on
actually maybe a bit nicer note is that there is the network of force them as we had already said
in the beginning on this website so it is updated every 15 minutes thanks to a data
collection done by my colleague Beatrice thank you very much and so if you go on this website
you can see the retweet network of force them and if you tweet and you can find yourself in
the network also so yeah what do we have here in the middle okay force them itself then there was
Ubuntu they beyond somewhere okay time's up thank you
yes so the question is I mentioned that you can only collect tweets from the last seven days
with the free API this is a limitation but the tool itself just writes into existing
CSV it depends basically so if you do the same keyword search multiple times and it will just
depend to a CSV yes I mean this is the question right now it depends because the question is
what happens on mastodon I don't know all these like if you want to look at political controversies
and such discussions I don't know if mastodon is mature enough yet to or adopted enough yet I think
if you want to look at the fostering community it's great so for this yes but yeah
this kind of profit for the city and so well actually for me that's more aggressive to see the
difference the stricter of this sort of this diagram that we are going to use about the social
of what we are talking about let's see the conference of citizens with human people same in
collection yeah I don't know what to think about that well I don't know which point exactly should
I address because you raised a lot of so so are you okay if I can rephrase so you are concerned
about these kinds of this kind of research also yes because because it can be used to track users
across political camps right yes okay I see so I think it's more about the
representativity of Twitter data for for the wide wider population which of course you're
you're totally right it is kind of a subset of highly politicized maybe also a bit more
educated than average people so you cannot but but this is not what we're trying to do
also you're not trying to infer I don't know actually lecture results based on Twitter data
so I yeah I don't know if I addressed the point now maybe we can take more about it right