As a device characterized by multiple degrees of freedom in one driving unit, analytical electromagnetic torque modeling is needed for the rotor position tracking control of a Permanent Magnet Spherical Motor (PMSpM). In this paper, Extreme Gradient Boosting (XGBoost) was proposed to be employed for establishing the output relationship between the rotor position and the electromagnetic torque of PMSpM. The Finite Element Method (FEM) was applied to obtain train data and test data concerning the rotor position and electromagnetic torque of PMSpM. Particle Swarm Optimization (PSO) was applied to optimize partial parameters of XGBoost, which serves to enhance the modeling accuracy of electromagnetic torque via XGBoost. The predictive results of algorithms, including Random Forest (RF), Gradient Boosting Regression Tree (GBRT), Multi-task Gaussian Process (MTGP), and XGBoost, were compared with FEM results and experimental results over multiple indicators. The capability of XGBoost has been validated not only to perform modeling tasks within an abbreviated time span but also to generate models that display amplified accuracy and efficiency.