Food security is a major issue in Sub-Saharan Africa (SSA) as a result of interrelated challenges such as climatic variability and change, soil degradation, pests, and disease, poor farmer management practices, and financial situation. Analytical tools that can assist farmers and policymakers in making decisions to mitigate the effects of climate change are urgently needed. Machine learning has the potential to inform agricultural decision-making, particularly when applied to big data due to its predictive capability. The objectives of this study were to evaluate the performance of an ensemble machine learning approach in simulating rice yield in the major rice-growing environments in SSA. We used data on climate, soils, management practices, and rice yield from 17,733 rice fields distributed in 13 countries of SSA. We applied 13 machine-learning models and identified the four best machine-learning models for predicting rice yield in each rice-growing environment. We then developed an ensemble model based on the four best models and evaluated its performance in simulating rice yield. The ensemble model predicted rice yield with coefficients of determination (R2) of 0.91, 0.86, 0.91, and 0.80, respectively, in the dry season of irrigated lowland, wet season of irrigated lowland, rainfed lowland, and rainfed upland. Regardless of the rice growing environment, the three major predictors of rice yields were nitrogen, phosphorus, and potassium fertilizer application rates. Climate and management practices were the main drivers of rice yield in irrigated and rainfed lowlands, while soils and management practices were the major drivers of rice yield in rainfed uplands. The study filled a knowledge gap in the literature by examining the ability of machine learning algorithms to predict rice yield.