Soil-structure interaction (SSI) under seismic loading is a rather complex phenomenon that has immense effects on the seismic performance of structures. Traditional approaches are the finite element method (FEM) and the boundary element method (BEM), which have been used rather widely in analyzing SSI. Both methods usually fail to capture the complex dynamics of the underlying process. Recent advances in machine learning offer promising alternatives for predictive modeling and analysis of SSI. This paper deals with the applicability of the XGBoost machine learning model, optimized with particle swarm optimization (PSO) in predicting Soil-Structure Interaction under Seismic Loading. The presented model shows accuracy with mean squared error (MSE): 0.04, Root Mean Squared Error (RMSE): 0.2, R-squared (R2): 0.95, and mean absolute error (MAE): 0.1. The results show the better performance of the model over traditional methods like the finite element method (FEM) and the boundary element method (BEM). Comparisons through visualization show that there were close agreements in the displacements predicted and real displacements. Stress distributions and stress–strain curves, predicted from the analysis, validate the model's accuracy. The important outcomes are that the model can deliver more accurate and reliable predictions, enhancing seismic design, and safety to a great extent. It contributes to the literature by being the first application of machine learning combined with an optimization technique; it provides a full comparison to traditional methods for the community and shows future research opportunities, for example, including real-time seismic data or exploring model transferability.