# Artificial Intelligence to Reshape the Healthcare Ecosystem
## 2 AI Techniques for Healthcare
### Graph Neural Networks
The general framework can be described as follows for a node \(v_{i}\):  
\[\mathbf{m}_{i}^{(l+1)}=\text{AGGREGATE}^{(l)}\Big{(}\{\mathbf{h}_{i}^{(l)}:j \in\mathcal{N}(i)\}\Big{)}, \tag{11}\]  
\[\mathbf{h}_{i}^{(l+1)}=\text{UPDATE}^{(l)}\Big{(}\mathbf{h}_{i}^{(l)},\mathbf{ m}_{i}^{(l+1)}\Big{)}, \tag{12}\]  
where \(\mathbf{h}_{i}^{(l)}\) is the feature vector of node \(i\) at layer \(l\), \(\mathcal{N}(i)\) denotes the set of neighbors of node \(i\), \(\text{AGGREGATE}^{(l)}\) is a function that aggregates the messages from the neighbors, and \(\text{UPDATE}^{(l)}\) is a function that updates the node feature based on its previous feature and the aggregated message. Instead of aggregating information from all neighbors, _GraphSAGE_[50] samples a fixed-size set of neighbors to maintain computational efficiency. It defines several aggregation functions to combine information from neighbors. Common aggregation functions include mean aggregator_, _LSTM aggregator_ (see Section 2.3.1 for a general LSTM description), and _pooling aggregator_:  
\[\mathbf{h}^{(k)}_{\mathcal{N}(v_{i})}=\text{mean}\Big{(}\{\mathbf{h}^{(k-1)}_{u},\forall u\in\mathcal{N}(v_{i})\}\Big{)} \tag{13}\]  
\[\mathbf{h}^{(k)}_{\mathcal{N}(v_{i})}=\text{LSTM}\Big{(}\{\mathbf{h}^{(k-1)}_{u},\forall u\in\mathcal{N}(v_{i})\}\Big{)} \tag{14}\]  
\[\mathbf{h}^{(k)}_{\mathcal{N}(v_{i})}=\text{max}\Big{(}\sigma\Big{(}\mathbf{W }_{\text{pool}}\mathbf{h}^{(k-1)}_{u}+\mathbf{b}\Big{)},\forall u\in\mathcal{N }(v_{i})\Big{)} \tag{15}\]  
where the matrix \(\mathbf{W}_{\text{pool}}\) and \(\mathbf{b}\) are trainable. Concerning the update function, the updated node representation is computed as  
\[\mathbf{h}^{(k)}_{i}=\sigma\Big{(}\mathbf{W}^{(k)}\Big{[}\mathbf{h}^{(k-1)}_{ i}\|\mathbf{h}^{(k)}_{\mathcal{N}(v_{i})}\Big{]}+\mathbf{b}^{(k)}\Big{)} \tag{16}\]  
where \(\|\) denotes concatenation, \(\sigma\) is a non-linear activation function (e.g., ReLU), and \(\mathbf{W}^{(k)}\) and \(\mathbf{b}^{(k)}\) are trainable parameters for layer \(k\). Graph pooling layers are used to reduce the number of nodes in the graph, similar to down-sampling in CNNs. A common method is _graph coarsening_[51], which clusters nodes and merges them. We indicate it generically with the following expression:  
\[\mathbf{H}^{(l+1)}=\text{POOL}\Big{(}\mathbf{H}^{(l)},\mathbf{A}^{(l)}\Big{)}. \tag{17}\]  
For node classification, the output layer produces a label for each node:  
\[\mathbf{Z}=\text{softmax}\Big{(}\mathbf{H}^{(L)}\mathbf{W}^{(L)}\Big{)}, \tag{18}\]  
where \(L\) is the final layer, and \(\mathbf{Z}\) is the matrix of class probabilities for each node. For graph classification, the node features from the final layer can be pooled into a graph-level feature vector, followed by a fully connected layer and a softmax activation, as follows:  
\[\mathbf{H}^{(l+1)}=\sigma\Big{(}\mathbf{\tilde{A}}\mathbf{H}^{(l)}\mathbf{W} ^{(l)}\Big{)}, \tag{10}\]0  
Graph attention networks (GATs) [52] introduce an attention mechanism to graph neural networks, enabling the model to learn the importance (through attention weights) of neighboring nodes when aggregating their features. The attention mechanism is further detailed in Section 2.4.4. This approach allows GATs to weigh the contributions of different neighbors differently, providing a more flexible and powerful solution to capture complex relationships. The _attention mechanism_ assigns different weights to different neighbors based on their features and importance. _Self-attention_ computes attention scores for each node-neighbor pair using learnable parameters. _Multi-head attention_ improves the stability and expressiveness of the model by using multiple attention heads. The interested reader can find a useful introduction to other similar variants in [45]. Several libraries have gained popularity for implementing and working with GNNs. They provide efficient implementations of different GNN data models and integration with deep learning frameworks, such as TensorFlow and PyTorch.