In addressing the challenge of unattainable temperature data at critical heat source points in bearings, this study solves for the temperatures of the bearing inner ring and rollers by merging thermal resistance network calculations with experimental data, referencing finite element simulation outcomes. The impact of temperature data from various positions within bearings on model accuracy is assessed using a BP prediction model. Subsequently, the training dataset of the thermal error model is optimized to enhance its predictive performance. To further boost the predictive capabilities of the model, a whale optimization algorithm is employed to optimize the BP neural network, which is then compared against both the conventional BP model and the GPR model. The findings reveal that a model optimized with the input of inner ring temperatures and the WOA algorithm achieves an accuracy rate of 97.748 %, outperforming both the BP model and the GPR model. This study provides a new idea for the field of thermal error modeling of motorized spindle.