# Spindle Thermal Error Prediction Based on LSTM Deep Learning for a CNC Machine Tool
## 3 Experimental Results
### Model Establishment and Modeling Effect Comparison  
To verify that the proposed LSTM modeling method could favorably estimate the spindle thermal displacement, the estimation effectiveness of the proposed model was compared with that of the MLR and BPNN models. The same five KTPs and the spindle speed \(S\) were used as the input, and spindle displacement in the z-direction was the output for the three modeling methods. Subsequently, three models of spindle displacement in the z-direction were separately established with the experimental data gathered at different spindle rotations. For the architecture of the ANN, the proposed LSTM and BPNN models were both set to have two hidden layers. Each of the two layers had ten hidden neurons, and the maximum training count was set to 100,000. The training curves of two modeling methods are shown in Figure 9. When the iteration number was 20,000, the proposed LSTM model was close to convergence with fewer errors than the BPNN. By contrast, the BPNN model approached convergence after 100,000 iterations.  
For the MLR modeling method, five KTPs and the spindle rotation speed \(S\) were the dependent variables, and the spindle thermal displacement in the z-direction was the independent variable. The best-fit coefficients between these independent and dependent  
Figure 8: Trend analysis of five KTP temperatures and spindle displacement.  
Figure 9: Training curve comparison between the proposed LSTM and BPNN models.  
variables were then obtained using the least squares method. The established MLR model is expressed in Equation (11).  
\[Z=-0.93246\Delta T_{17}+0.535236\Delta T_{9}-0.30063\Delta T_{27}-0.18147\Delta T _{14}-0.19361\Delta T_{32}-0.01884S+1.08416 \tag{11}\]  
where \(\Delta T_{17}\), \(\Delta T_{9}\), \(\Delta T_{27}\), \(\Delta T_{14}\), and \(\Delta T_{32}\) denote the temperature increase of the KTPs, and \(S\) is the spindle rotation speed. Figure 10 presents the results of the MLR, BPNN, and proposed LSTM models at different spindle rotation speeds. In the MLR modeling method, larger estimation errors occurred at the turning point of the spindle displacement curve (e.g., the estimation results at the 4 th, 8 th, and 12 th hour). The largest estimated error reached 12.85 \(\upmu\)m when the spindle rotation speed was 9000 rpm. The linear mathematical model is not enough to accurately describe the relationship between the temperature increase and spindle displacement. By contrast, the largest estimated errors for the BPNN and the proposed LSTM modeling methods were 6.96 and 3.22 \(\upmu\)m, respectively. The ANN methods significantly outperformed the MLR modeling method. The proposed LSTM modeling method with memory characteristics had the best estimation performance at different spindle rotations.  
Figure 10: Comparison estimation results of MLR, BPNN, and the proposed LSTM modeling methods at different spindle rotation speeds.  
Table 8 presents the RMSEs of the MLR, BPNN, and the proposed LSTM modeling methods at different spindle rotation speeds. The three modeling methods exhibited a similar trend of more accurate estimations at low spindle speeds. The proposed LSTM modeling method consistently outperformed the MLR and BPNN methods in estimation for every spindle speed.