A simple epidemic model with basic Python tools

β€œWhy not rekindle the epidemic,” the thought came suddenly. Work from home with the right organization can be more effective than office work, as a result of which there is an honest extra time to β€œthink” about something else.


It all began, of course, from building a daily visualization of data on COVID-19 from the European Center for Disease Control. A simple algorithm draws graphs on updated data daily at noon. The charts draw attention to China's effective anti-epidemic actions when the epidemic began to decline in early March. But the countries of Europe pick up the baton - first Italy (can you remember how in late February the Milan authorities asked tourists to return to the city, because the economy is suffering?), Then Spain.


image


β€” , , -, . 30 β€” , , , ? ? .


β€œβ€ COVID-19 β€” - . , (!) . . . ? β€” !



- β€” . β€” . β€” . , β€” . . 3 :


  • : \\

, , β€” , . . ? , β€” β€œ ” caseIssuedDate ( β€” ). , β€” β€œ ” severity . β€œβ€ .


: - = 1 .
:


  #['infectDate', 'endOfCaseDate', 'result', 'severity', 'caseDocumentedDate', 'isolated' ]
  epidemy = [[0, None, 'infected', 'mild', None, False]] 

*, \ β€˜result’ . β€˜recovered’ β€˜dead’.


β€” , …
β€” . , ( β€œβ€, , ). , β€” .


β€” , β€œβ€. , 0.1 (10%) 1 10 . 100 10 , 100 10 0.1 = 100 . , : , . () :


 ['infectDate', 'endOfCaseDate', 'result', 'severity', 'caseDocumentedDate', 'isolated' ]

, , ( β€” !) .


β€” , , . ? , . : , , , β€” deathRate.


- ::



#  

dailyTransmissionContacts = 15 #    

# 

contagiousness = 0.01       #
severityRate = 0.3          #  
deathRate = 0.5             #  (   )
caseDuration = 25          # 

#  
closedPopulation = 10000

# 

periodToDocumented = caseDuration * 0.6 #       
mildDocumentedRate = 0.3
severeDocumentedRate = 0.9
isolationQualityRate = 0.1

#  

showDays = 150 #Ρ–  Ρ–

(. ) :
periodToIssued β€” , ,
mildDocmentedRate β€” 30%
severeDocumentedRate = 90%
isolationQualityRate β€” () . 100%


? , β€” … , , , , . β€” . . , COVID-19. β€” .



. :


β€” β€œβ€ β€œβ€ β€œβ€
, β€œβ€ β€”
.2


   susceptibleToday = (closedPopulation - infectedCountToday - recoveredCountToday)
   newAffectedPeopleCount = int(((activeInfectedCountToday * dailyTransmissionContacts * contagiousness) // 1 * susceptibleToday/closedPopulation + 1))

* β€” β€œβ€ . . ( ) .


.


.


, pandas.


10 . : 0 (.. ) 100%, β€œβ€ .
6 . 120 ( ) ( ) β€” , .


totalAffected: 10000     deathsTotal: 1582   deathRate_real = 15%

image


( ). 10 , ,


image


. , . , COVID-19, β€” 5-7 . , , β€”


image


caseDuration :


image


: , , .


:


. caseIssuedDate β€” . β€œβ€ . : β€œ , ”. , , - .


: β€œ, , . > ?”
: β€œ , ...

: , , β€” . 2 : mildDocumentedRate severDocumentedRate β€” ( ) . : 7-9 10 , , . , . , , , , , . ? , . , .


mildIDocumentedRate = 0.3
severeDocumentedRate = 0.9

image


, . , : 150 50 β€” , , .. .


, .


, .. , . , . () .


( β€” β€” )


totalAffected: 10000     deathsTotal: 1582   deathRate_real = 15%
DocumentedTotal: 4789    deathsDocumented: 1406  deathRate_docum = 29%

. .


() : β€œβ€ . β€” , .


periodToDocumented β€” . , β€œβ€ , , . , β€” , β€” , , .


imageepidemy-7


periodToDocumented. mildDocumentedRate = 0.3 (30% ). β€œβ€ , , .


: β€” , .


image


, [20:30] .


, , β€” .



:


  • (, )
  • ( ) +


.
. , , , .


image


(0 β€” , 1 β€” ).
, β€” , β€œ ” . , .



( ) .


, , . . , . ( 0.7) periodToDocumented.
, periodToDocumented ( ) 60% , .. 25 * 0.6 = 15 . 10, 7, 4


image


, , β€” β€œβ€ , , , , . , .


:


totalAffected: 10000     deathsTotal: 1486   deathRate_real = 14%
totalAffected: 10000     deathsTotal: 1556   deathRate_real = 15%
totalAffected: 10000     deathsTotal: 1439   deathRate_real = 14%
totalAffected: 8466  deathsTotal: 1248   deathRate_real = 14%


β€” β€” . 2 :


dailyTransmissionContacts = 15 #  
contagiousness = 0.01 # 

β€œ ” . .


image


totalAffected: 10000     deathsTotal: 1557   deathRate_real = 15%
totalAffected: 7727  deathsTotal: 1173   deathRate_real = 15%
totalAffected: 4597  deathsTotal: 709    deathRate_real = 15%
totalAffected: 2008  deathsTotal: 299    deathRate_real = 14%

. 5 . , β€œ ”. β€” .



, .
. : 60 80, .


image


, , β€œβ€ , , β€œ ”


totalAffected: 10000 deathsTotal: 1557 deathRate_real = 15%
totalAffected: 4597 deathsTotal: 709 deathRate_real = 15%
totalAffected: 10000 deathsTotal: 1434 deathRate_real = 14%



, β€œβ€ , . , , , , / (, , ). β€œ ” β€” . , . , , β€” , ( , , , , , β€” , β€” ).
. ! , , .


: epidemy (β€˜recovered’).


image
image


totalAffected: 7890 deathsTotal: 1162 deathRate_real = 11%
totalAffected: 10000 deathsTotal: 1557 deathRate_real = 15%


5 20 ( ) 30% β€” .



, . :


  • , «». . .
  • . (, , , ) , , .
  • , ( β€œ ”).


β€œ ” , .


β€œ ” β€œβ€ . , , , β€” . β€œβ€ β€œ ” .


Different methods of suppression can significantly differ in effect: the tested methods of β€œself-isolation” and even β€œearly detection” did not show the expected positive results with model parameters close to COVID19. At the same time, any measure of suppression to one degree or another β€œsmoothes out” the peak of the epidemic, which can positively affect the work of the healthcare system in the context of the epidemic.


The most effective measure was quarantine. Timely and sufficient quarantine can not only β€œstretch” the course of the epidemic, reducing the burden on the healthcare system, but also at times reduce both the number of cases and mortality.


Laptop on google colab link


All Articles