Factors that may influence the recovery of patients with confirmed SARS-CoV-2 infection hospitalized in the Fangcang shelter were explored, and machine learning models were constructed to predict the duration of recovery during the Omicron BA. 2.2 pandemic. A retrospective study was conducted at Hongqiao National Exhibition and Convention Center Fangcang shelter (Shanghai, China) from April 9, 2022 to April 25, 2022. The demographics, clinical data, inoculation history, and recovery information of the 13,162 enrolled participants were collected. A multivariable logistic regression model was used to identify independent factors associated with 7-day recovery and 14-day recovery. Machine learning algorithms (DT, SVM, RF, DT/AdaBoost, AdaBoost, SMOTEENN/DT, SMOTEENN/SVM, SMOTEENN/RF, SMOTEENN+DT/AdaBoost, and SMOTEENN/AdaBoost) were used to build models for predicting 7-day and 14-day recovery. Of the 13,162 patients in the study, the median duration of recovery was 8 days (interquartile range IQR, 6-10 d), 41.31% recovered within 7 days, and 94.83% recovered within 14 days. Univariate analysis showed that the administrative region, age, cough medicine, comorbidities, diabetes, coronary artery disease (CAD), hypertension, number of comorbidities, CT value of the ORF gene, CT value of the N gene, ratio of ORF/IC, and ratio of N/IC were associated with a duration of recovery within 7 days. Age, gender, vaccination dose, cough medicine, comorbidities, diabetes, CAD, hypertension, number of comorbidities, CT value of the ORF gene, CT value of the N gene, ratio of ORF/IC, and ratio of N/IC were related to a duration of recovery within 14 days. In the multivariable analysis, the receipt of two doses of the vaccination vs. unvaccinated (OR = 1.118, 95% CI = 1.003-1.248; p = 0.045), receipt of three doses of the vaccination vs. unvaccinated (OR = 1.114, 95% CI = 1.004-1.236; p = 0.043), diabetes (OR = 0.383, 95% CI = 0.194-0.749; p = 0.005), CAD (OR = 0.107, 95% CI = 0.016-0.421; p = 0.005), hypertension (OR = 0.371, 95% CI = 0.202-0.674; p = 0.001), and ratio of N/IC (OR = 3.686, 95% CI = 2.939-4.629; p < 0.001) were significantly and independently associated with a duration of recovery within 7 days. Gender (OR = 0.736, 95% CI = 0.63-0.861; p < 0.001), age (30-70) (OR = 0.738, 95% CI = 0.594-0.911; p < 0.001), age (>70) (OR = 0.38, 95% CI = 0292-0.494; p < 0.001), receipt of three doses of the vaccination vs. unvaccinated (OR = 1.391, 95% CI = 1.12-1.719; p = 0.0033), cough medicine (OR = 1.509, 95% CI = 1.075-2.19; p = 0.023), and symptoms (OR = 1.619, 95% CI = 1.306-2.028; p < 0.001) were significantly and independently associated with a duration of recovery within 14 days. The SMOTEEN/RF algorithm performed best, with an accuracy of 90.32%, sensitivity of 92.22%, specificity of 88.31%, F1 score of 90.71%, and AUC of 89.75% for the 7-day recovery prediction; and an accuracy of 93.81%, sensitivity of 93.40%, specificity of 93.81%, F1 score of 93.42%, and AUC of 93.53% for the 14-day recovery prediction. Age and vaccination dose were factors robustly associated with accelerated recovery both on day 7 and day 14 from the onset of disease during the Omicron BA. 2.2 wave. The results suggest that the SMOTEEN/RF-based model could be used to predict the probability of 7-day and 14-day recovery from the Omicron variant of SARS-CoV-2 infection for COVID-19 prevention and control policy in other regions or countries. This may also help to generate external validation for the model.