Regulations mandate the testing of concrete's compressive strength after the concrete has cured for 28 days. In the ideal situation, cured strength equals the target strength. Advance estimation of concrete's compressive strength can facilitate quality management, improve safety, and present economic advantages in terms of waste management and sustainability benefits. Basic statistical methods cannot effectively predict concrete's strength or its nonlinear relationships with the proportions of its constituent materials. In this study, a baseline model for predicting concrete's compressive strength was constructed using a state-of-the-art machine-learning method. Most related studies have used sets of concrete mix design results concerning concrete specimens for laboratory-produced concrete specimens as training sets and have obtained simple models through regression; however, these models have been unsuitable for onsite prediction of the compressive strength of concrete with the various mix designs. Control over mix proportions is high in laboratories, resulting in low variation; onsite manual operation and environmental factors cause large variations in assessment data. In this study, machine-learning techniques and a newly developed metaheuristic optimisation algorithm were applied to long-term big data from 75 concrete plants to construct the optimal machine-learning model. Our self-developed forensic-based investigation algorithm (FBI) was employed to fine-tune the hyperparameters of the XGBoost model and to improve the model's generalisability. The lowest mean absolute percentage error (MAPE) obtained using this model was 9.29%, which was smaller than the lowest MAPE achieved using the conventional simple regression (12.73%). The regression model tends to overestimate the actual compressive strength. Finally, a convenient expert system was developed that facilitates the use of the proposed model by onsite engineers for quality management. This system can make a considerable contribution to the field because automated recording of the proportions of constituents of concrete will reduce sampling errors and ensure data reliability.