In order to provide decision-making support for the auxiliary diagnosis and individualized treatment of calculous pyonephrosis, the study aims to analyze the clinical features of the condition, investigate its risk factors, and develop a prediction model of the condition using machine learning techniques. A retrospective analysis was conducted on the clinical data of 268 patients with calculous renal pelvic effusion who underwent ultrasonography-guided percutaneous renal puncture and drainage in our hospital during January 2018 to December 2022. The patients were included into two groups, one for pyonephrosis and the other for hydronephrosis. At a random ratio of 7:3, the research cohort was split into training and testing data sets. Single factor analysis was utilized to examine the 43 characteristics of the hydronephrosis group and the pyonephrosis group using the T test, Spearman rank correlation test and chi-square test. Disparities in the characteristic distributions between the two groups in the training and test sets were noted. The features were filtered using the minimal absolute value shrinkage and selection operator on the training set of data. Auxiliary diagnostic prediction models were established using the following five machine learning (ML) algorithms: random forest (RF), xtreme gradient boosting (XGBoost), support vector machines (SVM), gradient boosting decision trees (GBDT) and logistic regression (LR). The area under the curve (AUC) was used to compare the performance, and the best model was chosen. The decision curve was used to evaluate the clinical practicability of the models. The models with the greatest AUC in the training dataset were RF (1.000), followed by XGBoost (0.999), GBDT (0.977), and SVM (0.971). The lowest AUC was obtained by LR (0.938). With the greatest AUC in the test dataset going to GBDT (0.967), followed by LR (0.957), XGBoost (0.950), SVM (0.939) and RF (0.924). LR, GBDT and RF models had the highest accuracy were 0.873, followed by SVM, and the lowest was XGBoost. Out of the five models, the LR model had the best sensitivity and specificity is 0.923 and 0.887. The GBDT model had the highest AUC among the five models of calculous pyonephrosis developed using the ML, followed by the LR model. The LR model was considered be the best prediction model when combined with clinical operability. As it comes to diagnosing pyonephrosis, the LR model was more credible and had better prediction accuracy than common analysis approaches. Its nomogram can be used as an additional non-invasive diagnostic technique.