1 Introduction

Rocking is the partial uplift of a structure and its oscillation about two pivot points. This response is observed during the seismic excitation of rigid block-like structures that are free-standing on a rigid base. Many different systems can be considered as rigid block-like structures, for example building contents and equipment (Di Sarno et al. 2019). Moreover, there are structures, e.g. masonry walls, or rocking bridge piers that may also exhibit rocking during an earthquake, while slender structures may rock on their foundation and/or overturn (Housner 1963; Ishiyama 1982; Yim et al. 1980; Yim and Chopra 1985). If the overturning risk is somehow controlled, i.e. a “safe” rocking response is ensured, the rocking motion can potentially offer an efficient, low-cost anti-seismic structural design.

The rocking motion is a highly nonlinear problem since it involves a wide range of nonlinear physical phenomena, e.g. impact, contact, uplift and sliding. The problem can be solved either directly handling the equation of motion, or using advanced numerical tools such as software based on the Finite Element, or the Discrete Element method. Both numerical simulation approaches introduce nonlinearity due to impacts and the sudden change of the pivot point. Many interesting studies that concern the rocking motion are available in the literature. For example, Dimitrakopoulos and DeJong (2012) revisited the dynamic response of the rocking block subjected to base excitation and provided closed-form solutions and similarity laws that are shedding light on the fundamental aspects of the rocking block problem. Furthermore, Diamantopoulos and Fragiadakis (2019) presented a novel modeling approach based on equivalent Single-Degree-of-Freedom (SDOF) oscillators for the seismic response assessment of free-standing, rigid or flexible, pure rocking systems. Recently, a macroelement for the prediction of the planar cyclic response of inelastic rocking members was proposed by Avgenakis and Psycharis (2020).

Machine learning (ML) is a branch of artificial intelligence (AI) that has the ability to automatically learn from data and past experience in order to identify patterns and make predictions with minimal human intervention. The recent progress in ML was driven by the development of new learning algorithms, while today there is an ongoing explosion of computation tools (Jordan and Mitchell 2015). This is also due to the vast applications of data-intensive ML methods throughout science, technology and commerce. Machine learning methods are able to find valuable underlying patterns within complex data that otherwise would have been very challenging to discover. The hidden patterns and knowledge about a problem are then used to predict future events and perform all kinds of decision making.

A wide range of Machine Learning applications in different fields of Civil Engineering can be found in the literature (Reich 1997; Melhem and Nagaraja 1996; Vadyala et al. 2022; Sun et al. 2021; Cevik et al. 2015; Avci et al. 2022; Flah et al. 2021). The complexity and the uncertain nature of Earthquake Engineering problems along with the availability of data from experiments and numerical simulations have made the application of ML techniques quite popular also in this field. For instance, Mangalathu et al. (2020) used ML algorithms in order to classify earthquake damage to buildings, while Zhang et al. (2018) adopted ML techniques for assessing post-earthquake structural safety. Moreover, Kiani et al. (2019) implemented ML methods for the prediction of structural response and the development of fragility curves, while Sivapalan (2021) used ML algorithms for the performance prediction of rocking shallow foundations during earthquake loading. A comprehensive literature review on the ML applications in Earthquake Engineering can be found in Xie et al. (2020) who discuss ML applications to various aspects of seismic risk mitigation.

Our study discusses the use of supervised machine learning (ML) algorithms in order to predict and/or classify the response of rigid blocks subjected to ground motions of different properties, e.g. frequency content, peak ground acceleration. ML algorithms are useful for problems where a large number of simulations are required, but most importantly, once an ML tool has been trained, it can be easily distributed, e.g. as a file, or as a web-page, and be used a generic model that rapidly produces inexpensive answers. A relatively simple and a more sophisticated classification algorithm are considered. More specifically, the two algorithms compared are the k-Nearest Neighbor (k-NN) and the support Vector Machine (SVM) algorithms, respectively. The performance of the models are first compared using full sine pulses, a problem that is well studied in the literature. Their application to natural ground motion records is subsequently discussed. The training performance of the algorithms were evaluated using the k-fold cross-validation method.

2 The rocking block problem

The rectangular block with height 2h and width 2b shown in Fig. 1 is considered. The rocking block has size parameter \(R=\sqrt{h^2+b^2}\) and slenderness \(\alpha =\arctan {(b / h)}\). The coefficient of friction between the block and the base is assumed infinite so that there is no sliding. Thus, the equation of motion of a rigid block subjected to a horizontal ground acceleration \(\ddot{u}_g(t)\), as proposed by Housner (1963) is:

$$\begin{aligned} I_0\ddot{\theta }(t) + m g R {\textit{sin}}[\alpha {\textit{sgn}}(\theta (t))-\theta (t)]= - m\ddot{u}_g R {\textit{cos}}[\alpha {\textit{sgn}}(\theta (t))-\theta (t)] \end{aligned}$$
(1)

where \(I_0=(4/3)mR^2\) is the moment of inertia with respect to the pivot point, m is the mass of the block, \(\theta \) is the response rotation and g is the gravity acceleration. The above equation corresponds to a Single-Degree-of-Freedom problem, since the rotation, \(\theta \), is the only degree of freedom.

Fig. 1
figure 1

Geometry of the rigid rocking block

Rocking initiates when \(\ddot{u}_g \ge \alpha _{g,{\textit{min}}} = g{\textit{tan}}\alpha \), i.e. when the acceleration of the ground motion exceeds the value \({\textit{tan}}\alpha \) in terms of g. Replacing \(I_0\) to the above equation and defining the quantity \(p=\sqrt{3g/4R}\) as the frequency parameter of the rocking block, a compact form of the equation of motion is defined:

$$\begin{aligned} \ddot{\theta }(t)= - p^2 \left[ {\textit{sin}}[\alpha {\textit{sgn}}(\theta (t))-\theta (t)] + \frac{\ddot{u}_g}{g} {\textit{cos}}[\alpha {\textit{sgn}}(\theta (t))-\theta (t)]\right] \end{aligned}$$
(2)

Energy dissipation in rocking bodies takes place instantaneously when an impact occurs, i.e. when the rotation changes sign at \(\theta =0\). The per-cycle of free vibration energy dissipation for a rigid rectangular block that rocks on a rigid base is described by the restitution factor r and is independent of the amplitude of vibration. The ratio of the energy after one complete cycle, E, to the initial energy, \(E_0\) is:

$$\begin{aligned} \frac{E}{E_0} = r^2 = \left( 1 - \frac{3}{2}\sin ^2{\alpha }\right) ^4 \end{aligned}$$
(3)

Generally speaking, impact is described by a resulting coefficient of restitution that relates the post-impact angular velocity \(\dot{\theta }^+\) to the pre-impact angular \(\dot{\theta }^-\) velocity and is defined according to:

$$\begin{aligned} \eta = \frac{\dot{\theta }^+}{\dot{\theta }^-} = 1 - \frac{3}{2}\sin ^2{\alpha } \end{aligned}$$
(4)

Note that, the above equation depends only on the slenderness value and is independent of any other characteristic of the block.

The equation of motion of rigid rocking blocks is solved using the ODE23s solver available in MATLAB as proposed by Diamantopoulos and Fragiadakis (2019). The solver increments automatically the time step and tries to exactly locate the instant of impact. In some cases, such solvers are trapped and thus different tolerance criteria should be used. The default tolerance of the ODE algorithm adopted is \(10^{-3}\) for the relative error and \(10^{-6}\) for the absolute error. Furthermore, a minimum threshold on the rotational velocity should be also considered. Below this threshold, the analysis is paused and the block is assumed at rest (full contact). This minimum rotational velocity limit was set to \(10^{-4}\).

3 Machine learning

As Machine learning we refer to algorithms and statistical models that computer systems use to effectively perform a specific task relying on models and inference without using any explicit instructions. Machine learning algorithms build a mathematical model with the aid of sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to perform the task (Bishop 1995). Supervised and unsupervised learning are the two main ML training methods. In supervised learning, each training example is a pair consisting of an input feature and a desired output value; the algorithm analyzes the training data and produces an inferred function. This function is then used for predicting the results of new input features (Russell and Norvig 2010). In unsupervised learning, the training data have only the input values while the algorithm identifies commonalities in the data and reacts based on the presence, or the absence, of such commonalities in each new piece of data. Supervised learning algorithms are commonly used for classification and regression. A classification problem is a predictive modeling problem where the outputs are restricted to a limited set of values (a category or a group) and for a given example of input data, a category label is predicted. Regression algorithms are used to predict continuous outcomes depending on the input features.

Supervised learning algorithms for classification have been used in this study to categorize the seismic responses of free-standing rigid blocks based on training data. Various algorithms with a different complexity level can be found in the literature, e.g. Ray (2019) and Singh et al. (2016), among others. Among the many options, a simple and a more complex algorithm were examined in this work. More specifically, the k-Nearest Neighbor (k-NN) and the Support Vector Machine (SVM) algorithms are examined.

The k-nearest neighbours (k-NN) algorithm is one of the simplest Machine Learning algorithms used for classification and regression tasks (Altman 1992). The algorithm makes predictions for a new instance x by searching through the entire training set for the k most similar instances (the neighbours) and summarizes the output variable for those k instances. For regression problems this might be the mean output variable, while for classification problems this might be the class value. A simple two-class classification problem is shown schematically in Fig. 2. The algorithm wishes to classify the green circle. The main parameter of the k-nearest neighbours is k, the number of neighbours. If \(k=1\) then the green sample will be categorized as class II, while for \(k=3\) neighbours it will be categorized as class I. In this work, the k-NN algorithm has been implemented in MATLAB environment using the “fitcknn” function which requires as input the number of neighbours, k.

Fig. 2
figure 2

Simple two-class classification problem and k-NN algorithm with \(k=1\) and \(k=3\) neighbours

The Support Vector Machine (SVM) is a discriminative classifier formally defined by a decision boundary, a separating hyper-plane with maximum margins. SVM is a core machine learning tool that is widely used in industry and science, often providing results that are more accurate than most methods available. Along with the random forest method it is one of the most important ML algorithms. For linearly separable data in the two dimensional space, this hyper-plane is a straight line dividing a plane in two parts where the two classes lay at the sides. Margins are the distances between the decision boundary and the support vectors which are the closest samples of each category to the decision boundary. Thus, an SVM solves an optimization problem in order to determine the optimal decision boundary with the maximum margins. For linearly inseparable patterns, e.g. the two classes of Fig. 2, a kernel function, which transforms the original data into a new space, is integrated in the optimization problem. The selection of the kernel function and its parameters affects the results of the SVM. Detailed explanation of the algorithm and its mathematical formulation are given in Cristianini and Shawe-Taylor (2000) and Hastie et al. (2001).

In this study, the SVM algorithm is implemented in the MATLAB environment using the “fitcsvm” function with a Gaussian kernel. The performance of the algorithm is controlled by two parameters, the “KernelScale” and the “BoxConstraint”. The “KernelScale” is a scaling parameter applied on the input data before the Gaussian kernel, while the “BoxConstraint” controls the maximum penalty imposed on margin-violating samples. If the “BoxConstraint” is increased, the SVM classifier assigns fewer support vectors. However, increasing the “BoxConstraint” may also increase the training times.

4 Proposed methodology

In structural earthquake engineering problems, the most common training data for ML applications is the response of a structure under seismic loading. The structural response is typically measured with the aid of an engineering demand parameter (EDP). For rocking problems usually the EDP is the rotation angle, \(\theta \), or the normalized rotation over the slenderness angle, i.e. \(\theta /\alpha \).

4.1 Problem formulation

For a free-standing rigid block subjected to a ground excitation, the only degree of freedom is the rotation of the block. Moreover, pure rocking motion is considered, omitting other nonlinear phenomena such as sliding and jumping. The goal is to develop a regression algorithm that predicts the rotation of the block, or an algorithm that classifies the blocks based on their response. In this study, a classification problem is formulated based on the response rotation, \(\theta \), of the block. The classification problem is defined with respect to a threshold \(\theta _{{\textit{lim}}}\) level that is decided depending on the desired class. The blocks are then categorized to samples with \({\theta }/{\alpha }\ge \theta _{{\textit{lim}}}\) and to samples with \({\theta }/{\alpha }<\theta _{{\textit{lim}}}\), thus forming a binary classification problem. For instance, rocking blocks can be classified as overturned, for \({\theta }/{\alpha }\ge 1\), or safe, for \({\theta }/{\alpha }<1\). Furthermore, three (or more) class classification problems can be also formulated setting more thresholds on \(\theta _{{\textit{lim}}}\) or using other response parameters. For instance, block samples can be considered as blocks that overturn with impact, blocks that overturn without impact and blocks that remain safe based on the response rotation \(\theta \) and the number of impacts, as it is discussed in the numerical examples that follow.

Fig. 3
figure 3

Confusion matrix for two-class classification problem

4.2 Selection of input features

The selection of the training, or input, features is a critical step of every ML application. The choice depends strongly on the problem at hand. For the rocking block problem, appropriate input features are parameters that describe the geometry of the block and the properties of the seismic signal. Since rocking blocks are rather simple structures, the characteristic frequency, p, and the slenderness angle, \(\alpha \), can be input features that describe the geometry of the block. On the other hand, the selection of appropriate base excitation properties is not straightforward. For instance, when a set of sine pulse excitations is considered, the pulse amplitude, \(A_p\), and its period, \(T_p\), can sufficiently describe the input motion. However, in the case of natural ground motion records, further investigation is required in order to choose parameters that are well correlated with the frequency content and the amplitude of the signal.

Two different sets of input features that describe the ground motion signals have been examined; they are termed as the “generic” set and the “pulse-based” set. The generic set can include both near and far-field records as the input features consist of well-known and powerful ground motion parameters that can be easily extracted from the records, namely the Peak Ground Acceleration, \({\textit{PGA}}\), the Arias Intensity, \(I_a\), the mean period, \(T_m\), and the significant duration, \(D_{5-95}\). On the other hand, the input features of the pulse-based set consist primarily of properties of the predominant pulse of each record. These parameters can be extracted following the approach proposed by Mimoglou et al. (2014). The authors proposed a methodology for extracting the predominant pulse from a seismic record that is based on optimally fitting the Mavroeidis and Papageorgiou (2003) wavelet (M &P) on the signal. The fitted wavelet depends on four parameters that control the frequency (\(T_p\)), the amplitude (\(A_p\)), the number of cycles (\(\gamma \)) and the polarity (\(\nu \)) of the signal. Polarity \(\nu \) defines the phase of the amplitude-modulated harmonic. For example, \(\nu = 0\) and \(\nu = \pi /2\) define symmetric and anti-symmetric pulses, respectively. Moreover, the cross-correlation of the original signal and the extracted wavelet gives the Pulse Indicator (PI) of the ground motion record, as it has been discussed by Kardoutsou et al. (2017). More specifically, records with PI less than 0.55 can be considered as non-pulse like, while for \(PI>0.65\) the record is definitely pulse-like. Thus, for pulse-like records the parameters of the predominant M &P wavelet were tested as alternative, pulse-based input features.

4.3 Training, validation and testing of the algorithms

Assessing the performance of a trained ML is essential. The common practice for this purpose, is to split the available data into three independent sub-sets: the training set, the validation set and the test set. The training set is used to train the model and to allow it to learn the hidden features/patterns within the data. The validation set is usually a part of the training set, for instance 20% of the training data, that is used in order to validate the model’s performance during training. This validation process provides information that helps to tune the model’s parameters accordingly. For example, for the k-NN algorithm the tuned model parameter is the number of neighbours, while for the SVM algorithm it is the kernel function parameters. Finally, the test set is a separate dataset that is used to test the model after the training phase has been completed.

In this study, the validation of the ML models has been performed using the k-fold cross-validation method. Moreover, the test datasets were created separately from the training sets for both supervised learning models considered. The k-fold cross-validation method allows the use of all the points of training data both for the training and for the validation of the supervised models. The idea is to spilt the data into a set of k folds. The model building and error estimation process is repeated k times. Each time \(k-1\) groups are combined and used to train the model. The group that was not used to construct the model is used to estimate the prediction error. After this process, there are k accuracy estimates that are averaged in order to obtain a more robust estimate of the prediction error.

Classification metrics measure the performance of a ML model when it comes to assigning data samples to certain classes. The classification accuracy measures the number of correct predictions made by the ML algorithm divided by the total number of predictions. It is the easiest classification metric to understand, but gives no information about the underlying distribution of the response values and the types of errors of the classifier. In other words, knowing only the classification accuracy, it is not possible to observe if a classification algorithm tends to assign samples to the wrong category or in which classes it tends to make misclassifications.

A confusion matrix such as that shown in Fig. 3 gives a more clear intuition of the prediction results compared to classification accuracy. A confusion matrix shows the number of correct and incorrect predictions made by the classification model compared to the actual outcomes (target values) in the data. The matrix is \(N\times N\), where N is the number of classes. The example of Fig. 3 is a a 2 by 2 confusion matrix where the classes are termed as “Class I” and “Class II”, respectively. The true, or correct predictions lie in the diagonal of the matrix (green boxes), while the off-diagonal terms correspond to the false predictions. More specifically, the labelling a, b, c and d was adopted for simplicity, where a and d correspond to the correct predictions of “Class I” and “Class II”, respectively. Moreover, b and c provide the number of false predictions. The number of cases in which the model predicts Class I while the target is Class II are referred as b and the number of cases in which the model predicts Class II while the target is Class I are labelled as c. As we will also show in the numerical examples, the confusion matrix, by definition, is not symmetric, thus \(b \ne c\).

Four performance metrics can be calculated with the aid of a confusion matrix, i.e. Accuracy, Precision, Recall and \(F_1\) score. These metrics are based on several works that discuss the classification performance metrics on either two-class (Hossin and Sulaiman 2015), or three-class (Tharwat 2021) problem. More specifically, the four metrics are defined as:

  • Accuracy: is the most intuitive performance measure. It is defined simply as the ratio of correctly predicted observation to the total observations. Based on Fig. 3, accuracy is calculated as: \((a+d)/(a+b+c+d)\). Based on Fig. 3, accuracy is calculated as: \((a+d)/(a+b+c+d)\) where the term \(a + d\) is the number of the correct predictions from both “Class I” and “Class II” while \(a + b + c + d\) represents the total number of predictions, either true or false. High accuracy does not necessarily means that the model is the optimum. Therefore, other parameters are also necessary in order to determine the performance of the model.

  • Precision is the proportion of Class I cases that were correctly identified, \(a/(a+b)\). Therefore, precision is the ratio of correctly predicted Class I samples to the total predicted Class I samples. The question that this metric answers is of all passengers that labeled as survived, how many actually survived? High precision relates to the low false positive rate which corresponds to c in Fig. 3.

  • Recall (sensitivity): is the proportion of actual Class I cases which were correctly identified \(a/(a+c)\). Recall is the ratio of correctly predicted Class I samples to the all samples of Class I.

  • \(F_1\) score: \(F_1\) score is the weighted average of Precision and Recall. Therefore, this score takes both false positives (c) and false negatives (d) into account. Intuitively it is not as easy to understand as accuracy, but \(F_1\) is usually more useful than the accuracy, especially in the case of an uneven class distribution. Accuracy works best if false positives (c) and false negatives (d) have similar cost. If the cost of false positives (c) and false negatives (d) are very different, it is preferable to look at both Precision and Recall. Therefore, \(F_1\) score is the harmonic mean of precision and recall, \(F_1\) score \(=\) ( 2 \(\times \) Precision \(\times \) Recall ) / (Precision + Recall).

Fig. 4
figure 4

Flowchart of the proposed methodology

In summary, the flowchart of Fig. 4 presents schematically the above-mentioned steps of the procedure which are: (i) Generation of training data, (ii) Selection of input features, (iii) Selection of ML algorithms, (iv) Training and validation and (v) Prediction. Between the steps (iv) and (v) one may determine threshold values on the metrics that adjust the quality of the ML algorithm, e.g. accuracy \(\ge 80{\%}\). If one metric does not satisfy the corresponding threshold, then training and validation should be performed again.

5 Numerical examples

The efficiency of the proposed ML-based methodology is demonstrated with two case studies. The first case study revisits the problem of the rigid block subjected to sine pulse excitations, while the second demonstrates the proposed methodology in the more demanding case of natural ground motion records.

5.1 Sine pulse base excitation

The problem of freestanding rigid blocks subjected to ground motions that are simulated as sine pulses is discussed in the first case study. This fundamental base excitation allows the visualization of the actual and the predicted classes and provides insight into the ML model predictions and capabilities. The training dataset used, considered blocks with \(R=0.5 \div R=1.5\) m and pulse properties: amplitude \(A_{p}=1 \div 12\) \(g{\textit{tan}}\alpha \) and pulse period \(T_{p}=0.2\div 1.5\) sec. The coefficient of restitution was set equal to \(\eta =0.85\). The input features adopted were the dimensionless parameters \(\omega _p/p\) and \(A_p/g{\textit{tan}}\alpha \), i.e. the normalised pulse frequency and the normalized pulse amplitude, respectively. These two input features, combine the characteristics of the input excitation and also the geometry of the block. One could argue that, since the problem is governed by two parameters, common curve fitting can be also applied. However, regression models can give a good prediction of the decision boundary between the two classes only when the training data lie around the boundary. In our problems, the data are scattered over a grid, while real-world seismic signals require more input features and thus fitting is not an option.

As discussed in Sect. 3, a two-class (safe, overturn) and a three-class classification problem (safe, overturn with no impact, overturn) have been considered. For the two-class problem, based on the results of numerical simulations. Assuming that overturning occurs when \(\theta /\alpha = 1\), 1242 samples were obtained and they were classified as overturned (1025 samples) and safe (217 samples). Both supervised learning algorithms adopted have been trained and validated using a fivefold cross-validation scheme. The models with the best cross-validation results have been used in order to carry out the response predictions on the test data. For the three-class classification problem, the 1242 blocks of the training set were split into three categories based on maximum rotation \(\theta \) and the number of block impacts, \({\textit{NIMP}}\). For \({\theta }/{\alpha }\ge 1\) and \({\textit{NIMP}}=0\) the block’s class was set to overturned (926 samples), for \({\theta }/{\alpha }\ge 1\) and \({\textit{NIMP}}>1\) the block’s class was set overturned-impact (99 samples) and for \({\theta }/{\alpha }<1\) the sample was considered as safe (217 samples). A fivefold cross validation was adopted also for the three-class problem.

For the k-NN algorithm, the number of neighbors was set equal to \(k = 10\). This value was chosen after several trials of training and cross-validation with different k values. Furthermore, for the SVM algorithm with Gaussian kernel the “BoxConstraint” parameter was set equal to 35 and the “KernelScale” was set equal to 2. The cross-validation confusion matrices are shown in Fig. 5 for the two-class problem. Figure 5(left) shows the predictions of the k-NN and Fig. 5(right) shows the SVM results. For both algorithms adopted, the false predictions that lie on the off diagonal boxes, have very few predictions, compared to the successful predictions of the boxes in the main diagonal. According to the confusion matrix the simple k-NN algorithm is only slightly worse than the more complex SVM. Furthermore, Table 1 compares the cross-validation accuracy of both algorithms that, on average, was found greater than 99%. In all four metrics, both algorithms have exhibited very high performance.

Fig. 5
figure 5

Cross-validation confusion matrix of the algorithms k-NN (left) and SVM (right) for the two-class classification problem of the first case study

Table 1 Cross-validation accuracy (%) of k-NN and SVM algorithms for the two-class and the three-class classification problem of a rigid block subjected to sine pulses

Figure 6(left) and (right) shows the rocking spectra, obtained using the k-NN and the SVM algorithm, respectively. The rocking spectra were plotted using as ordinates the input features of the problem at hand. More specifically, the horizontal axis is ratio \(\omega _p/p\) which is proportional to the frequency of the block, while the vertical axis is the normalized amplitude of the pulse \(A_p/g{\textit{tan}}\alpha \), where \(\alpha \) is the slenderness of the block. Using the ML algorithm, a grid of the input features is created and the performance of the ML models on the test data is assessed by visualizing the predictions obtained. Open circles denote safe response and the close circles denote overturning. Thus, the grid of circles corresponds to the training data. Once the grid in known, the safe (green color) and overturned regions (red color) can be identified using the ML algorithm with a very fine grid of points. This allows to draw the decision boundary of the two ML models. As observed from the decision boundaries, both algorithms were able to predict sufficiently the response of the unseen samples. However, the decision boundaries of the algorithms slightly differ due to the complexity/nature of each algorithm. The k-NN algorithm performs its predictions based on the closest neighbour samples, thus its decision boundary is not smooth, while on the other hand the SVM algorithm produces a smooth decision boundary. This attributed to the main scope of the SVM algorithm which is to find an optimum boundary.

Fig. 6
figure 6

Training samples and decision boundaries for the two-class classification problem of the first case study: k-NN (left) and SVM (right)

For the three-class problem, the cross-validation confusion matrices and the decision boundaries of the two ML algorithms are shown in Figs. 7 and 8, respectively. The observations made on the two-class problem also hold for the three-class problem. From the confusion matrices, it can be observed that the false predictions of both algorithms are very few, compared to the successful predictions. Furthermore, it is observed that the performance of the simple k-NN is very close to that of the SVM algorithm. Figure 8 shows the decision boundaries for three-class problem, for the k-NN (left) and the SVM (right) algorithms, respectively. Open circles denote safe response, the close circles denote overturning and the stars denote overturning with impact. Similar to the decision boundaries of two-class problem (Fig. 6), the decision boundary of the SVM algorithm is smoother than the decision boundary of the k-NN algorithm. Both ML algorithms were able to classify the training and test samples into three classes with excellent accuracy, even though the number of samples, which correspond to overturning with impact, was considerably less than the other two classes. In all, both algorithms have exhibited very high performance in all four metrics as presented in Table 1.

Fig. 7
figure 7

Cross-validation confusion matrix of the algorithms k-NN (left) and SVM (right) for the three-class classification problem of the first case study

Fig. 8
figure 8

Training samples and decision boundaries for the two-class classification problem of the first case study: k-NN (left) and SVM (right)

5.2 Seismic excitations

The second case study examines the use of natural ground motion records. The selection of the input features is not straightforward as in the case of sine pulses, while there are many different input feature combinations that can offer a successful training (Lagaros and Fragiadakis 2007). Moreover, the visualisation of the results in the form of Figs. 6 and 9 is not anymore possible. The training and the test datasets consist of the seismic response of various block samples with \(R=0.5\div 1.5\) m and are subjected to two different sets of ground motion records. For the training dataset, 55 pulse-like ground motion records with pulse index \(PI > 0.65\) have been selected. Detailed tables with the record properties and the characteristics of the predominant pulse can be found in Mimoglou et al. (2014).

As already discussed in Sect. 3, two sets of input features are considered. The first set is a “generic” set that consists of ground motion indices, namely \({\textit{PGA}}\), \(I_a\), \(T_m\) and \(D_{5-95}\) that are used are input features. The second set is called the “pulse-based” set of input features since it includes the properties of the predominant pulse of each record, namely \(T_p\), \(A_p\), \(\nu \), and \(\gamma \). These are the parameters that correspond to the pulse proposed by Mavroeidis and Papageorgiou (2003). The parameters are extracted from the ground motion records according to the multi-resolution analysis procedure proposed by Mimoglou et al. (2014). Furthermore, the block characteristic frequency, p, is also used as an input feature in both sets considered. The coefficient of restitution is kept constant and equal to \(\eta =0.85\). Due to the complexity of the problem, contrary to the previous case study, a separate test set that includes different ground motions from those of the training set has been created in order to assess the performance of the proposed algorithm.

Three classification problems, corresponding to three different limit-states were examined. The three limit-states are defined by setting threshold values on the normalized rotation \(\theta /\alpha \), thus: \(\theta /\alpha \ge 0.15\) (Damage Limitation), blocks with \(\theta /\alpha \ge 0.30\) (Significant Damage) and \(\theta /\alpha \ge 1\) (Overturning). The ML algorithms are trained separately for each of the limit-state considered, while a fivefold cross validation is used during the training phase.

Fig. 9
figure 9

Cross-validation confusion matrix of k-NN (left) and SVM (right) algorithms for the second case study and the overturning limit-state using the “generic” input feature set

Fig. 10
figure 10

Cross-validation confusion matrix of k-NN (left) and SVM (right) algorithms for the second case study and the overturning limit-state using “pulse-based” input feature set

The two ML algorithms were trained using the “generic” and the “pulse-based” set for the overturning limit-state in order to compare the performance of the models to the different sets of input features. For the k-NN algorithm, the number of neighbors was set to \(\textrm{k} = 10\). Furthermore, for the SVM algorithm with Gaussian kernel the “BoxConstraint” parameter was set to 35 and the “KernelScale” was set to 2. The training datasets consist of 1415 block samples from which 578 samples are overturned and 837 samples are safe. The test dataset contains totally 5454 samples, from which 5195 are overturned and 275 are safe. The confusion matrices resulting from the training cross-validation are shown in Figs. 9 and 10 for the two input feature sets, respectively. As it is observed, the algorithms have practically similar performance regardless of the input feature set considered. More specifically, the cross-validation accuracy of k-NN and SVM algorithms using the “generic” features was calculated equal to 97.6 and 98.7%, respectively, while for the “pulse-based” features, it was found equal to 96.7 and 98.8%, respectively.

Since the confusion matrices are not symmetric, the accuracy does not fully represent the performance of the algorithm. Therefore, the four ML performance metrics previously discussed are shown in Table 2. In all metrics, both input feature sets have exhibited high performance that is superior to 90%. Thus, both ground motion and predominant pulse parameters can be considered as efficient input features for the representation of ground motion. Based on this comparison, the “generic” input feature set is kept for the remaining. This set consists of parameters that are easier to extract from a ground motion signal, while various software are available for this purpose. Table 3 shows the performance of the two algorithms for all three limit-states when the “generic” input set is adopted. In all limit-states, the accuracy was remarkably high when the training set is used for the validation of the algorithm accuracy. Note that the comparison of Table 3 is obtained when the training data are adopted, combined with fivefold cross-validation.

Table 2 Cross-validation accuracy (%) of k-NN and SVM algorithms for the second case study and the overturning limit-state using the “generic” and the “pulse-based” input feature sets

Due to the complexity of the problem, the cross-validation method adopted may not be sufficient when the algorithm is required to blindly predict the maximum response of a rigid block against unknown ground motion records. For this purpose, a test set with different ground motions has been chosen. The test dataset includes 28 pulse-like and 26 non pulse-like records (Dimakopoulou et al. 2022). Both pulse and non-pulse records were considered in order to assess the performance of the trained algorithms to random ground motions. The resulting confusion matrices of the k-NN and the SVM algorithm are shown in Fig. 11, while Table 4 shows the ML performance metrics that were obtained when the test set has been adopted. Despite the very high classification accuracy, i.e. 93.2 and 97.0% for the overturning limit-state, the k-NN algorithm classified 274 overturned samples as safe, which corresponds to a 40% recall value. On the other hand, the SVM algorithm misclassified 54 samples which results to a 76% recall. The SVM algorithm considerably outperforms the k-NN algorithm in the case of the blind predictions of the test set. However, the algorithm is more efficient for the pulse-like records. More specifically, when the SVM algorithm is adopted, 73% of the misclassified samples were samples subjected to non-pulse like records, thus the algorithm was quite effective for the pulse-like signals of the test set.

Table 3 Cross-validation accuracy (%) of k-NN and SVM algorithms for the second case-study and for all limit-states
Fig. 11
figure 11

Confusion matrix of k-NN (left) and SVM (right) algorithms for the test dataset considering the second case study and the overturning limit-state using “generic” input features

Figure 12 shows the SVM predictions in the \(\omega _m/p-{\textit{PGA}}/g{\textit{tan}}\alpha \) plane for the overturning limit-state. Compared to Fig. 6, the pulse period \(\omega _p\) has been replaced by the circular frequency corresponding to the mean period \(T_m\), while the pulse amplitude \(A_p\) is replaced by the PGA of the record. Contrary to the sine pulse case, it is not possible to identify a “safe” and an “overturning” region. However, it is possible to identify a safe region, as was also shown in Psycharis et al. (2013). This safe region provides an upper bound for overturning, while simulations that are on the left of this region, do not necessarily overturn. Furthermore, Fig. 12(right) provides more insights regarding the true/false predictions of the SVM algorithm as function of the normalized PGA and the mean pulse period of the ground motions. The few false predictions seem to be concentrated at the upper left side of the spectrum.

Fig. 12
figure 12

Samples of the test set for the second case study and the overturning limit-state (left). True and false predictions of the SVM algorithm (right)

Table 4 Classification accuracy of (%) k-NN and SVM algorithms for the second case study and all limit-states considering the test sets

6 Conclusions

The paper proposes a new methodology on predicting the dynamic response of rigid blocks subjected to base excitations using supervised machine learning (ML) algorithms. Two types of base excitations were considered, i.e sine pulses and historical seismic records. The training datasets of each case were used to train k-NN and SVM algorithms, in order to classify the response of the block for a given ground motion. For the case study of sine pulses, the classification algorithms have shown almost perfect training and validation performance. For case of natural records, the performance of the classification algorithm was very good. The current work should be considered as an attempt to offer some first guidelines on smartly using ML algorithms on complicated problems such as the seismic performance assessment of rigid bodies. The study concludes that ML algorithms are promising for the case of rocking problems considering the reduced computational cost required for the training and the validation processes. Such tools can offer valuable tools with minimal computing efforts and are useful tools either to researchers that wish to generate generic models for simple non-dimensional problems, or to engineers that wish to use an available, trained model, in order to quickly obtain seismic performance estimations.