Forecast of epidemic development trend in China

The growth model used by the author predicts the development trend of epidemic situation in China , Used 3 The growth models are used to predict the growth rate , Only the code using the logistic growth model is posted here .

logistic The growth curve is also known as s Type curve . The figure on the left of the figure below shows the number of curves , The figure on the right shows the growth rate .

Logistic growth model , Also known as the growth retardation model ,
Logistic curve is usually divided into 5 Period ：

* Start period , Due to the small number of individuals in the population , Density growth is slow , Also known as incubation period .
* Acceleration period , With the number of individuals increasing , Density growth accelerated .
* Transitional period , When the number of individuals reaches half of the saturation density （K/2), Density grows fastest .
* Deceleration period , The number of individuals is more than half of the density （K/2) after , Growth slows .
* Saturation period , The number of individuals reached K Value and saturation .

According to historical experience ,2003 Prediction of SARS patients in , Some scholars use logistic growth model to forecast , And the accuracy is very high , So we also try novel coronavirus patient number by logistic growth model. , The logistic growth model is ：$y=\frac{k}{1+\mathrm{e}^{-a(x-b)}}$
among k Upper limit of novel coronavirus patients ;a It reflects the growth rate ;b Point of inflection , From b The dot starts to rise and slows down , stay b The rising speed reaches the highest point .

OK, so much about the basic knowledge of logistic growth model , Now let's start with some dry goods .
import numpy as np import matplotlib.pyplot as plt import pandas as pd import
seaborn as sns import warnings # from scipy.optimize import curve_fit #
Nonlinear least square fitting from scipy.optimize import leastsq warnings.filterwarnings('ignore')
plt.style.use("seaborn") plt.rc('font', family='SimHei', size=13) # Display Chinese
plt.rcParams['axes.unicode_minus'] = False # It is used to display negative sign normally # Read the data first China_data =
First, we will draw the trend of cumulative number of confirmed cases in China , Our main task is forecasting , No interaction diagram will be posted , Stick a simple trend chart

plt.plot(China_data[' Cumulative diagnosis '], label=' diagnosis ') plt.plot(China_data[' Existing suspected '],
label=' Existing suspected ') plt.plot(China_data[' Cumulative death '], label=' death ')
plt.plot(China_data[' Cumulative cure '], label=' cure ') plt.legend(loc="best")
plt.xlabel(" time ") plt.title("2019-nCoV Epidemic curve ")

Based on previous experience in predicting the number of SARS patients , We also consider using growth models to forecast
# Logistic growth model def logistic_increase_function(p, t): K, a, b = p exp_value =
np.exp(-a * (t - b)) return K / (1 + exp_value) # Define prediction error function def err_f(p, t, y):
return logistic_increase_function(p, t) - y # Initial value of parameter logistic_p0 = [80000, 0.8,
20] # As long as the initial value is not too far off the mark , They all converge # The data we choose t = np.array([i + 1 for i in range(56)])
China_y = China_data[' Cumulative diagnosis '].values # Solving parameters by least square method logistic_params =
leastsq(err_f, logistic_p0, args=(t, China_y)) China_p = logistic_params #
Using the logistic growth function defined by us China_predict_data = logistic_increase_function(China_p, t)
China_predict_data # Prediction error China_e = China_y - China_predict_data China_e #
Draw the scatter plot of the error plt.scatter(China_y, China_e)

For the sample points with large error , Can be deleted , Then the parameters are fitted again , We won't delete it here
# mapping plt.scatter(t, China_y, label=" Number of patients actually diagnosed ") plt.plot(t, China_predict_data,
label=' Predicted number of patients curve ') plt.xlabel('time') plt.ylabel(' Number of patients ') plt.legend(loc='best')

# Forecast the future trend of epidemic situation in China future_t = [i + 1 for i in range(0, 100)] China_future_fit =
logistic_increase_function(China_p, future_t) China_future_fit # mapping
plt.scatter(t, China_y, label=" Number of patients actually diagnosed ") plt.plot(future_t, China_future_fit,
label=" Predicting the number of patients in the future ") plt.xlabel('time') plt.ylabel(' Number of patients ') plt.legend(loc='best')

The prediction of China novel coronavirus pneumonia is the final number of patients. 80717 Left and right , The inflection point appears at 30 day , Namely 2 month 7 Around the day , The outbreak will take place in 80 day , Namely 3 month 29 It ends around the day .

Interested friends , This model can be used to predict South Korea , Japan , Italy , Trend of epidemic development in Iran and other countries , In addition, the author also uses the Gompertz The growth model is also predicted , It won't be posted here , Interested friends , You can do it yourself .

It's just posted here Gompertz Function of the model
# Gompertz Growth model def func(p, t): k, a, b = p return k * a**(b**t)

Technology
Daily Recommendation
views 5
views 2