The linear motor feed system has been in service in complex working conditions for a long time, thus causing the nonuniform distribution of the temperature field distribution. Thus, thermal error has become a key factor affecting system motion accuracy. To maximize the accuracy and efficiency of thermal error compensation for linear motor feed system, an improved modeling method for the thermal error of the linear motor feed system based on Bayesian neural networks is proposed in combination with the strong generalization performance and avoidance of overfitting of Bayesian neural networks. And the specific modeling ideas are as follows: Firstly, the X-Y cross-type two-axis linear motor feed system is as the test object. Aiming at the slow convergence , over fitting and under fitting problems of traditional neural network, Bayesian neural network is used to model the thermal error of linear motor feed system .Secondly, In order to avoid the influence of multicollinearity data on the final results, the grey relation analysis method is used to screen the temperature measuring points, and the data with large relation degree is selected for modeling to ensure the prediction accuracy of neural network. Thirdly, and the temperature variables of sensitive points and thermal positioning errors are taken as data input samples. Fourthly, a Bayesian neural network model is established. Fifthly, the hyperparameters of the Bayesian neural network is determined by a calculating method of Hessian matrix by Gauss Newton approximation. And finally, a thermal error prediction model is established. The comparison and analysis with the neural network constructed by ordinary Levenberg-Marquardt algorithm after a series of experimental demonstrations see that the prediction accuracy of the proposed method can be enhanced by up to 10%. It also shows that the prediction model has the advantages of high precision, strong generalization ability, strong anti-disturbance ability and strong robustness, etc. Therefore, the prediction model is expected to be widely used in the prediction and compensation of thermal error of the feed system of high-speed CNC machine tools in practical machining occasions.