## 3 Materials and Methods
### Bubble Model Training Strategy
This labeling is central to training the supervised classifier, as it allows the model to learn the latent features of a pre-instability regime. Thus, samples very close to and before the critical point (which we know in advance) are labeled positive samples (1). On the other hand, all those samples that are well away from the critical point and after the critical time \(t_{c}\) can be labeled as negative class (0). How close they are to the critical point is a matter of empirical matter, the \(r\)-parameter. However, throughout history, the number of critical points is smaller than on non-bubble days so that we will have a class imbalance problem. This strategy is motivated by the conceptual framework of the Log-Periodic Power Law Singularity (LPTLS) model [18], which interprets bubbles as regimes characterized by super-exponential growth with log-periodic oscillations culminating at a singular point \(t_{c}\), analogous to a phase transition in statistical physics. However, in contrast to the LPTLS  
Figure 5: Time series of the S&P500, their respective values of long-range returns, and slopes using \(\delta=500\) days. The divergence between long-range returns and slopes is \(d_{t}=r_{t}-s_{t}\). The vertical stripes in yellow highlight the periods of instabilities between the maximum value of the index and its lowest value. The strip (a) represents the Black Monday of 1987, (b) the dot-com crisis of 2000, (c) the Subprime crisis of 2008, (d) the COVID-19 outbreak, and (e) the stock market decline of 2022. Note: The index values and features have been scaled to values between 0 and 1 to improve the readability of the time series and their relationship to each other. literature, we do not estimate or calibrate the LPLLS model directly to infer \(t_{c}\). Instead, we use domain knowledge to define \(t_{c}\) ex-post as the local maximum in price before a well-defined market crash. This simplification avoids the difficulties of fitting the LPLLS model, which has many nonlinear parameters and often leads to unstable or sensitive estimates, as noted in [PERSON] et al. [58]. The parameter \(r\) can be interpreted as the empirical horizon of warning or alert. While it is not derived from a specific theoretical threshold in the LPLLS dynamics, it is consistent with the idea that bubbles exhibit distinct dynamics shortly before their collapse. A key reference supporting this empirical perspective is [PERSON] et al. [59], which showed that LPLLS-based end-of-bubble signals successfully anticipate several historical crashes, including those in 1987, 2000, and 2008, but also generate warnings before more minor corrections or 'other' drawdowns. To tackle the class imbalance problem, we will consider the Balanced Random Forest (BRF) algorithm, which has proven to be satisfactory in other problems in various data domains [72], in churn prediction [73], modifications combining the BRF and nearest neighbor algorithm to identify critical areas in the dataset [74], and also in the identification of RNA codes in genetics [75]. The BRF works in the same way as the traditional Random Forest [76], with the difference that in each iteration, a bootstrap sample is taken from the minority class. The same number of samples is taken with replacement for the majority class (see [72] for more details). To train the BRF-based classifier, we must generate the representations of the original volatility and return samples with the GGRBMs already trained. So, the BRF input features will be the values of the last hidden GGRBM units.