Modeling on 2019_nCoV novel coronavirus (Wuhan pneumonia) of (Ⅱ) - epidemic prediction based on Logistic Model

Modeling on 2019_nCoV novel coronavirus (Wuhan pneumonia) of (Ⅱ) - epidemic prediction based on Logistic Model

introduction

Model was completed in February 6th, on considering the model problem, we mainly refer to the article about the big brother to the csdn HowNet from the carefully considered, Logistic model and determine the use of the latent period SEIR model with the analysis of the epidemic and prediction. Deficiencies hope readers pay more correction.

Fetch data analysis

Firstly, the author of the data captured china_Dailylist the simple analysis, to extract table data, confirm the number of people diagnosed daily. Draw a simple trend.

#引用约定
import pandas as pd
from pylab import *
mpl.rcParams['font.sans-serif'] = ['SimHei']#解决中文乱码问题
from matplotlib import pyplot as plt
import random
import numpy as np
import matplotlib
import collections
from scipy.optimize import curve_fit
import math
#from matplotlib import pyplot as plt
data=pd.read_csv('china_DailyList_2020_02_03.csv')
print(data.head())
x=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]
y=data['confirm']
z=data['heal']
plt.plot(x,y,color='green',marker='o',linestyle='solid',label='疫情确诊人数')
plt.plot(x,z,color='red',marker='o',linestyle='solid',label='治愈人数')
plt.title('疫情趋势图')#加标题
plt.ylabel('患病人数')
plt.xlabel("日期")
plt.show()

Here the x-axis date - a gripping start date is the author of the main data, date 1-25 2020-01-23_2020-02-05 represented.
Here Insert Picture Description
The number of diagnosed together into a smooth curve can be seen:

plt.plot(x,y,'r',label='疫情确诊人数')
plt.ylabel('人数')
plt.xlabel("日期")
plt.legend(loc=0)
plt.show()

Here Insert Picture Description

Logistic model

Mathematical Principle I Logistic model is omitted here, may be interested in learning about self Baidu
Here Insert Picture Descriptionin short, using the existing data, fitting the above-mentioned equation, P (t): the number of function; K: most value; r: Growth Resistance ( Medical isolation as a result of the epidemic growth resistance).

#logistic模型
# a=0.10
# b=0.60
# eor=100


def logistic_increase_function(t, K, P0, r):
     r=0.29
     t0 = 1
     exp_value = np.exp(r * (t - t0))
     return (K * exp_value * P0) / (K + (exp_value - 1) * P0)
     # 日期与感染人数
t = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
t = np.array(t)
P = data['confirm']
# 最小二乘拟合
P = np.array(P)
popt, pocv = curve_fit(logistic_increase_function, t, P)
# for i in range(len(P)):
#      print(P[i])
# print(type(P))
# print(type(P))
# print(P)


#所获取的opt皆为拟合系数
print("K:capacity P0:intitial_value r:increase_rate t:time")
print(popt)
#拟合后对未来情况进行预测
P_predict=logistic_increase_function(t,popt[0],popt[1],popt[2])
future=[25,27,29,40,60,71,76,82]
future=np.array(future)
future_predict=logistic_increase_function(future,popt[0],popt[1],popt[2])
#近期情况
tomorrow=[25,26,27,28,29,30,31]
tomorrow=np.array(tomorrow)
tomorrow_predict=logistic_increase_function(tomorrow,popt[0],popt[1],popt[2])
#图像绘制
plot1=plt.plot(t,P,'s',label="疫情确诊感染人数")
plot2=plt.plot(t,P_predict,'r',label='感染人数拟合曲线')
plot3=plt.plot(tomorrow,tomorrow_predict,'s',label='近期感染人数预测')

plt.xlabel('日期')
plt.ylabel('确诊人数')
plt.legend(loc=0)
plt.show()
plot4=plt.plot(future,future_predict,'s',label='未来感染人数预测')
plt.show()
for i in range(25):
     people_sick=int(logistic_increase_function(np.array(i+25),popt[0],popt[1],popt[2]))
     print("2月%d日确诊人数预计:%d人"%(i+6,people_sick))

Selection of the resistance r

In python logticis fitting, different degrees of growth resistance, can affect the quality of the selected curve fitting results of late. r and K selected in which all should be fine, for convenience, the author in advance to discuss r
r = 0.6 when;
Here Insert Picture Description
when 0.1 r =;
Here Insert Picture Description

Fitting results

I believe that the optimization method is 1. r mesh optimization;
2. binary optimization; (where I take 0.29 as a result of optimization)
Here Insert Picture Description
for predicting the future number of patients, and the inflection point analysis:
Here Insert Picture Description
Here Insert Picture Description
appearance date predicting an inflection point in late February to 3 in early May, the number of peak prevalence is approximately 50,000 people.

summary

Aspects of the model chosen, Logistic only about the date and the number is expected to peak to the inflection point of the sick, the whole process can not predict the epidemic, while k r and worthy of the optimization problem needs to be improved.

reference

HowNet
https://blog.csdn.net/z_ccsdn/article/details/104134358

Some

Yunqi General Assembly on a foreign programmer Ali's nickname Little America, talked about this passage: in China want to get married must have a house, I am going to marry his girlfriend and northeast, then go to the Emerald City house. The house is 90 flat, my wife said to me: "This house is too small friends."
Mel puzzled, his wife said: "I did not mean you, I mean, in future we may have to contribute to it ? "
Mel:" java java python is what the world's best language ah "??.

Published 18 original articles · won praise 0 · Views 1232

Guess you like

Origin blog.csdn.net/Zengmeng1998/article/details/104208284