The environmental risks posed by mine tailings suggest the necessity of recycling tailings as cemented paste backfill (CPB) and constitutive modelling is an important step to understand its mechanical stability. In the present work, a novel data-mining approach is proposed for the stress–strain relationship modelling of CPB considering the coupled effect of cement/tailings ratio, solids content and curing time. The proposed approach is based on the random forest (RF) and firefly algorithm (FA), which can operate on large quantities of data for nonlinear and complex relationships modelling. RF was used to model the CPB constitutive relations while FA was used to tune the RF hyper-parameters. Unconfined compression tests were performed for the dataset preparation. The reliability and robustness of the proposed approach, the RF_FA, has been verified against experimental data. Results showed that the hyper-parameters of RF could be efficiently tuned by FA and the optimum hyper-parameters were obtained at the fifth generation. Moreover, the RF_FA possessed excellent prediction capability for the stress–strain relationship modelling (the correlation coefficient values between predicted and experimental stress values were 0.991 on the training set and 0.989 on the testing set). External verifications were further carried out to illustrate the performance of the RF_FA using several statistical criteria recommended in the literature. Consequently, it can be suggested that the RF_FA paves a new way in the constitutive modelling of CPB, which is of great significance for its engineering application.