The world still suffers from the COVID-19 pandemic, which was identified in late 2019. The number of COVID-19 confirmed cases are increasing every day, and many governments are taking various measures and policies, such as city lockdown. It seriously treats people’s lives and health conditions, and it is highly required to immediately take appropriate actions to minimise the virus spread and manage the COVID-19 outbreak. This paper aims to study the impact of the lockdown schedule on pandemic prevention and control in Ningbo, China. For this, machine learning techniques such as the K-nearest neighbours and Random Forest are used to predict the number of COVID-19 confirmed cases according to five scenarios, including no lockdown and 2 weeks, 1, 3, and 6 months postponed lockdown. According to the results, the random forest machine learning technique outperforms the K-nearest neighbours model in terms of mean squared error and R-square. The results support that taking an early lockdown measure minimises the number of COVID-19 confirmed cases in a city and addresses that late actions lead to a sharp COVID-19 outbreak.