# On-Demand Maintenance Method Using Fault Prediction to Reduce Elevator Entrapment
## 3 Prediction of Elevator Entrapment Incidents
### Predictive Modeling of Elevator Entrapment Incidents  
A hybrid model is constructed based on Self-Attention and LSTM, and its network structure is shown in Figure 4. The model performance has been validated in our previous work [26].  
Figure 4: Self-Attention–LSTM network architecture.  
Discrete data such as equipment code, geographic location, fault type and other discrete data are mapped to the feature space by solo thermal coding. Firstly, continuous data such as elevator age, maintenance cycle and other continuous data, are subjected to preliminary feature extraction, and constant and discrete data are spliced; then, the spliced feature information is passed into the LSTM network, and the (time-encoded) temporal abstract features are obtained through the first layer of the LSTM network. These temporal abstract features are subsequently passed to the Self-Attention Mechanism layer, and the current time point features are calculated using the different time point features between similarities and performing weighted summation to obtain the current time point features with integrated full-time information. Next, dropout is applied to the output of the Self Attention Mechanism to reduce the overfitting; it is then input to the second layer of the LSTM network and applied to produce the second layer of the LSTM again. These integrated temporal features are then passed into the two fully connected layers, and Sigmoid processing is performed in order to transform the features into predicted values of elevator entrapment probability.  
Through grid search of the model parameters, several key parameters were determined: the sliding window size was set to 12; the step size was set to 1; the number of LSTM layers was 2; the number of hidden units was 128, and the dropout rate was set to 0.1. The model was then trained using the Adam optimization algorithm to adjust the learning rate for parameter updates. The initial learning rate was set to 0.0001, the batch size was 128, and the maximum number of training epochs was set to 1500. Early stopping was implemented, where training would terminate prematurely if the validation loss failed to decrease for 50 consecutive epochs to prevent overfitting. Cross-entropy loss was used for the loss function. The evaluation metrics ensured accuracy, recall, and precision. The loss curve of the model training is shown in Figure 5.  
From the trajectory of the training loss curve, it can be observed that the loss value decreased rapidly during the initial training phase. This demonstrates that the model effectively learns from the data and that the parameter adjustments substantially, reducing predicted errors.  
As the training progressed, the loss reduction rate gradually decreased, and the curve exhibited a trend toward stabilization, indicating that the model was progressively converging to a steady state. Although the loss curve presented fluctuations during certain phases, these oscillations may stem from inherent noise in the data or suboptimal configu  
Figure 5: Training loss curve.  
ration of optimization parameters. When training reached 1000 epochs, the early stopping mechanism was triggered, suggesting that the model is approaching its performance limit. The dynamic changes in the loss function curve profoundly reflected on the stable learning process and the gradual convergence characteristics during model training.