High-speed electric spindle is an important part of CNC machining equipment. The thermal displacement generated by the electric spindle during operation is the main reason that affects the machining stability and machining accuracy of the electric spindle. Compensating the thermal error of the high-speed electric spindle can effectively improve the CNC machining. The processing performance of the equipment. Therefore, it is particularly important to establish the accuracy of the thermal error prediction model. Taking the A02 high-speed electric spindle as the research object, ANSYS is used to analyze the thermal characteristics of the electric spindle, and the temperature and thermal displacement monitoring points of the electric spindle are arranged according to the simulation results, and the temperature and thermal displacement data of the monitoring points under different rotational speeds are collected; Using K-means to classify temperature measurement points, uses the grey relation analysis degree to determine the correlation between the temperature measurement point and the thermal displacement data, and selects 4 temperature sensitive points from 10 temperature measurement points. Finally, particle swarm optimization (PSO) is used to optimize the penalty factor and kernel function of support vector machine (SVM), and the PSO-SVM prediction model is established to compare with the neural network prediction model of SVM and genetic algorithm (GA) optimized SVM respectively. The results show that PSO-SVM has better robustness, stability and generalization ability.