Abstract
The ball screw is an essential component in feed drive systems whose accuracy is seriously affected by machine tool internal and external heat sources. In this paper, a thermal error compensation method for ball screws is proposed based on the extreme gradient boosting (XGBoost) algorithm and thermal expansion principle. An XGBoost predictive model is established using the time series temperature data collected from thermal characteristics experiments. Furthermore, the predictive performance between the XGBoost algorithm and BP neural network is compared to validate the effectiveness and robustness of the proposed model. The results show that the XGBoost model has better predictive performance. Based on this, the temperature of key points on the ball screw can be obtained, and thermal error (which is useful for pulse compensation) is predicted. Simultaneously, thermal error compensation experiments are carried out on the ball screw bench with average results of more than 45%. The presented thermal error compensation method proved effective and can provide a foundation for precision machining.
Introduction
Ball screws are widely used components in high-speed machining technology due to their high efficiency and good stiffness. However, the high speed leads to thermal deformation, which has become one of the most pressing concerns in the manufacturing domain. 1 Thermally-induced errors account for approximately 40%–70% of machining errors. 2 Therefore, reducing the thermal error of ball screws is required to improve the machining accuracy of CNC machine tools. The studies on ball screw accuracy retention mainly include accuracy degradation basic, accuracy degradation analysis, and revealing the law of accuracy degradation. 3
Generally, the methods that reduce the thermal error of ball screws can be classified into thermal error suppression and compensation. In thermal error suppression, the improved structures and unique characteristics of advanced materials were proven effective in reducing the ball screws’ thermal error. The thermal elongation correction of ball screws was validated by researchers using various cooling systems, including air, 4 liquid, 5 oil, 6 and circulating coolant system. 7 Gao et al. applied carbon fiber-reinforced plastic8,9 and graphene10,11 to ball screws to improve positioning accuracy. Even though the effectiveness of suppression methods has been validated, their weaknesses should be focused on. The existing thermal error reduction methods of ball screws with additional systems are complicated and lack reliability. The high cost of high-module carbon fiber and the unsolid attaching of graphene coating increases the difficulty of design implementation in engineering practice.
Thermal error compensation is another measure that mitigates a decrease in the positioning accuracy of ball screws without changing the structure of the ball screw. An accurate thermal error model is the basis of thermal error compensation for ball screws. However, due to the nonlinearity of thermal error change, it is difficult to find its law. Furthermore, excellent robustness cannot be generally guaranteed for a thermal error model under different and complex working conditions. Zhang et al.
12
established the prediction models for the positioning error of ball screws based on mounting conditions. Yang et al.
13
proposed the thermal expansion mathematic model of screw shaft in the axial direction using the Fourier series expansion method with relative errors under 14%. Prasad and Kamala
14
calculated the thermal deformations of the feed motor assembly in
The neural networks and data-driven methods are attracting more and more attention from researchers to address the regression and prediction issues. Liu et al. 23 proposed the regression model and backpropagation (BP) neural network model for predicting the maximum and average temperatures in the cutting zone. Mei et al. 24 coupled the BP neural network with the multi-domain analytical model to predict dynamic tracking errors of the feed drive system. Liu et al. 25 introduced a data-driven thermally-induced error compensation method based on the homogeneous transformation method for the five-axis machine tools. The proposed method reduced errors by 85% compared to that without compensation. Chengyang et al. 26 used the convolutional neural network to model axial and radial thermal errors of horizontal and vertical spindles by combining the thermal image with the thermocouple data. The authors obtained prediction accuracy and average compensation ratio of more than 90% and 50%, respectively. Fan et al. 27 presented a thermal error prediction method for a grinding machine spindle based on the heat energy conduction principle and convolutional neural network. Thus, the absolute position accuracy of the shaft characteristic faces was improved by more than 84%. Li et al. 28 proposed the thermal error compensation model for the CNC machine tool based on genetic algorithm optimization wavelet neural network. Li et al. 29 established the inverse random radial basis and forward random radial basis function neural network models to predict the thermal error of feed systems considering the randomness of influencing thermal error factors. Yang et al. 30 modeled the thermal error of a high-precision feed system with a thermal error residual of 0.88 μm by employing the Elman network optimized by the differential evolution algorithm. Gao et al. 31 applied the long short-term memory (LSTM) neural network optimized by particle swarm optimization (PSO) to predict the thermal error of the ball screw, while the absolute error was controlled within 5 μm. Massive data are required to obtain a more accurate model when predicting the ball screw thermal error using a neural network. However, the traditional prediction model cannot achieve high efficiency when dealing with massive data. 32 Compared with other gradient boosting algorithms, the extreme gradient boosting (XGBoost) algorithm is an efficient and accurate algorithm based on the following advantages 33 :
effective handling of missing values;
can prevent overfitting;
parallel and distributed calculation to reduce the running time.
XGBoost gathers strong classifiers from a set of weak classifiers and has been used in many areas, such as time series prediction of COVID-19 transmission, 33 PM2.5 prediction, 34 and freeway travel time prediction. 35 Zhang et al. 36 predicted the time series of the melting pool temperature distribution during direct energy deposition using two machining learning methods, XGBoost and LSTM. Lyu et al. 37 constructed a mini liquid cooling system surrogate model based on XGBoost with a 2 ms computational time. The thermal prediction model with multiple inputs can be established using XGBoost to reduce the calculation time, which is consistent with the advantage of parallel calculation of the XGBoost algorithm. However, thermal error prediction of machine tools using the XGBoost algorithm is rarely investigated, especially in the field of ball screws. Furthermore, the time-series thermal characteristic data of a ball screw includes the temperature and thermal errors, consistent with the characteristic of predicting the time series data via XGBoost.
Many of the existing investigations introduced real-time thermal error compensation, which requires reading servo axes positions from the controller and writing the compensation values to the controller, 20 such as Li et al. 16 On the other hand, compensation based on the predictive temperature data requires the correction of thermal errors obtained from temperatures. In Zapłata and Pajor, 15 the temperature of the ball screw was obtained, and the thermal error was compensated.
In this research, a thermal error compensation method is proposed and validated to deal with a decrease in the positioning accuracy of the ball screw. Since the axial positioning accuracy of machine tools is mainly affected by ball screw feed driving systems, errors in other directions are guaranteed by the guide slide, and thermal deformation in other directions is out of the scope of this research. Firstly, the temperature predictive model of key points on the ball screw is established using the XGBoost algorithm. Then, the prediction performance between the XGBoost algorithm and the backpropagation (BP) neural network is compared to the data collected from thermal characteristics experiments. Furthermore, the thermal error values are obtained using the multiple linear regression method and thermal expansion principle. These values can compensate for the position error by adjusting the sever pulses. Finally, the thermal error compensation experiments are conducted, and the effectiveness and robustness of the proposed method are validated. The framework of the research work is shown in Figure 1.

Framework of the research work.
Thermal error modeling of ball screws based on the XGBoost
The predictive model
The XGBoost algorithm is a scalable machine learning system for tree boosting that can be used for regression and classification problems. The algorithm generates a weak learner at each step and accumulates it into the total model.
As a tree integration model, the predictive temperature results
where
where
where
The iterative method is used to minimize the objective function. Thus, the objective function in the
This function can be simplified using the Taylor expansion. Thus, the following can be derived:
where
Based on scalability, high efficiency, low calculation cost, parallelization support, and regularization processing advantages, 39 the XGBoost algorithm has been used in many prediction issues.38,40 The XGBoost algorithm was employed in this paper to establish the mapping between the input and output data, thereby obtaining the thermal error prediction. The XGBoost model was employed to establish the mapping relation between the temperature of every key point on the screw and torque of the servo motor, the temperature of thermal sensitive points 31 (supporting bearing, fixed bearing, and nut), and ambient temperature.
The predictive performance of the XGBoost is further compared with the BP neural network to verify its robustness. The structure of BP can be divided into input layer, hidden layer, and output layer. Similar to the XGBoost model, a BP neural network was established in which servo motor torque, the temperature of thermal sensitive points, and ambient temperature were the input layer neurons. Furthermore, a single output neuron, that is, the temperature of every key point on the screw, is acquired.
BP neural network represents the mapping relation between the input layer neurons and the output neuron. Parameter
The output
The predictive model should input massive data to train and obtain high prediction accuracy. Thus, sufficient data on servo motor torque and key temperature data of the ball screw feed system was collected. The input and output sets, fed into the model after normalizing, were defined to establish the predictive model. The last 20% of data was assigned as the test set to validate the model’s accuracy. After obtaining the predicted temperature of key points on the screw, the thermal error can be calculated according to the principle of thermal elongation of the slender shaft, as follows:
where Δ
Experimental procedure
To validate the effectiveness and robustness of the proposed method, two thermal characteristics experiments, including step speed and random speed working conditions, were conducted on a self-design ball screw bench in natural ambient, according to Liu et al.
25
The stability can be guaranteed by large weight base of the bench when the sliding table is moving fast. The two working conditions are shown in Table 1, and the experimental setup is shown in Figure 2. The factor of preload, load, and cooling medium will lead to the variation of temperature. The temperature data directly related to thermal deformation is considered the main parameter for the predictive model. This model is applicable when the preload, load, and cooling medium vary. Eight temperature sensors were used in the experiments to measure the system’s temperature. The temperature data of ambiance (
Rotation speed of thermal characteristics experiments.

Experimental setup: (a) high-speed ball screw test bench, (b) temperature acquisition system, and (c) servo motor torque-acquisition system.
Firstly, to ensure the experiments goes well, the pretests were conducted on the test bench. And the step speed thermal characteristic experiment was carried out to validate the XGBoost prediction model. The rotation speed increased from 600 to 2400 rpm, then decreased to 600 rpm. The real-time temperature information was collected and visualized during the operation by a thermal error experimental temperature measurement system. The sample interval was set to 1 min. Subsequently, a random speed thermal characteristic experiment was conducted at the same condition, and the temperature and torque data were obtained.
Results and discussion
After thermal characteristics experiments with step speed and random speed were carried out, the temperature data could be collected to establish the predictive model. The mutate temperature is collected by non-contacting temperature sensors when the worktable passes. To distinguish the unacceptable data, the derivative threshold of measured temperature was set. If the derivative of measured data exceeded the threshold, it was considered to be unacceptable data. The mutation is distinguished and deleted. To compensate the data for the integrity, the temperature was recorded when the work table is located on the one end of the stroke for the first time after the unacceptable data is deleted. The experimental results are shown in Figure 3. It can be concluded that an increase in the temperature of every part of the ball screw is correlated with an increase in the rotation speed. The temperature change trend of measuring points on the screw is similar to the nut. Due to the complex working condition and the relative long length of screw, there are differences in the temperature of the measuring points on the screw, and the temperature rise of the screw is uneven in the axis direction; thereby, the thermal error of each segment is different. It is noted that the temperature of nut was higher than other points at the initial time in Figure 3(a), the reason may be that the ball screw was not be cooled completely after the pretest.

Experimental results: (a) step speed work condition and (b) random speed work condition.
After obtaining sufficient temperature and torque data to establish the XGBoost model, the temperature of key points (

Mapping relations between input and output.
The first 80% of input and output data obtained from two experiments were fed into the XGBoost model to train two prediction processes. The remaining input data were assigned as the test set to validate the effectiveness and robustness of the established model. Simultaneously, the BP network was applied to train and predict the temperature of the same key points on the screw using the same data. The comparative results of the thermal characteristics experiment under step speed are shown in Figure 5.

Comparison of predictive results under step speed: (a) measuring point 1, (b) measuring point 2, (c) measuring point 3, and (d) measuring point 4.
Comparison results indicate that the predictive trend based on the XGBoost model is better than the one based on BP neural network under the step speed working condition. The maximum relative errors of every measuring point are listed in Table 2.
Maximum relative errors of predictive results in step speed experiment.
According to the step speed experiment results, it can be seen that the predictive performance of the XGBoost model with a smaller maximum relative errors is better than that of the BP neural network. The maximum relative errors obtained by the XGBoost model of four measuring points is less than 3%, demonstrating that the XGBoost model can predict the temperature of the ball screw well. The thermal characteristics experiment of the ball screw was also conducted under random speed conditions to validate the robustness of the proposed XGBoost. The other experimental setup is the same as the step speed experiment (except for the rotation speed). The results of the other experiment are shown in Figure 6.

Comparison of predictive results under random speed: (a) measuring point 1, (b) measuring point 2, (c) measuring point 3, and (d) measuring point 4.
The analysis results are similar to the step speed experiment, which proves that the XGBoost predictive model is more accurate than the BP neural network. Maximum relative errors of the random speed experiment are listed in Table 3. The average computing time of 25.58 s is required using the ordinary PC with Intel(R) Core (TM) i5-6200U CPU.
Maximum relative errors of predictive results in a random speed experiment.
The error analysis indicates that the XGBoost model and BP neural network under random speed condition are relatively poorer than in step speed conditions. The reason is that the XGBoost model and the BP neural network are data-sensitive models that can be influenced by the more complex temperature data series from the random speed condition. Furthermore, different maximum relative errors are obtained at various points using XGBoost and BP predictive models. This can be attributed to the temperature data at different points predicted by the model with different training sets. It can be concluded that the XGBoost model has better predictive performance. Compared with the results from the simulation in Liu et al., 22 the proposed method is characterized by better predictive accuracy. Thus, the robustness of the XGBoost model can be confirmed. However, since the parameters in the XGBoost model are not optimized, the predictive performance of hybrid thermal error modeling methods is better than the proposed method, such as the PSO-LSTM. 31 However, additional computing cost is required to achieve thermal error prediction using the hybrid methods with the optimization method.
Thermal error modeling
According to the thermal elongation principle of the slender shaft, the thermal error was calculated based on the temperature prediction values. In this paper, the screw was considered an axis with a non-uniform elongation characteristic. It was assumed that the thermal elongation was uniform between the measuring points on the screw and between the bearings and the nearest measuring points. Thus, the thermal deformation of every point on the screw can be obtained as follows:
where
Thermal error compensation of ball screws
Thermal error compensation and suppression are effective methods to deal with a decrease in the positioning accuracy of ball screws. After obtaining the thermal error model, the thermal error can be reduced by compensation. In this paper, a compensation method by controlling servo pulses was proposed to improve the position accuracy of the ball screw.
Thermal error compensation principle
In this paper, the thermal error prediction method using the XGBoost and multiple linear regression model was adopted to obtain the thermal error in real-time, thereby improving the positioning accuracy of the ball screw feed system. The compensation process can be seen in Figure 7. Based on the prediction model established in Section 2, the temperature of key points on the screw can be obtained, and the thermal error can be calculated. It is generally assumed that the origin of the feed axis is constant. Thus, the thermal drift error is assumed as negligible.
41
In this paper, the XGBoost predictive model established via step-rotation speed working condition was adopted to obtain

Schematic diagram of compensating for the thermal error of ball screw.
Multiple linear regression
After obtaining the temperature data of key points on the ball screw using the XGBoost predictive model, the mapping relation between temperature data
In this paper, the predictive results of XGBoost under step-rotation speed working conditions were processed using multiple linear regression. Thus, the temperature of key points on the ball screw can be calculated according to the temperature values measured by PT100 sensors. The multiple linear regression results are listed using the following equations:
Validation of thermal error compensation
Thermal error compensation experiments were conducted on the self-design ball screw bench to validate the improvement in the positioning accuracy of the ball screw feed system by the proposed method. The thermal error compensation system includes thermal characteristics acquisition, temperature prediction, and a thermal error compensation module. The temperature prediction module was used to predict the temperature of four key points on the screw based on the model established in Section 2. Then, the temperature data was transferred into thermal error data on every point of the screw, which was assigned as the compensation value in the thermal error compensation module. After removing the non-contacting temperature sensors and their bracket, the other experimental set was the same as in Section 2.2. In addition, the laser interferometer (XL-80, Renishaw) was selected to measure the positioning accuracy of the work table. The experimental setup is shown in Figure 8.

Setup of thermal error compensation experiment.
The new working rotation speed was designed to demonstrate the robustness of the proposed compensation method. The heating and measuring intervals were included in this working condition, as shown in Figure 9. The heating intervals were designed to obtain an obvious temperature increase of the ball screw and validate the effectiveness of the proposed compensation method.

Rotation speed of compensation experiment.
Considering the origin of the ball screw bench as a reference point, six points (0, 100, 200, 300, 400, and 500 mm) which occupied almost the entire screw stroke, were selected as the measuring points to obtain the positioning errors. In every measuring interval, all positioning errors of six points before and after compensation were measured twice and recorded, respectively. Thermal errors before and after compensation are shown in Figures 10–12.

Thermal errors in the first measuring interval before and after compensation: (a) first and (b) second measurements.

Thermal errors in the second measuring interval before and after compensation: (a) first and (b) second measurements.

Thermal errors in the third measuring interval before and after compensation: (a) first and (b) second measurements.
The thermal error measurement indicates that the presented thermal error compensation can effectively reduce the positioning error. The maximum compensation effect in every measurement is summarized in Table 4. It can be concluded that the positioning error was reduced using the compensation method in each selected measuring point. Thus, the thermal error compensation is experimentally validated, and the average thermal error compensation can reach more than 45% on every point within each measuring interval, as shown in Table 5. The effectiveness and robustness of the proposed compensation method are validated.
Results of thermal error compensation.
Average thermal error compensation results.
A machine tool’s thermal error mainly includes spindle and servo axes thermal errors. 42 Since the ball screw feed system is the key feed component in machine tools, its thermal error is significant. The reduction of thermal error of ball screws can improve the machining accuracy of machine tools. In this study, the focus is placed on thermal error modeling and compensation of ball screws, and a thermal error compensation method for the ball screw was proposed. This study’s results can contribute to machine tool thermal error reduction.
Conclusions
In this paper, thermal error prediction and compensation methods were proposed to deal with the reduction of ball screw positioning accuracy due to thermal-induced error. The thermal error on a different segment of the ball screw can be obtained by combining the XGBoost prediction model and the slender shaft’s thermal elongation principle. The XGBoost prediction model can be used to predict the temperature of key points on the ball screw, which is the basis of thermal error calculation. A comparison of predictive performance between the XGBoost model and BP neural network was conducted under two working conditions. The results show that the XGBoost model can predict the temperature more accurately, that is, the relative error is less than 8%.
The thermal error of every point on the ball screw can be calculated based on the predictive temperature. Thus, the thermal error can be reduced by compensation using multiple linear regression and pulse control. Thermal error compensation experiments were conducted to collect and analyze thermal errors before and after compensation. The results show that the average thermal error compensation effect is more than 45% compared with the thermal characteristics experiment without compensation.
The effectiveness and robustness of the proposed prediction and compensation method are experimentally validated. However, to validate this method’s effectiveness in engineering practice, real-time cutting tests will be conducted in the future to fully validate the effectiveness of the proposed method during actual working conditions.
Footnotes
Author contributions
Xiangsheng Gao conceived the modeling and analysis, and wrote the manuscript as well. Xiangsheng Gao, Kuan Zhang, and Zitao Zhang conducted the experiment and modeling. Tao Zan and Peng Gao conducted the data analysis. Min Wang supervised this work and revised the manuscript.
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This study was supported by the National Natural Science Foundation of China (grant numbers: 51875008).
Ethical approval
The article follows the guidelines of the Committee on Publication Ethics (COPE) and involves no studies on human or animal subjects.
Consent to participate
Not applicable.
Consent to publish
All the authors approve the publication of this article.
Availability of data and materials
All data generated or analyzed in this study are included in the present article.
Code availability
The authors make sure we have permissions for the use of software, and the availability of the custom code.
