Quantifying the impact of climate change and human activities on runoff changes is beneficial for developing sustainable water-management strategies within the local ecosystem. Machine-learning models were widely used in scientific research; yet, whether it is applicable for quantifying the contribution of climate change and human activities to runoff changes is not well understood. To provide a new pathway, we quantified the contribution of climate change and human activities to runoff changes using a machine-learning method (random forest model) in two semi-humid basins in this study. Results show that the random forest model provides good performances for runoff simulation; the contributions of climate change and human activities to runoff changes from 1982 to 2014 were found between 6–9% and 91–94% in the Zijinguan basin, and 31–44% and 56–69% in the Daomaguan basin, respectively. Furthermore, the model performances were also compared with those of well-known elasticity-based and double-mass curve methods, and the results of these models are approximate in the investigated basins, which implies that the random forest model has the potential for runoff simulation and for quantifying the impact of climate change and human activities on runoff changes. This study provides a new methodology for studying the impact of climate change and human activities on runoff changes, and the limited numbers of parameters make this methodology important for further applications to other basins elsewhere. Nevertheless, the physical interpretation should be made with caution and more comprehensive comparison work must be performed to assess the model’s applicability.