The mechanical characteristics of rocks, specifically uniaxial compressive strength (UCS) and elastic modulus (E), serve as crucial factors in ensuring the integrity and stability of relevant projects in mining and civil engineering. This study proposes a novel hybrid PSO (particle swarm optimization) with tree-based models, such as gradient boosting regressor (GBR), light gradient boosting machine (LightGBM), random forest (RF), and extreme gradient boosting (XGBoost) for predicting UCS and E of rock samples from Block IX of the Thar Coalfield in Pakistan. A total of 122 datasets were divided into training and testing sets, with an 80:20 ratio, respectively, to develop the predictive models. Key performance metrics, including the coefficient of determination (R2), mean absolute error (MAE), and root mean square error (RMSE), were employed to assess the model’s predictive performance. The results indicate that the PSO-XGBoost model demonstrated the highest accuracy in predicting UCS and E, outperforming the other models, which exhibited inferior predictive performance. Furthermore, this study utilized the SHAP (Shapley Additive exPlanations) machine learning method to enhance our understanding of how each input feature variable influences the output values of UCS and E. In conclusion, the proposed framework offers significant advantages in evaluating the strength and deformation of rocks at Thar Coalfield, with promising applications in the field of mining and rock engineering.