## 3 Materials and Methods  
In this section, we describe the model's components for early detection of a phase change and strategies for training it.  
The system consists of two independent models. The first model allows us to detect if we are in a financial instability condition, which is defined as a sample located in a zone of high volatility and negative price variations. On the other hand, in periods before a situation of instability, the prices have positive or negative variations, which on average tend to be zero (daily basis), and normal volatility. This situation is essential since it allows us to recognize if we are already in a phase change. This model comprises a classical Bernoulli-Bernoulli RBM (BBRBM) and a traditional feedforward network. With a simple Naive model, we can generate as many unstable samples as we want and train the ANN as a classifier to detect whether or not the incoming sample corresponds to an unstable sample (See Section 3.2). Essentially, we capture the system's state with two measures: the market index or stock price variations and the volatility.  
The second model lets us detect whether we are in a bubble condition. A bubble consists of a prolonged and rising rate of price or index increase, accompanied by oscillations of increasing frequency until the critical moment \(t_{c}\), when a phase change occurs, and the system enters a stage of significant negative price variations and high volatility. To detect this phenomenon, binary representations of volatility and price variations alone are insufficient because the bubble process is long-lasting and can take years [18]. Consequently, we need to include other features for this long-run accumulation process. This paper primarily considers two features: (a) the index slopes at time \(t\) and (b) the cumulative index changes at time \(t\). The first represents the price rise (or fall) in a unit of time before the critical time \(t_{c}\). These values are known to be very high when we approach the critical point, i.e., price acceleration increases more and more. The second feature type is the cumulative returns over more than 250 days (approximately one year). We know that these cumulative returns are unusually high near the critical point with a very low probability of occurrence. Unlike the first instability detection model, we trained a Gaussian-Gaussian RBM (GGRBM) in this instance. This choice is to avoid losing information in the discretization process. Therefore, all the features that enter this RBM are continuous, ensuring no information is lost.  
Figure 2 shows the general warning model. The BBRBM's mission is to capture complex representations of the system in the hope that it has some level of discriminative power to distinguish between a normal and unstable state. The GGRBM's task goes in the same direction but to identify bubble periods or an approximation to a critical time \(t_{c}\). The information in these high-level representations embedded and learned by the RBMs can help predict the properties of a specific set of financial index samples. However, since the RBM is a generative model, we can use it, mainly the GGRBM, to reproduce synthetic samples under certain fixed interest conditions and find the bubble probability, as seen in Section 4.5.