Getting a closer look: More on visualizing results from stylometry with Gephi
This post is a follow-up post to my last brief post on the new version of the stylo script and its output for visualization with Gephi. Today, I just want to report on what Maciej told me about the technical details, and to show some more graphs resulting from my data.
First things first, then. Here is how the data for input into Gephi is constructed (thanks to Maciej for the exaplanations). The values for the edge weighs are derived from the distance matrix, but in a slightly more sophisticated manner than what I suggested last time. The basic idea is that for any text, it is not only interesting which the nearest neighbor is (i.e., which the one most similar text is), but also which the second and third (and so on) nearest neighbors (or most similar texts) are. In Maciej’s implementation, for any one text, the first three most similar texts are considered. Each of these three pairs is assigned a value, decreasing with their similarity rank: the first/closest gets a 1.0, the second a 0.2, and the third a 0.05 value. This is just one possible implementation; the values can of course be adjusted right in the script; instead of a logarithmic one, you could also use a linear scale of values; also, more than three texts could be considered. When using the bootstrap consensus tree method in the stylo script, the values for each of the three pairs are added whenever different runs result in identical pairs, so the bootstrapping principle is realized here as well, but in a slightly different fashion. Depending on the number of texts and the number of iterations, the range of values for the individual pairs of texts increases significantly beyond the basic three values. Also, if there is a mutual relation between two texts, the weights are added. Both mecanisms create quite a bit of differentiation of the possible values.
Once I had understood this, I felt better about experimenting some more with my French drama data; here is what I found. I made another run with the stylo script, this time using bootstraping instead of a single cluster analysis. The range of edge weights was quite large, between 0.05 to 34.0, with a relatively homogeneous spread of the data over the range. After importing the data into Gephi, I also extracted quite a few attribute values from my original file names using a very neat feature of Gephi’s Data Laboratory: you can create a new column and automatically populate it using a Regular Expression operating over an already existing column. My filenames include quite a bit of metadata: they are constructed on the schema “Author_genre-form-date-Title”, for example “Scarron_CO-V-1650-Corsaire” for Scarron’s comedy in verse from 1650 called Corsaire; getting different parts of this into different columns is really easy and allows you to assign category labels as you see fit, and also to use these attributes for ranking and partitioning of the network (with a little bit of help from Clément Levallois, I also managed to get the data type in these columns right; the “list_string” format from my initial column needs to be changed to just “string” for partitioning to work correctly.
Having the various categories (like genre, decade, form, and author) available as separate attributes in the data table allows to flexibly switch the node labels (or, unless you have too many values for your attribute, colors) from one category to another, which is very convenient when you are interested in how the overall similarity or proximity values correspond to authorship, genre, form or date, as I happen to be. Fig. 1 “Prose, verse or mixed form in 223 plays” shows an example for this: while the topological grouping shows the similarity of the plays, the coloring corresponds to the form of the plays: red is verse, green is prose, and blue is mixed prose and verse.
Another very useful technique I also learned from Clément Levallois at the Nijmegen Workshop in eHumanities was to have Gephi run a Modularity Analysis which detects communities in the network, helping to distinguish closely related topological subgroups of nodes from each other. Depending on the granularity you define in the settings, there can be a clear match between subgroups in the network and the communities (for me, this was the case with around 10 communities). However, it is actually more interesting to use a somewhat finer granularity in order to see areas of a possible mismatch between communities and subgroups, or simply of smaller communities inside of the subgroups; this was the case for me when I used 20 subgroups). To adjust the number of subgroups you get, you need to adjust the “resolution” setting when running the modularity test.
Fig. 2 shows a small part of the graph where the coloring corresponds to “communities”, while the topological grouping is based on the similarity scores. The communities help separate some larger subgroups into two parts, as the red and dark magenta one in the upper right of the crop; or it shows that there may be an isolated member of a “community” within another subgroup, like with the one light green node in the middle of the pale green subgroup. Interestingly, the communities do correspond in many cases to the play’s authors, but bring together several authors in quite a few cases as well (sorry for not showing this here, but the labels on the nodes are not very readable in the static files, even with the sizes adjusted and scaled).
Using another statistical analysis lets you analyse your network a bit further; for example, “Eigenvector Centrality” can be used (according to the relevant Wikipedia article, it is “a measure of the influence of a node in a network”). Then, using the ranking function, the size of each node can be linked to its centrality score.
Fig. 3 “Centrality for 223 plays” shows that there are a few particularly well-connected plays in my drama network. Interestingly, the plays with the highest centrality scores are not only the most famous ones: after Molière, there come Dancourt and Regnard, and then only Racine and Pierre Corneille (the fact that Dancourt and Regnard wrote quite a few plays, though not more than Racine or Corneille, so there should be a way to control for number of plays by the same author).
Of course, you want to look at these visualization in Gephi itself, because they really only make sense when can interact with them, switch on/off certain labels and find out things in this way (here is the relevant GEXF file). Still, I hope to have shown that the network visualization of results from stylometry makes sense, especially when you are interested in more than one relevant factor or signal in your data.
OpenEdition suggests that you cite this post as follows:
Christof Schöch (May 13, 2013). Getting a closer look: More on visualizing results from stylometry with Gephi. The Dragonfly's Gaze. Retrieved December 7, 2024 from https://doi.org/10.58079/nwer