In the era of photovoltaics, metal chalcogenides exhibit promising photovoltaic performance owing to their optimal bandgap of 1 eV-1.5 eV. The current study focuses on the numerical simulation of the Cu2HgSnS4 (CHTS) based solar cell, with the initial device structure demonstrating a power conversion efficiency (PCE) of 21.16 %. Furthermore, various Machine Learning (ML) models are utilized to optimize the CHTS-based solar cell. Using ML techniques, accurate PCE predictions are made, which help simplify computation and improve the accuracy of the proposed model. Through the SCAPS-1D simulator, 729 datapoints are generated by varying the charge transport layers, absorber layer thickness (0.200 mu m to 1.1 mu m), defect density (1 x 1014 cm- 3 to 1 x 1022 cm- 3), and acceptor density (1 x 1012 cm-3 to 1 x 1020 cm- 3). The boosting ML technique XGBoost is used for optimization, yielding the highest photovoltaic (PV) performance and improved accuracy. After identifying the best-suited model, the mean squared deviation and performance metrics such as MSE, R2, and CVS are calculated across 10 iterations, achieving the lowest mean squared error (MSE) of 0.036 +/- 0.028 compared to other ML techniques. The optimized PV performance is obtained with VOC: 1.15 V, JSC: 33.53 mA/cm2, FF: 83.80 % and eta = 31.68 %, which is considered as a remarkable improvement in the PV industry. These predictions aligned closely with experimental benchmarks, validating the model's reliability for CHTS solar cell optimization. The proposed research provides new and significant insights for developing the CHTS-based solar cells.