To develop a machine learning model and nomogram to predict the probability of persistent virus shedding (PVS) in hospitalized patients with coronavirus disease 2019 (COVID-19), the clinical symptoms and signs, laboratory parameters, cytokines, and immune cell data of 429 patients with nonsevere COVID-19 were retrospectively reviewed. Two models were developed using the Akaike information criterion (AIC). The performance of these two models was analyzed and compared by the receiver operating characteristic (ROC) curve, calibration curve, net reclassification index (NRI), and integrated discrimination improvement (IDI). The final model included the following independent predictors of PVS: sex, C-reactive protein (CRP) level, interleukin-6 (IL-6) level, the neutrophil-lymphocyte ratio (NLR), monocyte count (MC), albumin (ALB) level, and serum potassium level. The model performed well in both the internal validation (corrected C-statistic = 0.748, corrected Brier score = 0.201) and external validation datasets (corrected C-statistic = 0.793, corrected Brier score = 0.190). The internal calibration was very good (corrected slope = 0.910). The model developed in this study showed high discriminant performance in predicting PVS in nonsevere COVID-19 patients. Because of the availability and accessibility of the model, the nomogram designed in this study could provide a useful prognostic tool for clinicians and medical decision-makers.