1 Introduction

The world is going through the COVID-19 pandemic. As of September 13, the cumulative case number has reached 28,917,861 and the total death number is up to 924,567 around the globe [1]. The COVID-19 pandemic hits China in late December of 2019 and then spreads to countries in Europe and America [2, 3]. Now it is accelerating in densely populated developing countries in Asia, Africa, and South America. The current COVID-19 epidemiological situation alerts the world to be prepared for the global health crisis. Many countries have implemented lockdown measures to control the epidemic progression [4,5,6] at different times (Fig. 1). Specific lockdown [7,8,9,10] measures adopted included closing schools, churches, bars, and other social venues, limiting travel and public gatherings, and even shutting down factories and businesses and staying at home. These interventions helped these countries reduce case numbers and mortality rates at different levels. Under the economic pressure [11, 12], some countries have lifted the lockdown measures and some are planning to. However, the epidemic progression may rebound once these controls are lifted. Therefore, forecasting the epidemic progression once the interventions start to be implemented or lifted is crucial. Such prediction can provide valuable information for a better understanding of the current situation and help policymakers and health authorities make appropriate plans to manage the country. However, the challenge lies in making predictions for the countries in the early stage of the COVID-19 pandemic, which are with too scarce data to train an accurate prediction model.

Fig. 1
figure 1

Timeline of COVID-19 dispersion of different countries and government responses. The start point of the X-axis is the date when China reported a cluster of COVID-19 cases in Wuhan, Hubei Province (2019-12-31). The length of the green bar denotes the days from 2019/12/31 to the date of the first detected cases in each specific country. The length of the light pink bar denotes the days from the first detected case to reaching 1 case per million in each country. The dark pink bar denotes the days from the date of reaching 1 case per million to May 31. The x-coordinate of the black dot means the days from the start point to the start date of the lockdown measure. The x-coordinate of the black triangle means the days from the start point to the end date of the lockdown measure. Among the countries which were still under lockdown before May 31 (no triangle presents in the corresponding panel), Indonesia, Singapore, and the USA had announced their lockdown end date as July 31, June 1, and June 1 respectively

There have been existing studies on predicting the spread of COVID-19 [13,14,15,16,17]. Traditional epidemiology models, such as susceptible infected (SI) [17, 18], SI recovered (SIR) [19], and susceptible exposed infected recovered (SEIR) [20,21,22,23], analyze the infection rate based on the dynamic change in the number of infections and subsequently predict the spread and development trend of the epidemic. However, these models made strong assumptions on the infection dynamics and are appropriate to predict the long-term trend of the epidemic. Time series analysis models, such as autoregressive integrated moving average (ARIMA), have also been applied to predict the epidemic trends. The ARIMA model can cover a wide range of patterns stationary to non-stationary and seasonal (periodic) time series, but their prediction performance is limited by their reliance on the prior knowledge of model parameters or inherent time lags. Furthermore, these models do not account for additional factors that can impact the development of infectious diseases [24]. Recently, deep learning algorithms, such as a recurrent neural network (RNN), have also been applied to predict the epidemic progression [15, 21]. These models are completely data driven and do not rely on any prior assumptions. Although they have been demonstrated to be able to achieve prediction performance, they require a large number of training samples due to their complex architectures [25, 26]. Countries at the early stage of COVID-19 only have limited data points, which makes it difficult to train a deep learning model sufficiently and achieve satisfactory performance.

To control the spread of the epidemic, lockdown measures have been proven to be effective [4, 5, 10]. After the lockdown starts, its influence on the spread of the COVID-19 will change over time. In particular, during the first several days of lockdown, the trend of the epidemic may not change because of the existence of the incubation, after which the change will take place and become more and more obvious [23]. This means that different attentions should be paid to the lockdown at different time points. However, few prediction models have considered such time-varying impact of the lockdown, which results in poor performance.

Our study focuses on predicting the epidemic spread trends in different countries with the governments switching the lockdown measures. Specifically, we developed an attention-based RNN framework named ALeRT-COVID with transfer learning to achieve the goal.

2 Method

2.1 Material

The data sources used in our study include the daily reported COVID-19 cases (updated on May 31) [27], the lockdown timeline [28], and populations [29] of 83 countries all over the world. Although the models in this paper were built based on the data until May 31, the proposed method can be used to predict the epidemic trends of COVID-19 at any time point. As the population sizes in different countries vary by a large range, we used the confirmed cases per million people (CCPM) in each country to estimate the severity of the epidemic. The date when the cumulative CCPM number reached one was used as the starting date for each country in our experiment. As the trends of Hubei and other parts of China displayed very different patterns, we treated them as two different areas in our data. For the countries reporting negative new daily cases due to the updated diagnostic criteria, we flatten their curves by using the average number of the neighboring days.

The timeline of the COVID-19 progression for the 83 countries is illustrated in Fig. 1. As of May 31, the days since these countries announced the first COVID-19 cases ranged from 60 to 152 with an average number of 98. These countries implemented the lockdown measures at different periods, ranging from − 7 to 82 with an average value of 27 days from the date of the first case in each country. Especially, the negative value − 7 is corresponding to El Salvador, which started a lockdown before the start of the epidemic in the country. For the countries which had lifted lockdown as of May 31, the average length of the lockdown period is 47 days (min: 4 days; max: 127 days). Twenty countries are still under lockdown by May 31, among which 17 countries had not announced the date for lifting the lockdown.

The source countries are defined in our study as they have suffered from the epidemic for more than 84 days and have lifted lockdown for more than 14 days. Finally, twelve trends of eleven countries, including Austria, China (except Hubei province), Hubei province, Croatia, Germany, Italy, Japan, Lebanon, Monaco, Norway, Oman, and United Arab Emirates meet these criteria. Then, the source set was constructed from these source countries and the 72 target sets are constructed from the other 72 countries (detailed in Method).

We used the countries with rich data to build a source model (Fig. 2a) and transferred it to other target countries (Fig. 2b). Therefore, the prior knowledge learned from the source countries is transferred to complement the prediction for target countries. The attention mechanism was utilized to learn the time-varying impact of the previous case numbers on the final prediction. We evaluated the proposed model using mean absolute percentage error (MAPE) (Fig. 2c) and the results demonstrated our method can make more accurate predictions compared with other baseline models. Our work can help different countries to make decisions on whether the lockdown could be lifted or extended (Fig. 2d).

Fig. 2
figure 2

Schematic representation of the computational steps of ALeRT-COVID. a The source model was trained on the source set constructed from the source countries. b The source model was fine-tuned on each training set constructed from the corresponding target country. c The fine-tuned model (target model) was validated on each test set constructed from the corresponding target country. d The target model was utilized to predict the future CCPM (confirmed cases per million) for the countries once the governments switch the lockdown measures

2.2 Constructing Source and Target Sets

We denote the original data set associated with each specific country i as Di = {Ci, Li}, where C stands for the cumulative CCPM data and L represents the lockdown data, specifically, Ci = {ci(t)}, Li = {li(t)}, and \( t\in \left[1,{T}_{\mathrm{max}}^i\right] \). t = 1 corresponds to the date when the cumulative CCPM number reached 1. \( {T}_{\mathrm{max}}^i \) equals to the number of days from date of t = 1 to May 31 in our experiment. Given an observation window W and a prediction window P, ALeRT-COVID takes Di(t − W, t] = {Ci(t − W, t], Li(t − W, t]} as input and predict the output value ci(t + P) and \( t\in \left[W,{T}_{\mathrm{max}}^i-P\right] \). We construct Si = {Di(t − W, t], ci(t + P)} for each specific country. Specifically, we set both the W and P to 7 days in our paper but they can be changed to other values.

The source set S is obtained by merging the Si from all source countries or areas (Austria, China (except Hubei province), Hubei province, Croatia, Germany, Italy, Japan, Lebanon, Monaco, Norway, Oman, and United Arab Emirates). The target set \( {S}_{t_i} \) is constructed from the target country ti. Finally, we construct one source set composed of 893 sample sequences and 72 target sets consisting of a different number of sample sequences ranging from 32 to 104.

2.3 Architecture of ALeRT-COVID

The architecture of ALeRT-COVID is illustrated in Fig. 3. There are two main components in ALeRT-COVID, aiming to encode the previous CCPM sequence and incorporate the effect of the lockdown measures into the prediction respectively. In the following descriptions, we omit the country index i as the superscript for notation simplification.

Fig. 3
figure 3

Architecture of ALeRT-COVID

The standard long short-term memory (LSTM) [30] is employed to encode the CCPM sequence data. More specifically, LSTM generates hidden states hτ based on the history C(t − W, τ] for any τ ∈ (t − W, t], where t ∈ (W, Tmax − P]. The hidden states H(t − W, t] are then sent into MLP to learn the attention [31] weights α(t − W, t] for identifying which time steps influence most on the final prediction. The encoded CCPM sequence is thus obtained by \( {\sum}_{\tau \in \left(t-W,t\right]}\left({\alpha}_{\uptau}\times {h}_{\uptau}\right) \).

The effect of the lockdown measure on the final prediction is learnt by an MLP taking both the lockdown sequence L(t − W, t] and the CCPM sequence C(t − W, t] together as input. The output of the MLP is denoted as gt.

Then, the final output is \( {\sum}_{\tau \in \left(t-W,t\right]}\left({\alpha}_{\uptau}\times {h}_{\uptau}\right)+{g}_{\mathrm{t}} \). We use the mean square error (MSE) to calculate the final loss.

$$ L=\sum \limits_{t=W}^T{\left(\sum \limits_{\tau \in \left(t-W,t\right]}\left({\alpha}_{\uptau}\times {h}_{\uptau}\right)+{g}_{\mathrm{t}}-{c}_{\mathrm{t}+\mathrm{P}}\right)}^2 $$

where T = Tmax − P.

2.4 Model Configurations and Training Details

2.4.1 Source Model

Given the observation window W = 7 days, we train an LSTM of length 7. We explored different hyperparameters. We tried a different number of LSTM layers from {1, 2, 3}. We also explored different numbers of nodes in the LSTM cell that gradually increases from 2.4 to 10. The activation functions of the LSTM include hyperbolic tangent (tanh) and rectified linear unit (ReLU). The number of attention layers is set to 1. The activation function is softmax. The number of layers of the MLP for lockdown effect is set to 1 and the activation function is selected from {tanh, ReLU}. Particularly, we use the “weight constraints” in Keras [32] to force the weights corresponding to the lockdown vector to be non-positive. We do this because the positive weight of the lockdown vector demonstrates that implementing the lockdown measures will raise the future CCPM number, which is unlikely to happen in reality. The optimizers include ADAM [33], stochastic gradient descent [34], and RMSProp [35]. The batch size varies from 16, 32, and 64. For the source model, we use 5-fold cross-validation on the source set to find the optimal hyperparameters from the above settings. Finally, the source model uses ADAM optimizer, ReLU activation in LSTM, and ReLU activation in MLP for lockdown effect and batch size of 32.

2.4.2 Target Model

Each of the target set is split into a training part (first 80%) and a validation part (last 20%). After training the source model on the source set, we adapt it to each target training set. The architecture of the source model remains the same during transfer learning. We freeze the LSTM parameters in the source model and re-trained (fine-tuned) other parameters in the MLP for lockdown effect and the attention layers on the training part of St. We use the ADAM optimizer and batch size of 4.

2.4.3 Baseline Models

Here we present the architecture of the baseline models we compared in our experiments.

  • Model A: LSTM with a fully connected layer as the output layer. The architecture of the LSTM is the same as that in ALeRT-COVID. The input of model A for a specific country i contains only the CCPM sequence Ci(t − W, t]. The model is trained directly on the training part of the target set without transfer learning.

  • Model B: LSTM with a fully connected layer as the output layer. The architecture of the LSTM is the same as that in ALeRT-COVID. The input of model B for a specific country i contains only the CCPM sequence Ci(t − W, t]. Transfer learning is utilized. A source model is constructed first on the source set and a target model is obtained by fine-tuning the parameters of the last fully connected layer on the training part of the target set.

  • Model C: LSTM with a fully connected layer as the output layer. The architecture of the LSTM is the same as that in ALeRT-COVID. The input of model C for a specific country i contains both the CCPM sequence Ci(t − W, t] and the lockdown information Li(t − W, t]. Transfer learning is utilized. A source model is constructed first on the source set and a target model is obtained by fine-tuning the parameters of the last fully connected layer on the training part of the target set.

2.4.4 Model Evaluation

All the compared models are evaluated on the validation part of each target set by the mean absolute percentage error (MAPE), which is defined as follows,

$$ \mathrm{MAPE}=\frac{1}{T_{\mathrm{max}}-P-W+1}\ \sum \limits_{t\in \left[W,{T}_{\mathrm{max}}-P\right]}\left|{\mathrm{pred}}_{t+P}-{c}_{t+P}\right|/{c}_{t+P} $$

where predt + P is the predicted cumulative CCPM at the time point t+P, ct + P is the ground truth.

3 Result

3.1 Overall Prediction Performance of ALeRT-COVID

ALeRT-COVID first built the source model based on the CCPM sequences constructed from the source countries (detailed in Method). Then, the source model was transferred to each target country through a fine-tuning process. In order to evaluate the benefits of the three components in ALeRT-COVID, which are (1) transfer learning, (2) the lockdown information, and (3) attention mechanism, we also developed four baseline models for each target country.

  • Linear regression model: A linear regression model with 7 predictors taking the cumulative CCPM values of the previous 7 days as input.

  • Model A: Using only the previous cumulative CCPM (confirmed cases per million people) as the predictor and training it directly on each country without transfer learning;

  • Model B: Using only the previous cumulative CCPM as the predictor and fine-tune the transferred source model;

  • Model C: Add the lockdown measure as an additional predictor for model B.

Mean absolute percentage error (MAPE) was utilized to evaluate the prediction performance. The most recent 20% cumulative CCPM numbers of each target country were used as the test sets to calculate the MAPE. Table 1 listed the overall MAPE scores on the 72 target countries. The mean MAPE was 0.118 (SD = 0.298) for the linear regression model. The standard deviation was large because the COVID-19 dispersions of some countries went far away from the linear pattern, which disagreed with the assumption of linear regression. The linear regression model therefore performed significantly worse for these countries. The mean MAPE was 0.100 (SD = 0.087) for model A (no transfer). The models using transfer learning (B, C, and ALeRT-COVID) achieved improved predictive accuracies compared to model A. Among them, ALeRT-COVID achieved the least mean MAPE score of 0.050 (SD = 0.040). Among all 72 target countries, 88.9% obtained MAPE scores less than 0.1 by ALeRT-COVID. These results demonstrated that the three components in ALeRT-COVID all helped enhance the prediction performance.

Table 1 Summary Statistics of MAPE on the test sets of 72 target countries by different models

3.2 Prediction Accuracies for Countries Lifting Lockdown at Different Time

We selected two representative countries which lifted the lockdown at different time periods to further demonstrate the effectiveness of adding the lockdown variable into the trend prediction model (Fig. 4). For the Netherlands, their authorities have announced easing lockdown from May 19 (Fig. 3a); ALeRT-COVID yielded the best MAPE (0.007) compared to the other three models (model A: 0.020; model B: 0.02; model C: 0.033) on the test set. The predicted cumulative CCPM on May 31 by the model A (no transfer) and B (transfer) was much smaller than the ground truth. This was mostly because the model A and B did not consider lockdown and thus could not deal with the situation once the lockdown measures switch. In contrast, ALeRT-COVID and model C have incorporated the lockdown information and thus produced much more precise predictions. Furthermore, ALeRT-COVID can predict better than model C, which suggests the benefits from the attention mechanism. For Singapore (Fig. 3b), although it announced lifting lockdown on June 1, 1 day after May 31, ALeRT-COVID still yielded the best MAPE (0.034) compared to the other three models (model A: 0.259; model B: 0.062; model C: 0.058) on the test set. These results suggest that ALeRT-COVID could capture the pattern of the CCPM trend more precisely for countries lifting lockdown at different time periods.

Fig. 4
figure 4

Prediction of the cumulative CCPM on May 31 for two representative countries that had announced the final date of the lockdown measure. The red points were the true cumulative CCPM on each day. The dashed vertical line represented the end date of the lockdown. The cumulative CCPM values and the lockdown information during May 18 to May 24 were input to the fine-tuned target model to predict the cumulative CCPM in 7 days (May 31). The green, yellow, orange, and blue points denoted the predictions of four different models

3.3 Predicting the Change of the New Case Number When the Lockdown Measure Is Switched

We also used ALeRT-COVID to estimate the change of the new case number within 7 days by switching the lockdown measures. Specifically, for each specific country, we predicted two new case number during the period between June 1 to June 7: one was based on the actual lockdown measure (Predactual) and the other was based on the switched lockdown measure (Predswitched). The change of the new case number within 7 days by switching the lockdown measures was calculated as

$$ \mathrm{change}=\left({\mathrm{Pred}}_{\mathrm{switched}}-{\mathrm{Pred}}_{\mathrm{actual}}\right)/{\mathrm{Pred}}_{\mathrm{actual}} $$

We chose two kinds of countries to do this analysis. The first group was composed of the countries that were still under lockdown until May 31 (Fig. 5a, b). The second group consisted of the countries that had lifted lockdown before May 25(Fig. 5c, d). The result demonstrated that the new case number from June 1 to June 7 of these target countries would increase or decrease to different extents.

Fig. 5
figure 5

Change of the new case number in 1 week brought by switching the lockdown measure. a Increasing percentage of the new case number in 1 week (June 1 to June 7) brought by lifting lockdown from May 25. b Decreasing percentage of the new case number in 1 week (June 1 to June 7) brought by keeping lockdown during May 25 to May 31. The color of the cell in the heatmap represented the predicted new CCPM during June 1 to June 7 by ALeRT-COVID given the actual lockdown information. (predactual: predicted new case number based on the actual lockdown; predswitched: predicted new case number based on switched lockdown)

For those still under lockdown (Fig. 5b), once reopening, the new case number would raise. Especially, Brazil and Chile may suffer a doubled number of new cases in 1 week once the lockdown was lifted. This was mostly because these countries were in the rapid growth phase of the epidemic (Fig. 6a, b). Lockdown measures took a crucial effect on controlling the epidemic progression. In contrast, lifting lockdown took moderate effect on some countries such as Israel and Luxembourg (Fig. 6c, d), because the new case number per day of these countries had decreased for a while.

Fig. 6
figure 6

Cumulative CCPM curve of eight countries. a, b, c, d Brazil, Chile, Israel, and Luxembourg, which were under lockdown during May 25 to May 31. e, f, g, h Nepal, Bolivia, Thailand, Australia, which reopened during May 25 to May 31. The darker color of the point denoted larger new CCPM per day

For countries that had already lifted lockdown before May 25 (Fig. 5d), resuming or extending the lockdown measure could reduce the new case number. Particularly, the new case number of Nepal and Bolivia between June 1 to June 7 might decrease by half if they remained lockdown. This is mostly because the cumulative CCPM of both countries continued a steady increase (Fig. 6e, f). Lockdown measure still helped to a large extent in controlling the spread of the COVID-19. On the contrary, for countries like Australia and Thailand (Fig. 6g, h), as the new case per day was decreasing, there was no big difference between extending and lifting the lockdown in our predictions.

4 Discussion

We proposed a deep learning approach named ALeRT-COVID to predict the COVID-19 spread trend of different countries around the globe.

There were three main novelties in our approach. First, we utilized transfer learning [30] to deal with the insufficient data problem of the countries in the early stage of the COVID-19. Second, we added the lockdown information into the predictors of the proposed model. This enabled ALeRT-COVID to capture the effect of the lockdown measure and more precisely forecast the change of the future case number when the lockdown measure switches. Third, ALeRT-COVID utilized the attention mechanism [31] to capture the contribution of previous CCPM numbers on the trend, which greatly enhanced the model as reflected on the improvement of its prediction performance. It should be noted that although the data was updated on May 31, the proposed methodology can be used to predict the epidemic trend at any time point. In the following, we expand these three points with more details.

Transfer learning [31] can help enhance the deep learning-based prediction models, especially for countries without sufficient data due to the early-stage epidemic. There have been existing studies applying deep learning algorithms to predict the epidemic progression in specific countries [15, 21, 36]. However, they all trained the model directly on the data from these countries. Although deep learning models can achieve much more accurate results, they often require a large amount of data points to train the model, which is difficult for the early-stage countries who just started the COVID-19 crisis for a short time. In contrast, transfer learning mechanisms built the source model based on the source countries with enough training points and then fine-tuned its parameters to better fit the specific target country, which greatly reduced the amount of required training data samples from the target countries with the prior knowledge learned from the source countries [31, 37]. As an example in our results, among the early-stage countries, Sierra Leone underwent the epidemic for 52 days from the date when the cumulative CCPM reached 1, with inadequate samples in the training set. It gained a MAPE score of only 0.202 for models without transfer learning, while transfer learning improved the performance significantly (model B: 0.058; model C: 0.047; ALeRT-COVID: 0.041).

Lockdown measures have been proved to play an important role in controlling the rapid growth of CCPM [8, 38, 39]. Adding the lockdown information could boost the model performance especially for the time points after lifting the lockdown measures. As illustrated in our results, models A and B, which did not use the lockdown information, predicted significantly lower CCPM values than the ground truth for Canada and Netherlands after they lifted the lockdown measure on May 4 and May 19 respectively (Fig. 3a, b). As most of the training data of models A and B was from the previous CCPMs under the lockdown, the model trained on them was unable to learn the logical trend when lockdown has been lifted. Consequently, their predictions still followed a slow-growth course even the country has lifted lockdown already for more than 10 days. In contrast, model C and ALeRT-COVID, which incorporated the lockdown information, could produce much closer predictions to the ground truth.

In addition, ALeRT-COVID added the attention mechanism to better capture the contribution of the previous CCPM numbers on the future trend. In our experiments, we utilized the cumulative CCPM of the last 7 days to predict the CCPM in 1 week. In real-world situations, the previous case number and the lockdown measure in the past days have a different impact on the epidemic progression. Without the attention mechanism, the previous case of each day is assumed to have the same effect on the future trend, which may not be true. The attention mechanism allows these previous case numbers to have a differential impact on future predictions, which makes the model more flexible and thus leads to more accurate predictions.

More importantly, having the lockdown measure can also help predict the impact on the epidemic progression by changing such control policy. We used ALeRT-COVID to predict the new CCPM for certain countries from June 1 to June 7 supposing if they have released the lockdown (still under lockdown in fact) or extended lockdown (reopening already in fact) during May 25 to May 31 respectively.

Once lockdowns have been lifted, we found that the new case number in 1 week would increase significantly for countries such as Brazil and Chile. They would suffer a double number of new cases in 7 days once the lockdown was lifted. This is mostly because the epidemics in these countries are still in rapid growth. Because of the critical role of lockdown in controlling the spread of COVID-19, these countries should consider extending their lockdown measure for a longer time. In contrast, lifting lockdown would not cause a significant increase to the COVID-19 spread for countries like Israel and Luxembourg because the epidemics in these countries had already entered into a gentle phase. In other words, the number of new cases per day had been decreasing for a while. It is safer for these countries to consider releasing the lockdown measure shortly to recover the economy. Similar patterns were presented in the countries which had lifted the lockdown as of May 25. For countries like Nepal and Bolivia, although they were still undergoing a fast increase in the number of cases, the lockdown had been lifted on May 7 and May 10 respectively. From our prediction, the number of new cases within 7 days could be reduced to about 50% if these countries remained lockdown. For countries such as Thailand and Australia, whose COVID-19 spread trends had already entered into a gentle phase, showed no significant decrease in the new case number when extending the lockdown measure. Therefore, our results indicate that it is important to extend or resume the lockdown measures for the countries that still undergo a rapid growth of the case number. And, it is relatively safer to release the lockdown measure for the sake of economic recovery for the countries with a decreasing number of new cases.

There are several limitations to our research. First, the lockdown measure was modeled as a binary variable representing the lockdown is on or off. However, different countries conducted different levels of lockdown. Even within the same country, such as the USA, different states had different lockdown measures. A more fine-grained quantification of the lockdown measures may enhance the prediction performance. In addition, more related information could be introduced to the model such as the number of recovered cases, death cases, and available healthcare resources. Although the proposed method aims at predicting the cumulative case numbers, the prediction targets can be conveniently changed to the number of recovery or death cases.

In conclusion, our predictions provide valuable data-driven insights for a better understanding of the current situation and could help policymakers and health authorities make plans to manage the future situation. Although the models in this paper were built on the data updated on May 31, the proposed method can be used to predict the epidemic trends of COVID-19 at any time point.