# Artificial Intelligence to Reshape the Healthcare Ecosystem
## 2 AI Techniques for Healthcare
### Recurrent Neural Networks  
It often happens that the data to be processed must be considered as a temporal sequence. After all, natural processes evolve according to temporal processes or time series that characterize their lifetime. The models presented above have characteristics that are well suited to modeling snapshots of these processes, and not their evolution. For this reason, recurrent neural networks (RNNs) have been introduced [58].  
Given their nature of allowing handling sequential data, they have been successfully applied in a variety of fields, such as natural language processing (NLP), sentiment analysis of a piece of text, named-entity recognition (NER), speech recognition, text-to-speech and speech-to-text, time-series prediction of stock prices, market trends, and economic indicators, generation of descriptive text for video content, and control of dynamic systems in real time. Clearly, all these features and applications can easily find space in healthcare [59; 60]. Some typical examples include aid in medical diagnosis by the analysis of sequential medical data [61; 62; 63], monitoring of patient vitals over time to detect anomalies [64], analysis of epidemiological data for tracking infections, and much more [65; 66].  
The development of recurrent networks has occurred over time, with several proposals that have followed one another. In this paper, we refer to the two most popular architectures, which are long short-term memory (LSTM) [67] and gated recurrent unit (GRU) [68]. The interested reader can find a description of RNN development in [58].  
These networks are called \"recurrent\" since they perform the same task for every element of an input sequence in a chain of operations, providing an output depending on previous computations. An RNN processes an input sequence \(\mathbf{x}=(x_{1},x_{2},\ldots,x_{T})\) by maintaining a hidden state \(\mathbf{h}_{t}\) at each time step \(t\). The hidden state is updated using the previous hidden state and the current input.  
The basic RNN operation can be illustrated as follows:  
\[\mathbf{h}_{t} =\sigma_{h}(\mathbf{W}_{hx}\mathbf{x}_{t}+\mathbf{W}_{hh}\mathbf{ h}_{t-1}+\mathbf{b}_{h}) \tag{20}\] \[\mathbf{y}_{t} =\sigma_{y}(\mathbf{W}_{hy}\mathbf{h}_{t}+\mathbf{b}_{y}) \tag{21}\]  
where \(\mathbf{h}_{t}\) is the hidden state at time step \(t\), \(\mathbf{x}_{t}\) is the input at time step \(t\), \(\mathbf{y}_{t}\) is the output at time step \(t\), \(\mathbf{W}_{hx}\), \(\mathbf{W}_{hh}\), and \(\mathbf{W}_{hy}\) are weight matrices, \(\mathbf{b}_{h}\) and \(\mathbf{b}_{y}\) are bias vectors, and \(\sigma_{h}\) and \(\sigma_{y}\) are activation functions, such as tanh or ReLU.  
RNNs can have different architectures. A \"one-to-many\" architecture refers to a situation where the RNN receives a single input and produces a sequence of outputs. A \"many-to-one\" architecture refers to the situation where the network processes a sequence of inputs and generates a single output. Finally, a \"many-to-many\" architecture refers to processing a sequence of inputs and the generation of a corresponding sequence of outputs.  
The most popular RNN libraries are offered by TensorFlow, PyTorch, and Keras. However, Apache MxNet [69], Microsoft Cognitive Toolkit [70], and Chainer [71] are widely used in the research and development of RNN models, each offering unique features that cater to different requirements and preferences.