{'fraction_non_alphanumeric': 0.0333027803238619, 'fraction_numerical': 0.004949587534372136, 'mean_word_length': 4.760647659274904, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Semantic Similarity Measures for Topological Link Prediction

The semantic approach to data linked in social networks uses information extracted from node attributes to quantify the similarity between nodes. In contrast, the topological approach exploits the structural information of the network, e.g., nodes degree, paths, neighbourhood breadth. For a long time, such approaches have been considered substantially separated. In recent years, following the widespread of social media, an increasing focus has been dedicated to understanding how complex networks develop, following the human phenomena they represent, considering both the meaning of the node and the links structure and distribution. The link prediction problem, aiming at predicting how networks evolve in terms of connections between entities, is suitable to apply semantic similarity measures to a topological domain. In this paper, we introduce a novel topological formulation of semantic measures, e.g., NGD, PMI, Confidence, in a unifying framework for link prediction in social graphs, providing results of systematic experiments. We validate the approach discussing the prediction capability on widely accepted data sets, comparing the performance of the topological formulation of semantic measures to the conventional metrics generally used in literature.


Introduction
For a long time, the semantic and topological approaches to the similarity in complex networks have been considered substantially separated. The semantic approach uses information extracted from node attributes to quantify the similarity between nodes, while the topological approach exploits the structural information of the network, e.g., nodes degree, paths, neighbourhood [4,7]. A set of techniques have been proposed in the literature for the link prediction, based on topological or semantic similarity. The idea behind both approaches is that similar nodes will develop a link in the future. Such similarity is structural in the topological approach, feature-based in the semantic approach, but can be applied to the same data. The link prediction problem, aiming at predicting how networks evolve in terms of connections between entities, is usually addressed with a topological approach. Still, we consider also suitable to apply the semantic approach to a topological domain. Formally, the link prediction problem consists in predicting the evolution of a given network at time t in terms of new links that will appear in the network in a future time t'. Forecasting a new link can be valuable for recommending, advertising or generating support, e.g., analysing social networks. E.g., in co-authorship networks, nodes represent authors, links represent co-authorship and prediction forecasts collaborations. Although the two approaches have been integrated into hybrid similarity frameworks, a dichotomy still exists, and the most significant interest in link prediction literature has been devoted to the topological approach, easier to exploit, and domain-independent.
The key idea is that the web-based similarity measures use statistics from a search engine which can be interpreted in terms of the structure of the Web (i.e., of the indexing network of search engines). Therefore, such measures indirectly embed a measure of documents' neighbourhood topology. This work shows how semantic similarity measures (i.e., average confidence, PMI, NGD, X-squared) can be reformulated in a topological view and used in an associated graph for link prediction, starting from the concept that a substantial equivalence exists between the two approaches to the Link Prediction problem [9,12]. The advantages of modelling both classes of similarities in a single comprehensive model are apparent: a unified model provides the opportunity to use semantic measures in a topological framework and vice versa. In the first section, we introduce the link prediction problem in our unified framework. In the second section, we present a mapping of the semantic measures to the topological domain. In the third and fourth sections, we experimentally validate the proposed approach, discussing the prediction capability on widely accepted data sets, comparing the performance of the topological formulation of semantic measures to the conventional metrics generally used in literature. In the fifth section, conclusions are drawn.

Previous Research
In previous works [9,12] we studied the feasibility of a bidirectional mapping from topological measures to semantic formulations and vice versa and demonstrated the correctness of the unified approach. The comparison has been conducted on web-based semantic proximity measures, emphasizing their ability to express topological concepts by exploiting the capabilities of search engines. In a preliminary phase we performed an in-depth analysis of such measures. We extended the comparison to other proximity measures that can be applied to a web-based domain even if they are not created for that context, obtaining promising results on Pointwise mutual information (PMI) [26]; Normalized Google Distance (NGD) [6]; PMING distance [8], which is a combination of the previous sensibly improving measuring performances in clustering; Confidence; Average Confidence, seen as a combination of directional Confidence either way; Chi-square. Such measures have been tested on image classification, using image metadata and captions, and on text-based emotion recognition. A proximity model for randomized Heuristic Semantic Search (HSW) [14] has been experimented in several variations to guide the navigation through network links, where semantic measures can be used as heuristics to choose the step-by-step path instead of a random or a rule-based selection from candidate nodes, ranked using an aggregation function on the results of several random tournaments. Previous contributions also include the extension of the context-based Image Semantic Similarity [10] to a new class of set similarity measure to be used on social communities, using different combination schemes. The study of distances based on random walks, which are robust and computationally efficient for context extraction in large unknown graphs, lead to exciting results in terms of topological goals, e.g., convergence, path length, and minimal solution. Such models and techniques have been systematically tested on benchmark data sets, e.g., social networks, bibliographic repositories, recommender systems, and semantic associations between terms and emotional tags. The previous work laid the foundation for investigating algorithms for ranking graph nodes for many applications, including link prediction and reconstruction.

Topological Formulation of Semantic Similarity
We start considering as information source a search engine S, providing statistics about the occurrence, co-occurrence and probability of terms in a context [13], i.e. the frequency of single terms and terms pairs, used in web-based semantic proximity measures. Consider the terms-to-documents graph G S = (V, E) indexed by the search engine. Typify G S as a bipartite graph where the set V = T ∪ D can be partitioned in two subsets. Vertices in T represent indexed terms, vertices in D represent the indexed documents. The edges (u, v) ∈ E are the occurrences of terms in documents, i.e. (u, v) is the relation "u occurring in If we consider the sample graph G S shown in Fig. 1, it is apparent that all the information required by the semantic similarity measures can be defined in terms of neighbourhood and graph parameters of G S , with the constraint of knowing the considered entities, i.e., the frequency/occurrence of a term u, the co-occurrence of u and v, and the corresponding probabilities and In such formulation Γ (u) is the set of documents that contain a term u, and a document d is a common neighbour of the terms u and v, d ∈ Γ (u) ∩ Γ (v), if d contains both terms. Conversely, Γ (d) is the set of terms contained in a given document d and t ∈ Γ (d 1 ) ∩ Γ (d 2 ), if t occurs in both d 1 and d 2 .  [2] formulation is straightforward in terms of topology: The original Confidence index TConf is not symmetric; thus, we define the Average Topological Confidence [13]: Topological Pointwise Mutual Index. The Pointwise Mutual Index (PMI) [5] can be expressed topologically as: Topological Normalized Google Distance. The Normalized Google Distance topological formulation results in [6]: Chi-squared Coefficient χ 2 . The Chi-squared Coefficient χ 2 [20] can be adapted as follows: Web-based similarity measures such as NGD are explicitly designed to count the frequencies with which terms occur in a corpus, e.g. the documents indexed in a search engine; such corpora indeed represent a bipartite graph, where document nodes are connected to word nodes, and vice versa. In some cases we will not be able to know the real value of M , representing the total number of indexed documents. In this case, we can set the parameter as a random number greater than any occurrence of terms or pairs (see [6,13]), M > |V |, because it simply serves as a normalisation value.

Preprocessing
Before the evaluation process, data sets are cleaned and randomised; the following elements are removed since they are not exploited in our approach: -multiple edges between the same pair of nodes; -self-loops; -additional information associated with edges, e.g. text attributes.

k-fold Validation and the 0-Tail Issue
A k-fold validation is performed on each data set, choosing k = 10. This setup implies examining particular cases that might appear. The most relevant issue to consider is that entities can appear as 0-degree nodes because all the incident edges have been moved in E T E (k). Therefore, the calculated value for pairs including such nodes may be incorrect for some measures, while others are not affected. In particular: -In Average Confidence, the degrees of nodes appear as denominators in a fraction; thus, if at least one of them is zero, the case in which the predicted value is infinite is replaced with 0. -In Jaccard, if both nodes have degree 0, the predicted value is 0 0 , which evaluates to NaN and is replaced with 0.
-In PMI, it is enough to have a 0-degree node to get a 0 0 value, again NaN, replaced with −∞.
-In NGD, in case of division by zero, the value is replaced with +∞.
This solution is correct from the logical point of view, because calculating neighbourhood-based similarity measures between two nodes u and v when one, or even both of them, have degree 0, i.e. have no neighbourhood, leads to a 0-tail [3]. The table containing the prediction values is sorted to produce the ranking induced by similarity measures; in case of distance measures, e.g. NGD, it is sufficient to reverse the rank order prior to the evaluation.

Evaluation Metrics and Approach-Dependent Considerations
In our approach, Link Prediction can be seen as a Binary Classification (BC) problem because each edge in the E P OT set either belongs or not to E T E , used to test the prediction. The following quantities are defined to evaluate the performances of our classification model in the BC view: The length of P alg and N alg depends on a threshold τ = |E T E | [19]. Links appearing in the top |E T E | positions in the rank are thus classified as positive, i.e. likely to appear at time t + 1. The fraction of links also appearing in |E T E | constitutes the T P set, while the remaining links correspond to the F P set. On the other hand, edges ranked lower than |E T E | are classified as negative, and part of them will not be included in the |E T E |, forming the T N set. The remainder composes the F N set. The traditional evaluation metrics for classification are Accuracy, Precision, Recall and F1. It is worth noticing that the choice of our threshold τ = |E T E | induces additional constraints. In particular, the number of F P instances is equal to F N; therefore, in our approach to the link prediction problem, Precision, Recall and F1 all assume the same values and can be considered equal.
Further considerations are required regarding Accuracy. Our algorithm evaluates the similarity measures for each edge in the set The cardinality of the set E T E is an upper bound for the T P , F P and F N, usually small if compared to |E P OT |. Since |E P OT | = T P + T N + F P + F N, it follows that T N T P + F P + F N. Recalling that accuracy is defined as ACC = T P +T N T P +F P +T N+F N , and given that T N represents the highest quota of the total edges, its value will always be ≈ 1, thus losing its significance. Since Precision considers the top |E T E | edges in the rank induced by similarity measures and counts the positive hits to evaluate performances, in some cases it could produce excessively low scores, not reflecting the real performance of the ranking as a whole. Due to our constraints and considerations, we decided to focus on an additional evaluation metric. Considering the position of the F N values in the rank, to detect whether most of them lay close to the τ ranking position (i.e., the frontier) or, instead, towards the bottom, it is useful to plot the Receiver Operating Characteristic (ROC) curve and calculate the Area Under the Curve (AUC) [27] value. A random predictor with uniform distribution returns AUC values close to 0.5; a higher value denotes a ranking where the positive edges are generally located in the upper section, and 1 indicates perfect rank. Since the accuracy is not significant in our case, we focus on precision and AUC in order to have more general, inter-dataset, key performance indicators.

Experimental Results
In the experiments, the mapped measures have been compared to conventional, widely used topological measures for Link Prediction, i.e. Common Neighbours [19], Jaccard [15], Adamic Adar [1] and Resource Allocation [29]. In Tables 2  and 3 the results are averaged on 10 folds; in bold, the best mapped semantic measure for each data set.
Results show that the performance of the mapped semantic measures is generally comparable to topological measures. The χ 2 index delivers highest Precision among the mapped measures in five out of nine experiments, with the remainder equally divided between Average Confidence and NGD. The reason for the higher Precision of AA and RA lies in the information about the neighbourhood up to a distance of 2 links traversal. CN and Jaccard, as well as our mapped measures, exploit only the direct neighbourhood of nodes, and their performance can be therefore compared. The exception is PMI [11], which is not a suitable correlation metric when only a few observations are provided. It is not surprising that the worst performances of semantic-derived measures are obtained with the smallest data sets, where node degree is in the order of few tens or hundreds.    Regarding the AUC, the best performances are obtained with Average Confidence, which is also comparable to topological alternatives. In all but few cases, the mapped measures achieve consistent results on all the data sets. In Table 4, the results of the 10-fold validation process are provided for the Netscience data set. It is apparent that all the measures show a coherent behaviour across all the folds, with only a few exceptions; such behaviour is shared across all the experiments.

Conclusion
In this paper, we introduce a new framework for the Link Prediction problem, aiming at giving a unified view of the two currently investigated approaches, topological and semantic. Our framework allows the use of semantic proximity measures to perform Link Prediction in a topological domain by remapping them according to a formal rule. Experiments have been held on data sets of different sizes, spanning from hundreds to tens of thousands of nodes. Different types of networks are represented, e.g., collaboration and e-mail, to evaluate the performance of semantic measures, i.e. Average Confidence, PMI, NGD, and X2, in a topological context. As a general conclusion, our experimental evidence shows that Average Confidence is comparable to classical topological ranking measures in terms of AUC; while χ 2 returns better Precision. We also observed that, in agreement with the literature, the applicability of measures derived from web-based semantics improves as the size of the network increases.