Cholecystectomy and Metabolic-associated steatotic liver disease (MASLD) are prevalent conditions in gastroenterology, frequently co-occurring in clinical practice. Cholecystectomy has been shown to have metabolic consequences, sharing similar pathological mechanisms with MASLD. A database of MASLD patients who underwent cholecystectomy was analysed. This study aimed to develop a tool to identify the risk of liver fibrosis after cholecystectomy. For this purpose, the extreme gradient boosting (XGB) algorithm was used to construct an effective predictive model. The factors associated with a better predictive method were platelet level, followed by dyslipidaemia and type-2 diabetes (T2DM). Compared to other ML methods, our proposed method, XGB, achieved higher accuracy values. The XGB method had the highest balanced accuracy (93.16%). XGB outperformed KNN in accuracy (93.16% vs. 84.45%) and AUC (0.92 vs. 0.84). These results demonstrate that the proposed XGB method can be used as an automatic diagnostic aid for MASLD patients based on machine-learning techniques.