In order to reduce the influence of thermal error on the machining accuracy of CNC machine tool, the position of temperature rise of machine tool was preliminarily found out by thermal imager, and then the collected temperature measurement point test data was optimized by using gray correlation theory to find out the measurement point with high correlation degree of thermal error. The selected temperature measurement point data and the measured Z-axis thermal error data were divided, and GM (1,n) grey prediction and BP neural network were used to establish the thermal error prediction model, which was verified on the test machine tool. The experimental results show that the difference between the predicted results of gray GM (1,n) model and the actual measurement is 10.17%, and the difference between the predicted results of BP neural network and the actual measurement results is 5.19%, which is better than the prediction of gray GM (1,n) model and can play a role in improving the accuracy of thermal error prediction.