The effects of environmental factors on phytoplankton are not simply positive or negative but complex and dependent on the combination of their concentrations in a fluctuating environment. Traditional statistical methods may miss some of the complex interactions between the environment and phytoplankton. In this study, the temporal-spatial fluctuations of phytoplankton diversity and abundance were investigated in a shallow temperate mountain river. The machine learning method classification and regression tree (CART) was used to explore the effects of environmental variables on the phytoplankton community. The results showed that both phytoplankton species diversity and abundance varied fiercely due to environmental fluctuation. Microcystis aeruginosa, Amphiprora sp., Anabaena oscillarioides, and Gymnodinium sp. were the dominant species. The CART analysis indicated that dissolved oxygen, oxidation-reduction potential, total nitrogen (TN), total phosphorus (TP), and water temperature (WT) explained 36.00%, 13.81%, 11.35%, 9.96%, and 8.80%, respectively, of phytoplankton diversity variance. Phytoplankton abundance was mainly affected by TN, WT, and TP, with variance explanations of 39.40%, 15.70%, and 14.09%, respectively. Most environmental factors had a complex influence on phytoplankton diversity and abundance: their effects were positive under some conditions but negative under other combinations. The results and methodology in this study are important in quantitatively understanding and exploring aquatic ecosystems.