Water is the active basis for the movement and transformation of various biological, physical and chemical substances and the flow of energy. On the one hand, the quality of water environment is very sensitive to changes in the external world; on the other hand, water quality affects the health of organisms and ecosystems through ecological support and other functions. The space-time distribution of water quality was analyzed according to the composition of basic substances and established water quality standards, which provided scientific basis for the rational development and utilization of water resources planning and management. In this paper, the stochastic forest algorithm was used to evaluate the water pollution degree of Qingshui River basin. This paper first analyzed the causes of Qingshui River pollution, and introduced the establishment method of random forest (RF) classification model. After that, this paper established the evaluation criteria of water pollution degree, and constructed the evaluation model of water pollution degree of Qingshui River basin according to the RF algorithm. In the experiment part, the quantity of decision trees (DT) of the RF model was set to 400 through sample training, and the classification accuracy of the RF classification model and the artificial neural network (ANN) model was compared. The experimental results showed that the RF classification model has a high classification accuracy rate of 97.33%, which can be used to assess the degree of water pollution. At the end of this paper, the RF classification model was used to evaluate the water pollution degree of the Qingshui River basin. The results showed that for the three stations in the Qingshui River basin, the water quality classification results are Class I, Class III, and Class IV. The water pollution degree of the Qingshui River basin is relatively serious.