Traditional manufacturing equipment is developing in the direction of precision, intelligence and integration, and the precision requirements of CNC machine tools are getting higher and higher. Compensating and controlling the thermal error of the machine tool is an important part of improving machining accuracy. This paper uses a cuckoo search algorithm to optimize the BP neural network to get the CSBP neural network model and inputs the temperature value of the CNC machine tool into the CSBP model to get the thermal error prediction results. Combined with the thermal error values of each measurement point on the CNC machine table, the B-spline function is used to fit the thermal error prediction model for the entire working area. Finally, the thermal error compensation system of the CNC machine tool has been established. Simulation and empirical studies show that the fitting and prediction accuracy of the model in this paper are better, and the maximum error value of the prediction is reduced by 20.27% compared to the LSTM model. After the application of the thermal compensation system in this paper, the thermal error of the CNC machine tool is greatly reduced, and most of the offset caused by the thermal deformation of the machine tool is eliminated through compensation. In this paper, the design of a thermal error compensation system based on full work area modeling can effectively reduce the thermal error of CNC machine tools, which can be applied to the actual machining process of machine tools to improve the machining accuracy of CNC machine tools.