Be Confident! Towards Trustworthy Graph Neural Networks via Confidence Calibration

1 Introduction . Graphs are ubiquitous in the real world , including social networks , e-commerce networks , traffic networks , and so on . Recently , Graph Neural Networks ( GNNs ) , which are able to effectively learn the node representations based on the message-passing manner , have attracted considerable attention in dealing with graph data [ 16 , 33 , 39 , 44 , 15 , 2 , 34 ] . To date , GNNs have been applied to various applications and achieved remarkable accuracy , e.g. , node classification [ 16 , 33 ] , link prediction [ 41 ] and graph classification [ 9 ] . However , it is well established that a model with good accuracy is not the only goal , but a trustworthy model is highly desired in many applications , especially in safety-critical fields [ 1 ] . Usually , a trustworthy model implies that it should know when it is likely to be incorrect , in other words , the probability , i.e. , the confidence , associated with the predicted class label should reflect its ground truth correctness likelihood [ 12 ] . For example , in the scene of autonomous driving , the system will adopt the prediction given by the model only when the model has high confidence for its prediction . Otherwise , the decision-making power will be returned to the driver or the system adopts other safer strategies . Recently , the confidence calibration has attracted considerable attention in deep learning [ 12 , 40 , 19 ] , which reveals that many modern neural network models are over-confident on the predictions , i.e. , the prediction accuracy is lower than its confidence . However , it has not been studied ∗Corresponding author 35th Conference on Neural Information Processing Systems ( NeurIPS 2021 ) . in GNNs on the semi-supervised scenario , which gives rise to one fundamental question : will the current GNNs follow the same over-confident property as other neural networks ? A well-informed answer can help us better understand GNNs and enable GNNs to be applied to various areas in a more reliable manner . As the first contribution of this study , we present experiments assessing the relationship between the confidence and the accuracy of Graph Convolutional Networks ( GCNs ) [ 16 ] and Graph Attention Networks ( GAT ) [ 33 ] in the node classification task ( more details can be seen in Section 2 ) , respectively . Surprisingly , we discover that existing GNNs are far distant from being well-calibrated , and more importantly , GNNs tend to be under-confident in their predictions , which is very different from other modern deep learning models that are often over-confident [ 12 , 19 ] . GNNs being under-confident means that many predictions are distributed in the low-confidence range , and therefore , fewer predictions are available for safety-critical applications . Once the weakness is identified , another natural question is : how can we calibrate the confidence on predictions given by GNNs so as to make them more trustworthy ? Essentially , the confidence calibration is to calibrate the outputs ( also known logits ) of original models ( e.g. , GNNs ) , therefore , a straightforward manner is to employ temperature scaling ( TS ) [ 12 ] , OP-families [ 25 ] to learn calibration function using a held-out dataset in a post-hoc way . However , when being applied to graphs , they all ignore the effect of topology , which will inevitably make mistakes during calibration . For example , considering that the logits of two nodes a and b are the same , but node a is similar to its neighbors while node b is not . Apparently , the predictions of GCNs for a should be more confident than b , while the traditional calibration methods , e.g. , TS , will learn the same confidence for a and b , because it does not consider the effect of topology . Moreover , most of them explore calibration functions only in the linear space [ 12 , 18 ] while it is well known that non-linear space contains more complex function transformation which is able to calibrate networks with complicated landscapes well . Even if some works have explored the non-linear space such as Matrix Scaling [ 12 ] , they generally degrade the classification accuracy of the original classifier , while a good accuracy is still a basic requirement by many applications . In this paper , we introduce a topology-aware post-hoc calibration method for GNNs . Specifically , for the logits given by the original classification GNNs , we employ another calibration GCN ( CaGCN ) to propagate confidence , naturally enabling that the confidence of topologically adjacent nodes becomes similar . CaGCN learns a unique temperature t for each node for temperature scaling , thus preserving the accuracy of the original classification GCN . In addition , based on our finding that large numbers of high-accuracy predictions are distributed in the low-confidence range , we design a calibrated self-training model CaGCN-st in which the confidence is firstly calibrated then used to generate pseudo labels with high confidence . The contributions of this paper are three-fold : • We study the trustworthy problem of GNNs , and discover one unique characteristic of GNNs , i.e. , the predictions made by GNNs are usually under-confident . • We propose a novel trustworthy GNN model based on the confidence calibration . Our proposed calibration function has three features : topology-aware , non-linear , and accuracy-preserving . We further design a calibrated self-training GNN model , which can effectively utilize the predictions with high confidence . • Extensive experiments demonstrate the effectiveness of our proposed models in terms of both calibration and accuracy . 2 Notation and Preliminary Study . In this paper , we focus on the calibration of semi-supervised node classification in an undirected attributed graph G = ( V , E ) with the adjacent matrix A ∈ RN×N and the node feature matrix X = [ x1 , . . . , xN ] T. V is a set of nodes and E ⊆ V ×V is a set of edges between nodes . N = |V | is the number of nodes . Here we give the definition of perfect calibration of GNNs as follows : Definition 1 . Given random variables A , X , Y⊆ { 1 , . . . , K } and a GNN model fθ where θ is the learnable parameters , for node i with label yi ∈ Y , zi = fθ ( xi , A ) = [ zi,1 , . . . , zi , K ] T is the output of GNNs ( i.e. , the prediction probability ) , and ŷi = argmaxk zi , k and p̂i = maxk zi , k are the prediction and the confidence respectively . Then we define fθ to be perfectly calibrated as : P ( ŷi = yi|p̂i = p ) = p , ∀p ∈ [ 0,1 ] . ( 1 ) According to Definition 1 , GNN is perfectly calibrated only when the confidence p̂i is exactly equal to the true probability of getting a correct prediction for every node . Next , we take two representative GNNs ( GCN [ 16 ] and GAT [ 33 ] ) as examples to analyze whether they are perfectly calibrated . Specifically , we apply GCN and GAT to four widely used datasets Cora [ 29 ] , Citeseer [ 29 ] , Pubmed [ 29 ] , CoraFull [ 3 ] , and examine whether their results satisfy Definition 1 . To provide more results , we select three label rates for training set ( i.e. , 20 , 40 , 60 labeled nodes per class ) . All the experimental settings follow [ 16 , 33 ] . Since the true probability p can not be exactly known , we take an approximate way to evaluate the calibration as in [ 12 ] . In particular , we first partition the [ 0,1 ] range of confidence into 20 equal bins and then we group the nodes into corresponding bins according to their confidence . After that we calculate the average accuracy of each bin . We expect the average accuracy is equal to the average confidence of each bin , which means the model is approximately perfectly calibrated . For example , if the average confidence of nodes in the bin [ 0.95 , 1.0 ] is 0.96 , and then the classification accuracy in this bin should be 96 % . We illustrate the results of label rate being 20 in Fig . 1 using Reliability Diagrams [ 23 ] here , where the x-axis is the confidence in 20 bins of equal size and y-axis is the average accuracy in each bin . The blue represents the classification accuracy of GCN and GAT while the red is our expectation . More results of label rate being 40 , 60 and other GNN models can be seen in Fig . 8 , Fig . 9 , Fig . 12 , Fig . 13 and Fig . 14 in the appendix . We can see that in all the datasets , the average accuracy of most bins is higher than the average confidence . In other words , these GNNs actually achieve remarkable performance , but they all output low confidence , i.e. , the GNNs are usually under-confident . Please note that this phenomenon of GNNs is very different from other modern neural networks , which are generally known to be over-confident [ 12 , 19 ] . Moreover , as shown in Fig . 2 , we also visualize the confidence distribution of test nodes , where the x-axis is the confidence and y-axis is the density [ 28 ] . The histogram height multiplied by the width is equal to the frequency . The blue represents the confidence distribution of correct predictions while the yellow represents that of incorrect predictions . More results of label rate being 40 and 60 can be seen in Fig . 10 and Fig . 11 in the appendix . We can see that a large quantity of correct predictions are distributed in the low confidence range . The results above indicate that the current GNNs are far from perfect calibration , leading to unreliable confidence . 3 Confidence Calibration on GCNs . In this section , we propose our method to calibrate current GNNs . Given A and X , for a l-layer GCN [ 16 ] , the output of the GCN before the softmax layer can be obtained by : V = Aσ ( · · ·Aσ ( AXW ( 1 ) ) W ( 2 ) · · · ) W ( l ) = [ v1 , · · · , vN ] T , ( 2 ) where W ( l ) is the weight matrix of l-th layer in GCN and σ ( · ) is the activation function . For each node i ∈ { 1 , · · · , N } , our goal is to learn a calibration function which is fed with vi ( often known as the logit of node i ) and outputs a calibrated confidence using a held-out dataset in a post-hoc way . The calibration function should satisfy three points below : ( 1 ) taking the network topology into account ( 2 ) non-linear ( 3 ) preserving the classification accuracy of the GCNs . 3.1 CaGCN : GCNs as Calibration Function . We assume that the ground-truth confidence distribution in a graph has homophily property , i.e. , the confidence of neighboured nodes given by well-calibrated models should be similar , and thus we conduct an experiment to verify this . We employ the classic temperature scaling method [ 12 ] as our calibration function and use the total variation [ 27 ] of confidence as our evaluation , which sums the difference of confidence between all the neighboured nodes . We compare the total variation of confidence before and after confidence calibration , where the results are shown in Table 1 . We can find that the total variation of confidence does decrease after temperature scaling , which verifies our assumption . This inspires us that if a GCN model is well-calibrated , then the confidence between neighbors should be more similar than before . To this end , we find that GCN itself can play the role of calibration function that meets above requirement since GCN is able to propagate node features along the network topology and smooth similar information between neighboured nodes . Therefore , we can employ another l-layer GCN ( CaGCN ) as our calibration function to propagate the confidence along the network topology . Specifically , given the output V of the classification GCN , the logit v′i and confidence p̂i for node i after calibration can be obtained by : V′ = Aσ ( · · ·Aσ ( AVW ( 1 ) ) W ( 2 ) · · · ) W ( l ) = [ v′1 , · · · , v′N ] T , zi = [ σSM ( v′i,1 ) , · · · , σSM ( v′i , K ) ] T , p̂i = max k zi , k , ( 3 ) where σSM ( v′i , · ) = exp ( v′i , · ) ∑Kj=1 exp ( v′i , j ) is the softmax operation . Then the total variation of confidence will surely become lower and the original classification GCN will be calibrated . Please note that although temperature scaling can be directly applied here , compared with GCN , it does not take the network topology into account , which may cause mistakes mentioned in Section 1 . Moreover , temperature scaling only employs a linear transformation , and GCN is able to learn a non-linear calibration function . For a comprehensive understanding of confidence propagation , we make a detailed and visible illustration here . As shown in Fig . 3 , the logits of two nodes a and b are the same , but node a is similar to its neighbors while node b is not . Apparently , the predictions of GCNs for a should be more confident than b . Suppose that a , b and their neighbours are under-confident based on the observation above . If we continue to propagate their logits along the topology using another GCN , the logits of a and its neighbors will tend to be the same . Therefore , if one or more of these nodes are calibrated during the calibration process , all of them will be calibrated as well . The confidence is propagated in this way . On the other hand , looking at another node b , it is as difficult even for manual classification as it is for GCNs . Consequently , the confidence of b should stay still even be lower . However , it will become higher because of the influence from a if we use the traditional calibration method without considering the network topology . Instead , when the network topology is taken into account , the logit of b will be averaged by its neighboured and each dimension tends to 1/K . It will be correctly calibrated when other nodes in the same situation are well-calibrated .

Summary: This paper proposed a confidence calibration method for graph neural networks (GNNs) for semi-supervised node classification problems. Based on the existing researches such as temperature scaling, the authors attempt to evaluate the confidence problem of GNNs and find a unique phenomenon that GNNs including GCN and GAT are less confident in their predictions which seem to be constant to other neural networks. From this observation, they proposed a confidence calibration procedure being aware of the topology of a graph structure and prove the accuracy-preserving property of their method. They also provided an effective optimization procedure for training their objective. Intensive experiments demonstrated the improvements of their proposed method with regard ECE and classification accuracy.