Estimation des paramètres d’un modèle SIRD pour la France

On récupère les données réelles pour un pays et on cherche à estimer un modèle CovidSIRD. Il y a deux problèmes avec les données. Le premier est que le nombre de cas positifs est largement sous-estimé. La principale raison durant le premier confinement fut le manque de tests, limité à 5000 pendant cette période. La seconde raison est que les personnes asymptomatiques ne le savent pas et ne se font pas toujours tester. Le délai d’attente des résultats des tests, les longues queues devant les laboratoires ont peut-être aussi joué puisqu’aux mois d’août, septembre.

Récupération des données

from datetime import timedelta
import warnings
import numpy
import pandas
from pandas import to_datetime
import matplotlib.gridspec as gridspec
import matplotlib.pyplot as plt
from matplotlib.cbook.deprecation import MatplotlibDeprecationWarning
from aftercovid.data import extract_hopkins_data, preprocess_hopkins_data
from aftercovid.models import CovidSIRD, rolling_estimation


data = extract_hopkins_data()
diff, df = preprocess_hopkins_data(data)
df.tail()
deaths confirmed recovered infected safe
10/15/21 114931.076674 6.904552e+06 6.700998e+06 88125.0 6.009595e+07
10/16/21 114945.684611 6.909010e+06 6.705737e+06 87793.0 6.009152e+07
10/17/21 114967.888676 6.912448e+06 6.710001e+06 86874.0 6.008816e+07
10/18/21 114987.365925 6.915821e+06 6.713874e+06 87314.0 6.008382e+07
10/19/21 115001.000000 6.920457e+06 6.719844e+06 85825.0 6.007933e+07


Séries différenciées.

deaths confirmed recovered infected safe
10/15/21 33.111324 5267.494155 5293.960632 -71.0 -5789.0
10/16/21 14.607937 4457.670386 4739.666779 -332.0 -4899.0
10/17/21 22.204065 3437.656403 4263.519273 -919.0 -3778.0
10/18/21 19.477250 3373.279963 3873.014711 440.0 -1057.0
10/19/21 13.634075 4636.013598 5970.017397 -1489.0 -5095.0


Graphes.

fig = plt.figure(tight_layout=True, figsize=(12, 10))
gs = gridspec.GridSpec(2, 2)
axs = []
ax = fig.add_subplot(gs[0, :])
df.plot(logy=True, title="Données COVID", ax=ax)
axs.append(ax)
ax = fig.add_subplot(gs[1, 0])
df[['recovered', 'confirmed', 'infected']].diff().plot(
    title="Différences", ax=ax)
axs.append(ax)
ax = fig.add_subplot(gs[1, 1])
df[['deaths']].diff().plot(title="Différences", ax=ax)
axs.append(ax)
for a in axs:
    for tick in a.get_xticklabels():
        tick.set_rotation(30)
Données COVID, Différences, Différences

On voit qu’en France, les données sont difficilement exploitables en l’état. Et on sait qu’en France la pénurie de tests implique une sous-estimation du nombre de cas positifs. L’estimation du modèle est très compromise.

Estimation d’un modèle

Sur 21 jours.

model = CovidSIRD()
print(model.quantity_names)

cols = ['safe', 'infected', 'recovered', 'deaths']
data = df[cols].values.astype(numpy.float32)
print(data[:5])

X = data[:-1]
y = data[1:] - data[:-1]
dates = df.index[:-1]

Out:

['S', 'I', 'R', 'D']
[[6.7e+07 0.0e+00 0.0e+00 0.0e+00]
 [6.7e+07 1.0e+00 0.0e+00 0.0e+00]
 [6.7e+07 1.0e+00 0.0e+00 0.0e+00]
 [6.7e+07 2.0e+00 0.0e+00 0.0e+00]
 [6.7e+07 2.0e+00 0.0e+00 0.0e+00]]

Estimation sur 3 semaines car les séries sont cycliques.

dfcoef, model = rolling_estimation(
    X, y, delay=21, dates=dates, verbose=1)
dfcoef.head(n=10)

Out:

k=7 iter=4 loss=2.980 l1=2.32e-08 coef=[0.04631365 0.01480898 0.00035811] R0=3.0535624921162414 lr=100.0 cn=0.0
k=14 iter=5 loss=3.453 l1=2.68e-08 coef=[0.07515167 0.04856004 0.011453  ] R0=1.2522555151232035 lr=1000000.0 cn=0.0
k=21 iter=4 loss=2.164 l1=1.85e-08 coef=[0.03724919 0.02701245 0.0145887 ] R0=0.8953884882854667 lr=100.0 cn=0.0
k=28 iter=4 loss=571.520 l1=2.79e-07 coef=[0.40889166 0.00451389 0.1034844 ] R0=3.7860938873012646 lr=100.0 cn=0.0
k=35 iter=84 loss=1081.491 l1=4.72e-07 coef=[0.32565848 0.0022913  0.31082536] R0=1.0400547973612944 lr=10000.0 cn=0.0
k=42 iter=7 loss=96502.399 l1=3.4e-06 coef=[0.41376276 0.02358635 0.2874978 ] R0=1.3300669989157972 lr=1 cn=0.0
k=49 iter=8 loss=1629919.810 l1=1.66e-05 coef=[0.34480092 0.00088429 0.08794831] R0=3.881468057431081 lr=0.0001 cn=0.0
k=56 iter=500 loss=3910723.048 l1=3.29e-05 coef=[0.13068025 0.00216315 0.07153133] R0=1.7732706850939994 lr=0.01 cn=0.0
k=63 iter=428 loss=239010767.238 l1=0.000145 coef=[0.14646042 0.00945349 0.02338074] R0=4.460601748548055 lr=0.0001 cn=0.0
k=70 iter=500 loss=261585920.000 l1=0.000157 coef=[0.04813412 0.01478064 0.01159255] R0=1.8251157109589686 lr=1e-06 cn=0.0
k=77 iter=500 loss=264586556.952 l1=0.000155 coef=[0.03555068 0.01060809 0.00753164] R0=1.9598238070238652 lr=1e-06 cn=0.0
k=84 iter=349 loss=256761075.810 l1=0.000223 coef=[0.01003199 0.03640417 0.00644764] R0=0.23410880032571038 lr=1e-06 cn=0.0
k=91 iter=79 loss=246613308.952 l1=0.000231 coef=[0.00137093 0.05397377 0.00616655] R0=0.022795584079785294 lr=1e-06 cn=0.0
k=98 iter=500 loss=208717897.143 l1=0.000189 coef=[1.00000000e-04 1.28849607e-01 1.51085566e-02] R0=0.0006946462615344612 lr=0.0001 cn=0.0
k=105 iter=4 loss=7230698.667 l1=4.55e-05 coef=[1.00004947e-04 1.81899008e-01 3.12190871e-02] R0=0.0004692466254623554 lr=1e-06 cn=0.0
k=112 iter=16 loss=1959700.952 l1=2.41e-05 coef=[0.02981807 0.08137871 0.02375688] R0=0.28361540835868554 lr=0.0001 cn=0.0
k=119 iter=19 loss=2407339.048 l1=2.1e-05 coef=[0.06713771 0.01750238 0.0086955 ] R0=2.562715608659572 lr=0.0001 cn=0.0
k=126 iter=294 loss=1663581.524 l1=1.64e-05 coef=[0.05584044 0.01712505 0.00579015] R0=2.436829595879982 lr=0.01 cn=0.0
k=133 iter=23 loss=1637082.286 l1=1.58e-05 coef=[0.04192133 0.0292884  0.0041349 ] R0=1.2542545616378977 lr=0.01 cn=0.0
k=140 iter=14 loss=1469404.952 l1=1.83e-05 coef=[0.00893012 0.04648467 0.00371847] R0=0.17787967859283899 lr=0.0001 cn=0.0
k=147 iter=11 loss=1283643.714 l1=1.64e-05 coef=[0.00017652 0.07515664 0.01003746] R0=0.0020719385542285647 lr=0.0001 cn=0.0
k=154 iter=19 loss=883657.048 l1=1.22e-05 coef=[0.00010708 0.07894038 0.01748743] R0=0.001110422323279307 lr=0.0001 cn=0.0
k=161 iter=42 loss=140495.524 l1=6.79e-06 coef=[0.05868272 0.03922259 0.00493057] R0=1.3290718235281485 lr=0.01 cn=0.0
k=168 iter=500 loss=258684.286 l1=8.08e-06 coef=[0.06659927 0.03311988 0.00357812] R0=1.8147929519392374 lr=1 cn=0.0
k=175 iter=4 loss=565865.667 l1=1.15e-05 coef=[0.08527167 0.03253641 0.0031956 ] R0=2.3864219861855136 lr=0.0001 cn=0.0
k=182 iter=4 loss=1107562.762 l1=1.66e-05 coef=[0.09233279 0.02781876 0.00019692] R0=3.2957544396573306 lr=1e-06 cn=0.0
k=189 iter=500 loss=1960218.857 l1=2.32e-05 coef=[0.08779094 0.01963441 0.0010015 ] R0=4.254280913231312 lr=0.01 cn=0.0
k=196 iter=500 loss=4416929.905 l1=3.7e-05 coef=[0.07415343 0.01719648 0.00231973] R0=3.799581654251945 lr=0.01 cn=0.0
k=203 iter=4 loss=12437557.333 l1=5.28e-05 coef=[0.08701538 0.01878601 0.00110953] R0=4.3736121220626165 lr=1e-06 cn=0.0
k=210 iter=75 loss=12726515.810 l1=5.71e-05 coef=[0.08353434 0.02124562 0.00045377] R0=3.849617483904406 lr=1e-06 cn=0.0
k=217 iter=500 loss=13251809.524 l1=6.16e-05 coef=[0.07823789 0.02470096 0.00036444] R0=3.1213491605858805 lr=0.0001 cn=0.0
k=224 iter=500 loss=11611875.048 l1=6.19e-05 coef=[0.06917228 0.02776619 0.00047739] R0=2.449132865151245 lr=0.0001 cn=0.0
k=231 iter=302 loss=18710288.762 l1=8.33e-05 coef=[0.06211848 0.03033018 0.00039296] R0=2.0218789901196446 lr=1e-06 cn=0.0
k=238 iter=266 loss=23531512.381 l1=9.68e-05 coef=[0.05690615 0.03188142 0.00033015] R0=1.766637049160731 lr=1e-06 cn=0.0
k=245 iter=340 loss=32746261.333 l1=0.000114 coef=[0.06114179 0.03541223 0.00044845] R0=1.7049816981631345 lr=1e-06 cn=0.0
k=252 iter=500 loss=52949827.048 l1=0.000147 coef=[0.06982762 0.03438601 0.00045983] R0=2.0039010229670495 lr=0.0001 cn=0.0
k=259 iter=500 loss=351543076.571 l1=0.000294 coef=[0.08006627 0.02929404 0.00045668] R0=2.6912383154641413 lr=1e-06 cn=0.0
k=266 iter=500 loss=1141689197.714 l1=0.000489 coef=[0.08001382 0.02607455 0.00089983] R0=2.9662899940124636 lr=1e-06 cn=0.0
k=273 iter=500 loss=1572173336.381 l1=0.000682 coef=[0.06569244 0.02628032 0.00077366] R0=2.428198938659711 lr=1e-06 cn=0.0
k=280 iter=500 loss=1999759652.571 l1=0.000812 coef=[0.05062805 0.03342262 0.00070518] R0=1.483484131367289 lr=1e-06 cn=0.0
k=287 iter=500 loss=2224154526.476 l1=0.000875 coef=[0.03429745 0.04225637 0.00104246] R0=0.7921103255248985 lr=1e-06 cn=0.0
k=294 iter=500 loss=1794580480.000 l1=0.000787 coef=[0.02189436 0.05453035 0.00121505] R0=0.39275641347626755 lr=1e-06 cn=0.0
k=301 iter=500 loss=1167805196.190 l1=0.000586 coef=[0.01224854 0.06974809 0.0001    ] R0=0.17535964142643024 lr=0.01 cn=0.0
k=308 iter=500 loss=357919280.762 l1=0.000332 coef=[0.01874068 0.08116334 0.00108438] R0=0.2278565697392881 lr=1e-06 cn=0.0
k=315 iter=500 loss=140182759.619 l1=0.00024 coef=[0.04574191 0.06978741 0.00161546] R0=0.6406171550029215 lr=0.0001 cn=0.0
k=322 iter=217 loss=65832313.905 l1=0.000161 coef=[0.05451473 0.0489237  0.00158297] R0=1.079357103137038 lr=1e-06 cn=0.0
k=329 iter=465 loss=73490383.238 l1=0.000163 coef=[0.05573222 0.04330696 0.00138812] R0=1.246943171735661 lr=1e-06 cn=0.0
k=336 iter=500 loss=79720222.476 l1=0.000175 coef=[0.05736593 0.04487268 0.0012537 ] R0=1.2436687024321766 lr=1e-06 cn=0.0
k=343 iter=500 loss=75272832.000 l1=0.000175 coef=[0.05946704 0.04227735 0.00158994] R0=1.355612402796211 lr=1e-06 cn=0.0
k=350 iter=500 loss=76572800.000 l1=0.000178 coef=[0.06114382 0.04229018 0.00136794] R0=1.4005141359160393 lr=1e-06 cn=0.0
k=357 iter=500 loss=72664539.429 l1=0.000166 coef=[0.05835223 0.04198813 0.00126648] R0=1.3490408046156959 lr=0.0001 cn=0.0
k=364 iter=500 loss=139849167.238 l1=0.00018 coef=[0.05559168 0.04469056 0.00107363] R0=1.2147420283740356 lr=1e-06 cn=0.0
k=371 iter=500 loss=110935503.238 l1=0.000156 coef=[0.05078141 0.04711492 0.00117714] R0=1.0515478442757973 lr=0.0001 cn=0.0
k=378 iter=500 loss=114604263.619 l1=0.000156 coef=[0.0509472  0.04922884 0.00099698] R0=1.014362779880491 lr=0.0001 cn=0.0
k=385 iter=500 loss=110452480.000 l1=0.000155 coef=[0.05218172 0.04885131 0.00098413] R0=1.0470805392025373 lr=0.0001 cn=0.0
k=392 iter=500 loss=111093162.667 l1=0.000157 coef=[0.05521451 0.04595021 0.00068129] R0=1.184060528513599 lr=1e-06 cn=0.0
k=399 iter=500 loss=114086144.000 l1=0.000156 coef=[0.05813792 0.0448009  0.00079694] R0=1.275014850309261 lr=1e-06 cn=0.0
k=406 iter=500 loss=150049804.190 l1=0.000184 coef=[0.06422068 0.04308974 0.00080184] R0=1.4631662029374317 lr=1e-06 cn=0.0
k=413 iter=500 loss=200179078.095 l1=0.000242 coef=[0.0676497  0.03961296 0.00071304] R0=1.677570273149025 lr=1e-06 cn=0.0
k=420 iter=500 loss=867967171.048 l1=0.000502 coef=[0.05701374 0.03674378 0.00068927] R0=1.5230860587260195 lr=1e-06 cn=0.0
k=427 iter=500 loss=2083858529.524 l1=0.000808 coef=[0.0590203  0.0395048  0.00062276] R0=1.470816767906069 lr=1e-06 cn=0.0
k=434 iter=500 loss=2080229863.619 l1=0.000801 coef=[0.05164465 0.04542733 0.00066854] R0=1.1203747986394035 lr=1e-06 cn=0.0
k=441 iter=500 loss=2054222994.286 l1=0.000777 coef=[0.05350525 0.04879948 0.0008626 ] R0=1.0773862567802233 lr=1e-06 cn=0.0
k=448 iter=500 loss=2190146998.857 l1=0.000755 coef=[0.03644589 0.05124059 0.00118771] R0=0.6951568013906823 lr=1e-06 cn=0.0
k=455 iter=500 loss=2140565504.000 l1=0.000729 coef=[0.03356902 0.05366934 0.00041154] R0=0.6207187617765145 lr=1e-06 cn=0.0
k=462 iter=500 loss=1424293400.381 l1=0.00056 coef=[0.0211167  0.06150964 0.00163585] R0=0.33441347136790095 lr=1e-06 cn=0.0
k=469 iter=500 loss=98393313.524 l1=0.000186 coef=[0.0356882  0.06862772 0.0003437 ] R0=0.5174345978701208 lr=1e-06 cn=0.0
k=476 iter=500 loss=91457359.238 l1=0.000176 coef=[0.03729987 0.07108477 0.00046445] R0=0.5213176550000483 lr=1e-06 cn=0.0
k=483 iter=500 loss=80995547.429 l1=0.00017 coef=[0.04035055 0.06997127 0.00062818] R0=0.571542021663565 lr=1e-06 cn=0.0
k=490 iter=91 loss=48976764.952 l1=0.000142 coef=[0.04248148 0.06841437 0.00082377] R0=0.6135560090492137 lr=1e-06 cn=0.0
k=497 iter=338 loss=40722249.143 l1=0.000139 coef=[0.04106022 0.07424938 0.00013391] R0=0.5520086580917544 lr=1e-06 cn=0.0
k=504 iter=208 loss=35233246.476 l1=0.000109 coef=[0.03299338 0.07910524 0.00080091] R0=0.4129016835439942 lr=1e-06 cn=0.0
k=511 iter=26 loss=19011536.762 l1=7.47e-05 coef=[0.02852046 0.09073154 0.00048295] R0=0.3126746904733567 lr=1e-06 cn=0.0
k=518 iter=500 loss=22492803.048 l1=8.24e-05 coef=[0.04145021 0.06924976 0.00070601] R0=0.5925201449295463 lr=0.0001 cn=0.0
k=525 iter=500 loss=35685546.667 l1=0.00012 coef=[0.13134861 0.03200963 0.00220878] R0=3.838535751079651 lr=1e-06 cn=0.0
k=532 iter=116 loss=71126735.238 l1=0.000149 coef=[0.12357059 0.01632548 0.00135162] R0=6.990431388974611 lr=1e-06 cn=0.0
k=539 iter=500 loss=150981156.571 l1=0.000225 coef=[0.09276317 0.01558896 0.0010042 ] R0=5.590444719697664 lr=1e-06 cn=0.0
k=546 iter=500 loss=196260766.476 l1=0.000282 coef=[0.07130909 0.02503332 0.00055818] R0=2.786436847227345 lr=1e-06 cn=0.0
k=553 iter=500 loss=179079911.619 l1=0.000276 coef=[0.0606659  0.03487146 0.00059624] R0=1.7104550361610265 lr=1e-06 cn=0.0
k=560 iter=500 loss=84117802.667 l1=0.000181 coef=[0.05468578 0.04251823 0.00024608] R0=1.2787713676813885 lr=1e-06 cn=0.0
k=567 iter=500 loss=151035452.952 l1=0.000223 coef=[0.04796413 0.04924436 0.00045121] R0=0.9651591256203587 lr=1e-06 cn=0.0
k=574 iter=500 loss=171703881.143 l1=0.000248 coef=[0.04168717 0.0534574  0.00053406] R0=0.7721066973802195 lr=1e-06 cn=0.0
k=581 iter=500 loss=170395123.810 l1=0.000249 coef=[0.0362079  0.05978042 0.00017276] R0=0.6039362765802949 lr=1e-06 cn=0.0
k=588 iter=500 loss=181087926.857 l1=0.000235 coef=[0.03230714 0.0651438  0.00049037] R0=0.4922305133865458 lr=1e-06 cn=0.0
k=590 iter=500 loss=181566342.095 l1=0.000239 coef=[0.03314745 0.06571309 0.00092189] R0=0.4974480863788404 lr=1e-06 cn=0.0
k=592 iter=500 loss=181493613.714 l1=0.000235 coef=[0.0334288  0.06532319 0.00014081] R0=0.5106440503977661 lr=1e-06 cn=0.0
k=594 iter=246 loss=161262043.429 l1=0.000213 coef=[0.03096132 0.07081916 0.00093038] R0=0.4315194084820261 lr=1e-06 cn=0.0
k=596 iter=195 loss=156730099.810 l1=0.000208 coef=[0.03123417 0.06906    0.00052866] R0=0.4488399103716602 lr=1e-06 cn=0.0
k=598 iter=500 loss=156618886.095 l1=0.000207 coef=[0.03495037 0.06931173 0.00083008] R0=0.4982815752031653 lr=1e-06 cn=0.0
k=600 iter=500 loss=148346709.333 l1=0.000197 coef=[0.03078916 0.07121695 0.00129739] R0=0.4245941446468195 lr=1e-06 cn=0.0
k=602 iter=500 loss=142218044.952 l1=0.000187 coef=[0.03619384 0.06704555 0.00134933] R0=0.5291893335083079 lr=1e-06 cn=0.0
k=604 iter=500 loss=118674785.524 l1=0.000171 coef=[0.0243177  0.06610941 0.00048007] R0=0.3651883491326093 lr=1e-06 cn=0.0
k=606 iter=500 loss=81435568.762 l1=0.000137 coef=[0.03728744 0.06821304 0.00046458] R0=0.5429342990179402 lr=0.0001 cn=0.0
k=608 iter=500 loss=59041871.238 l1=0.000121 coef=[0.02795393 0.0682112  0.00076624] R0=0.40526188483316766 lr=0.0001 cn=0.0
k=609 iter=133 loss=29410172.952 l1=9.65e-05 coef=[0.03972963 0.06888435 0.0011857 ] R0=0.5669987502073386 lr=1e-06 cn=0.0
k=610 iter=99 loss=32304579.048 l1=0.000102 coef=[0.04207308 0.06797145 0.00093313] R0=0.6105991461591954 lr=1e-06 cn=0.0
k=611 iter=267 loss=32516016.762 l1=0.000101 coef=[0.04099417 0.06644    0.00018916] R0=0.6152586976976491 lr=1e-06 cn=0.0
k=612 iter=372 loss=31847713.524 l1=9.86e-05 coef=[0.04290815 0.06580704 0.00042161] R0=0.6478790900937453 lr=1e-06 cn=0.0
k=613 iter=159 loss=31669446.095 l1=9.84e-05 coef=[0.04570953 0.06506878 0.00067206] R0=0.6952987674740129 lr=1e-06 cn=0.0
k=614 iter=73 loss=31845376.000 l1=9.78e-05 coef=[0.04318409 0.06378051 0.00024607] R0=0.6744714139507328 lr=1e-06 cn=0.0
k=615 iter=174 loss=30562541.714 l1=9.36e-05 coef=[0.04403428 0.06209022 0.00052939] R0=0.7032026139736126 lr=1e-06 cn=0.0
k loss loss_l1 it R0 lr correctness beta mu nu
date
2/18/20 7 2.980059e+00 2.322223e-08 4 3.053562 100.000000 0.0 0.046314 0.014809 0.000358
2/25/20 14 3.452673e+00 2.677506e-08 5 1.252256 1000000.000000 0.0 0.075152 0.048560 0.011453
3/3/20 21 2.163956e+00 1.847424e-08 4 0.895388 100.000000 0.0 0.037249 0.027012 0.014589
3/10/20 28 5.715201e+02 2.787354e-07 4 3.786094 100.000000 0.0 0.408892 0.004514 0.103484
3/17/20 35 1.081491e+03 4.715742e-07 84 1.040055 10000.000000 0.0 0.325658 0.002291 0.310825
3/24/20 42 9.650240e+04 3.399682e-06 7 1.330067 1.000000 0.0 0.413763 0.023586 0.287498
3/31/20 49 1.629920e+06 1.657095e-05 8 3.881468 0.000100 0.0 0.344801 0.000884 0.087948
4/7/20 56 3.910723e+06 3.286393e-05 500 1.773271 0.010000 0.0 0.130680 0.002163 0.071531
4/14/20 63 2.390108e+08 1.450981e-04 428 4.460602 0.000100 0.0 0.146460 0.009453 0.023381
4/21/20 70 2.615859e+08 1.568772e-04 500 1.825116 0.000001 0.0 0.048134 0.014781 0.011593


Saving the results.

df.index = to_datetime(df.index)
dfcoef.index = to_datetime(dfcoef.index)
df.to_csv("plot_covid_france_sird.data.csv", index=True)
dfcoef.to_csv("plot_covid_france_sird.model.csv", index=True)

Statistiques.

k loss loss_l1 it R0 lr correctness beta mu nu
count 101.000000 1.010000e+02 1.010000e+02 101.000000 101.000000 101.000000 101.0 101.000000 101.000000 101.000000
mean 349.148515 2.991095e+08 2.020276e-04 347.405941 1.435029 10002.990813 0.0 0.063318 0.047749 0.011243
std 193.705776 5.882727e+08 2.144725e-04 202.281644 1.307128 99498.441579 0.0 0.069087 0.026489 0.044006
min 7.000000 2.163956e+00 1.847424e-08 4.000000 0.000469 0.000001 0.0 0.000100 0.000884 0.000100
25% 182.000000 1.325181e+07 6.188960e-05 133.000000 0.529189 0.000001 0.0 0.035551 0.029294 0.000490
50% 357.000000 7.972022e+07 1.561235e-04 500.000000 1.077386 0.000001 0.0 0.050628 0.045427 0.000930
75% 532.000000 1.810879e+08 2.245092e-04 500.000000 1.814793 0.000100 0.0 0.065692 0.066440 0.002209
max 615.000000 2.224155e+09 8.751078e-04 500.000000 6.990431 1000000.000000 0.0 0.413763 0.181899 0.310825


Fin de la période pour la série originale.

df.tail(n=10)
deaths confirmed recovered infected safe
2021-10-10 114790.005737 6.882241e+06 6.673713e+06 90838.0 6.012066e+07
2021-10-11 114824.090924 6.886015e+06 6.678734e+06 91923.0 6.011452e+07
2021-10-12 114847.880993 6.891299e+06 6.684681e+06 91134.0 6.010934e+07
2021-10-13 114871.671062 6.895306e+06 6.690457e+06 84777.0 6.010989e+07
2021-10-14 114897.965349 6.899285e+06 6.695704e+06 88196.0 6.010120e+07
2021-10-15 114931.076674 6.904552e+06 6.700998e+06 88125.0 6.009595e+07
2021-10-16 114945.684611 6.909010e+06 6.705737e+06 87793.0 6.009152e+07
2021-10-17 114967.888676 6.912448e+06 6.710001e+06 86874.0 6.008816e+07
2021-10-18 114987.365925 6.915821e+06 6.713874e+06 87314.0 6.008382e+07
2021-10-19 115001.000000 6.920457e+06 6.719844e+06 85825.0 6.007933e+07


Fin de la période pour l’estimation.

k loss loss_l1 it R0 lr correctness beta mu nu
date
2021-10-07 604 1.186748e+08 0.000171 500 0.365188 0.000001 0.0 0.024318 0.066109 0.000480
2021-10-09 606 8.143557e+07 0.000137 500 0.542934 0.000100 0.0 0.037287 0.068213 0.000465
2021-10-11 608 5.904187e+07 0.000121 500 0.405262 0.000100 0.0 0.027954 0.068211 0.000766
2021-10-12 609 2.941017e+07 0.000097 133 0.566999 0.000001 0.0 0.039730 0.068884 0.001186
2021-10-13 610 3.230458e+07 0.000102 99 0.610599 0.000001 0.0 0.042073 0.067971 0.000933
2021-10-14 611 3.251602e+07 0.000101 267 0.615259 0.000001 0.0 0.040994 0.066440 0.000189
2021-10-15 612 3.184771e+07 0.000099 372 0.647879 0.000001 0.0 0.042908 0.065807 0.000422
2021-10-16 613 3.166945e+07 0.000098 159 0.695299 0.000001 0.0 0.045710 0.065069 0.000672
2021-10-17 614 3.184538e+07 0.000098 73 0.674471 0.000001 0.0 0.043184 0.063781 0.000246
2021-10-18 615 3.056254e+07 0.000094 174 0.703203 0.000001 0.0 0.044034 0.062090 0.000529


Graphe.

dfcoef['R0=1'] = 1

fig, ax = plt.subplots(2, 3, figsize=(14, 6))
with warnings.catch_warnings():
    warnings.simplefilter("ignore", MatplotlibDeprecationWarning)
    dfcoef[["mu", "nu"]].plot(ax=ax[0, 0], logy=True)
    dfcoef[["beta"]].plot(ax=ax[0, 1], logy=True)
    dfcoef[["loss_l1"]].plot(ax=ax[1, 0], logy=True)
    dfcoef[["R0", "R0=1"]].plot(ax=ax[0, 2])
    df.drop('safe', axis=1).plot(ax=ax[1, 1], logy=True)
    for i in range(ax.shape[1]):
        for tick in ax[1, i].get_xticklabels():
            tick.set_rotation(30)
    ax[0, 2].set_ylim(0, 5)
    fig.suptitle('Estimation de R0 tout au long de la période\n'
                 'Estimation sur 3 semaines', fontsize=12)
plt.show()
Estimation de R0 tout au long de la période Estimation sur 3 semaines

Graphe sur les dernières valeurs.

dfcoeflast = dfcoef.iloc[-30:, :]
dflast = df.iloc[-30:, :]

fig, ax = plt.subplots(2, 3, figsize=(14, 6))
with warnings.catch_warnings():
    warnings.simplefilter("ignore", MatplotlibDeprecationWarning)
    dfcoeflast[["mu", "nu"]].plot(ax=ax[0, 0], logy=True)
    dfcoeflast[["beta"]].plot(ax=ax[0, 1], logy=True)
    dfcoeflast[["loss_l1"]].plot(ax=ax[1, 0], logy=True)
    dfcoeflast[["R0", "R0=1"]].plot(ax=ax[0, 2])
    dflast.drop('safe', axis=1).plot(ax=ax[1, 1], logy=True)
    for i in range(ax.shape[1]):
        for tick in ax[1, i].get_xticklabels():
            tick.set_rotation(30)
    ax[0, 2].set_ylim(0, 5)
    fig.suptitle('Estimation de R0 sur la fin de la période', fontsize=12)
Estimation de R0 sur la fin de la période

Sur 21 jours mais seulement les 5 derniers mois

model = CovidSIRD()
print(model.quantity_names)

cols = ['safe', 'infected', 'recovered', 'deaths']
data = df[cols].values.astype(numpy.float32)
print(data[:5])

X = data[:-1]
y = data[1:] - data[:-1]
dates = df.index[:-1]

Nlast = 150
X = X[-Nlast:]
y = y[-Nlast:]
dates = dates[-Nlast:]

Out:

['S', 'I', 'R', 'D']
[[6.7e+07 0.0e+00 0.0e+00 0.0e+00]
 [6.7e+07 1.0e+00 0.0e+00 0.0e+00]
 [6.7e+07 1.0e+00 0.0e+00 0.0e+00]
 [6.7e+07 2.0e+00 0.0e+00 0.0e+00]
 [6.7e+07 2.0e+00 0.0e+00 0.0e+00]]

Estimation.

# 3 semaines car les séries sont cycliques
dfcoef, model = rolling_estimation(
    X, y, delay=21, dates=dates, verbose=1)
dfcoef.head(n=10)

Out:

k=7 iter=399 loss=56398110.476 l1=0.000158 coef=[0.03920417 0.0696458  0.00100913] R0=0.5548680995546835 lr=1e-06 cn=0.0
k=14 iter=498 loss=40530870.857 l1=0.000126 coef=[0.0320585  0.07408345 0.00147161] R0=0.42430648372760676 lr=1e-06 cn=0.0
k=21 iter=157 loss=25572397.714 l1=9.22e-05 coef=[0.0311814  0.08047936 0.00137101] R0=0.38095613047638666 lr=1e-06 cn=0.0
k=28 iter=14 loss=20747498.667 l1=7.98e-05 coef=[0.04044467 0.08254653 0.00094417] R0=0.48442123346647314 lr=1e-06 cn=0.0
k=35 iter=500 loss=22053446.095 l1=9.18e-05 coef=[0.09564698 0.05333061 0.00088093] R0=1.7643288852648908 lr=0.0001 cn=0.0
k=42 iter=85 loss=34069372.952 l1=0.000114 coef=[0.14988806 0.02136639 0.00065442] R0=6.806654065153434 lr=1e-06 cn=0.0
k=49 iter=500 loss=77372166.095 l1=0.000163 coef=[0.11164904 0.0152256  0.00033533] R0=7.174957454772039 lr=1e-06 cn=0.0
k=56 iter=415 loss=160538063.238 l1=0.000248 coef=[0.08420692 0.01903601 0.00040829] R0=4.330675002276954 lr=1e-06 cn=0.0
k=63 iter=500 loss=173988790.857 l1=0.000273 coef=[0.06777416 0.02994063 0.00034069] R0=2.238150854564704 lr=1e-06 cn=0.0
k=70 iter=500 loss=146195285.333 l1=0.000242 coef=[0.05723242 0.03869752 0.00013423] R0=1.4738563414420538 lr=1e-06 cn=0.0
k=77 iter=12 loss=117952170.667 l1=0.000198 coef=[0.05112561 0.0460496  0.00013292] R0=1.1070336151728242 lr=1e-06 cn=0.0
k=84 iter=500 loss=155183847.619 l1=0.000237 coef=[0.04506687 0.05120523 0.00028389] R0=0.8752699303197435 lr=1e-06 cn=0.0
k=91 iter=500 loss=172887734.857 l1=0.000256 coef=[0.0392007  0.05543239 0.0004354 ] R0=0.7016691998473265 lr=1e-06 cn=0.0
k=98 iter=15 loss=176395958.857 l1=0.000246 coef=[0.03408343 0.06134799 0.00020714] R0=0.5537057180992639 lr=1e-06 cn=0.0
k=102 iter=500 loss=181141430.857 l1=0.000234 coef=[0.0330471  0.06462234 0.000222  ] R0=0.5096374060285117 lr=1e-06 cn=0.0
k=104 iter=500 loss=181491833.905 l1=0.000237 coef=[0.0323291 0.0652629 0.0005628] R0=0.49113181701118747 lr=1e-06 cn=0.0
k=106 iter=500 loss=181241600.000 l1=0.000235 coef=[0.03237431 0.06558    0.00035822] R0=0.4909794071269763 lr=1e-06 cn=0.0
k=108 iter=500 loss=161229982.476 l1=0.000212 coef=[0.03028982 0.07027102 0.0003705 ] R0=0.42878206126665436 lr=1e-06 cn=0.0
k=110 iter=500 loss=156709412.571 l1=0.000208 coef=[0.03143258 0.06852046 0.00063121] R0=0.4545455522426823 lr=0.01 cn=0.0
k=112 iter=500 loss=156380818.286 l1=0.000205 coef=[0.03209929 0.06860575 0.00043261] R0=0.4649486649598985 lr=1e-06 cn=0.0
k=114 iter=500 loss=148415622.095 l1=0.000195 coef=[0.03153853 0.07014685 0.00074108] R0=0.4449069576841776 lr=1e-06 cn=0.0
k=116 iter=500 loss=142359222.857 l1=0.000185 coef=[0.03238052 0.06642443 0.00013824] R0=0.48646657652748526 lr=1e-06 cn=0.0
k=118 iter=381 loss=118779111.619 l1=0.000171 coef=[0.02603385 0.06727575 0.00126422] R0=0.37983454506885445 lr=1e-06 cn=0.0
k=120 iter=500 loss=81505414.095 l1=0.000139 coef=[0.03890397 0.0679262  0.0012844 ] R0=0.5621099574698663 lr=1e-06 cn=0.0
k=122 iter=199 loss=59038470.095 l1=0.000121 coef=[0.02779097 0.06841849 0.00068363] R0=0.40217252719781 lr=1e-06 cn=0.0
k=123 iter=500 loss=29386529.524 l1=9.45e-05 coef=[0.03711189 0.06880418 0.00014412] R0=0.5382567527331767 lr=0.0001 cn=0.0
k=124 iter=500 loss=32280179.810 l1=0.000101 coef=[0.04079234 0.06832345 0.00040438] R0=0.5935345028422835 lr=0.0001 cn=0.0
k=125 iter=280 loss=32534293.333 l1=0.000103 coef=[0.04391042 0.06692508 0.00122665] R0=0.6443039607557919 lr=1e-06 cn=0.0
k=126 iter=22 loss=31850736.762 l1=0.000101 coef=[0.04503988 0.06646686 0.00111531] R0=0.6664461437033824 lr=1e-06 cn=0.0
k=127 iter=17 loss=31679905.524 l1=9.92e-05 coef=[0.04639428 0.06613263 0.00066511] R0=0.6945486906176855 lr=1e-06 cn=0.0
k=128 iter=108 loss=31843297.524 l1=9.81e-05 coef=[0.04303063 0.06438256 0.00030866] R0=0.6651695324883071 lr=1e-06 cn=0.0
k=129 iter=13 loss=30559881.143 l1=9.42e-05 coef=[0.0445909  0.06266979 0.00083324] R0=0.7021853388957761 lr=1e-06 cn=0.0
k loss loss_l1 it R0 lr correctness beta mu nu
date
2021-06-18 7 5.639811e+07 0.000158 399 0.554868 0.000001 0.0 0.039204 0.069646 0.001009
2021-06-25 14 4.053087e+07 0.000126 498 0.424306 0.000001 0.0 0.032059 0.074083 0.001472
2021-07-02 21 2.557240e+07 0.000092 157 0.380956 0.000001 0.0 0.031181 0.080479 0.001371
2021-07-09 28 2.074750e+07 0.000080 14 0.484421 0.000001 0.0 0.040445 0.082547 0.000944
2021-07-16 35 2.205345e+07 0.000092 500 1.764329 0.000100 0.0 0.095647 0.053331 0.000881
2021-07-23 42 3.406937e+07 0.000114 85 6.806654 0.000001 0.0 0.149888 0.021366 0.000654
2021-07-30 49 7.737217e+07 0.000163 500 7.174957 0.000001 0.0 0.111649 0.015226 0.000335
2021-08-06 56 1.605381e+08 0.000248 415 4.330675 0.000001 0.0 0.084207 0.019036 0.000408
2021-08-13 63 1.739888e+08 0.000273 500 2.238151 0.000001 0.0 0.067774 0.029941 0.000341
2021-08-20 70 1.461953e+08 0.000242 500 1.473856 0.000001 0.0 0.057232 0.038698 0.000134


Statistiques.

k loss loss_l1 it R0 lr correctness beta mu nu
count 32.00000 3.200000e+01 32.000000 32.000000 32.000000 32.000000 32.0 32.000000 32.000000 32.000000
mean 89.03125 9.900980e+07 0.000167 347.343750 1.202838 0.000323 0.0 0.047745 0.059536 0.000625
std 38.38219 6.307546e+07 0.000063 202.954883 1.699565 0.001766 0.0 0.027076 0.017084 0.000405
min 7.00000 2.074750e+07 0.000080 12.000000 0.379835 0.000001 0.0 0.026034 0.015226 0.000133
25% 61.25000 3.217282e+07 0.000101 144.750000 0.479553 0.000001 0.0 0.032272 0.054907 0.000329
50% 105.00000 9.972879e+07 0.000167 500.000000 0.558489 0.000001 0.0 0.039202 0.066279 0.000499
75% 120.50000 1.576666e+08 0.000234 500.000000 0.745456 0.000001 0.0 0.045399 0.068542 0.000897
max 129.00000 1.814918e+08 0.000273 500.000000 7.174957 0.010000 0.0 0.149888 0.082547 0.001472


Fin de la période pour la série originale.

df.tail(n=10)
deaths confirmed recovered infected safe
2021-10-10 114790.005737 6.882241e+06 6.673713e+06 90838.0 6.012066e+07
2021-10-11 114824.090924 6.886015e+06 6.678734e+06 91923.0 6.011452e+07
2021-10-12 114847.880993 6.891299e+06 6.684681e+06 91134.0 6.010934e+07
2021-10-13 114871.671062 6.895306e+06 6.690457e+06 84777.0 6.010989e+07
2021-10-14 114897.965349 6.899285e+06 6.695704e+06 88196.0 6.010120e+07
2021-10-15 114931.076674 6.904552e+06 6.700998e+06 88125.0 6.009595e+07
2021-10-16 114945.684611 6.909010e+06 6.705737e+06 87793.0 6.009152e+07
2021-10-17 114967.888676 6.912448e+06 6.710001e+06 86874.0 6.008816e+07
2021-10-18 114987.365925 6.915821e+06 6.713874e+06 87314.0 6.008382e+07
2021-10-19 115001.000000 6.920457e+06 6.719844e+06 85825.0 6.007933e+07


Fin de la période pour l’estimation.

k loss loss_l1 it R0 lr correctness beta mu nu
date
2021-10-07 118 1.187791e+08 0.000171 381 0.379835 0.000001 0.0 0.026034 0.067276 0.001264
2021-10-09 120 8.150541e+07 0.000139 500 0.562110 0.000001 0.0 0.038904 0.067926 0.001284
2021-10-11 122 5.903847e+07 0.000121 199 0.402173 0.000001 0.0 0.027791 0.068418 0.000684
2021-10-12 123 2.938653e+07 0.000095 500 0.538257 0.000100 0.0 0.037112 0.068804 0.000144
2021-10-13 124 3.228018e+07 0.000101 500 0.593535 0.000100 0.0 0.040792 0.068323 0.000404
2021-10-14 125 3.253429e+07 0.000103 280 0.644304 0.000001 0.0 0.043910 0.066925 0.001227
2021-10-15 126 3.185074e+07 0.000101 22 0.666446 0.000001 0.0 0.045040 0.066467 0.001115
2021-10-16 127 3.167991e+07 0.000099 17 0.694549 0.000001 0.0 0.046394 0.066133 0.000665
2021-10-17 128 3.184330e+07 0.000098 108 0.665170 0.000001 0.0 0.043031 0.064383 0.000309
2021-10-18 129 3.055988e+07 0.000094 13 0.702185 0.000001 0.0 0.044591 0.062670 0.000833


Graphe.

dfcoef['R0=1'] = 1

fig, ax = plt.subplots(2, 3, figsize=(14, 6))
with warnings.catch_warnings():
    warnings.simplefilter("ignore", MatplotlibDeprecationWarning)
    dfcoef[["mu", "nu"]].plot(ax=ax[0, 0], logy=True)
    dfcoef[["beta"]].plot(ax=ax[0, 1], logy=True)
    dfcoef[["loss_l1"]].plot(ax=ax[1, 0], logy=True)
    dfcoef[["R0", "R0=1"]].plot(ax=ax[0, 2])
    df[-Nlast:].drop('safe', axis=1).plot(ax=ax[1, 1], logy=True)
    for i in range(ax.shape[1]):
        for tick in ax[1, i].get_xticklabels():
            tick.set_rotation(30)
    ax[0, 2].set_ylim(0, 5)
    fig.suptitle('Estimation de R0 tout au long de la période\n'
                 'Estimation sur 3 semaines', fontsize=12)
plt.show()
Estimation de R0 tout au long de la période Estimation sur 3 semaines

Graphe sur les dernières valeurs.

dfcoeflast = dfcoef.iloc[-30:, :]
dflast = df.iloc[-30:, :]

fig, ax = plt.subplots(2, 3, figsize=(14, 6))
with warnings.catch_warnings():
    warnings.simplefilter("ignore", MatplotlibDeprecationWarning)
    dfcoeflast[["mu", "nu"]].plot(ax=ax[0, 0], logy=True)
    dfcoeflast[["beta"]].plot(ax=ax[0, 1], logy=True)
    dfcoeflast[["loss_l1"]].plot(ax=ax[1, 0], logy=True)
    dfcoeflast[["R0", "R0=1"]].plot(ax=ax[0, 2])
    dflast.drop('safe', axis=1).plot(ax=ax[1, 1], logy=True)
    for i in range(ax.shape[1]):
        for tick in ax[1, i].get_xticklabels():
            tick.set_rotation(30)
    ax[0, 2].set_ylim(0, 5)
    fig.suptitle('Estimation de R0 sur la fin de la période', fontsize=12)
plt.show()
Estimation de R0 sur la fin de la période

Prédictions

Ce ne sont pas seulement des prédictions mais des prédictions en boucle à partir d’un état initial. On utilise la méthode simulate.

predictions = model.simulate(X[-30:], 21)
dfp = pandas.DataFrame(
    predictions[9], columns='Spred Ipred Rpred Dpred'.split()).set_index(
        pandas.to_datetime(dates[-21:]))
dfp.tail()
Spred Ipred Rpred Dpred
2021-10-14 60097792.0 89092.671875 6697275.0 115840.109375
2021-10-15 60094228.0 86998.476562 6702858.5 115914.343750
2021-10-16 60090748.0 84953.304688 6708311.0 115986.835938
2021-10-17 60087352.0 82956.007812 6713635.0 116057.617188
2021-10-18 60084032.0 81005.484375 6718833.5 116126.742188


On représente les prédictions. Ipred est la valeur prédite, Itrue est la valeur connue. Idem pour Dpred et Dtrue.

fig, ax = plt.subplots(2, 3, figsize=(14, 6))

dfp = pandas.DataFrame(
    predictions[9], columns='S Ipred R Dpred'.split()).set_index(
        pandas.to_datetime(dates[-21:]))
dfp[["Ipred"]].plot(ax=ax[0, 0])
dfp[["Dpred"]].plot(ax=ax[1, 0])
dfp = pandas.DataFrame(
    X[-21:], columns='S Itrue R Dtrue'.split()).set_index(
        pandas.to_datetime(dates[-21:]))
dfp[["Itrue"]].plot(ax=ax[0, 0])
dfp[["Dtrue"]].plot(ax=ax[1, 0])
ax[0, 0].set_title("Prediction à partir de %s" % dates[-21])

dt = pandas.to_datetime(dates[-7])
dates2 = pandas.to_datetime([dt + timedelta(i) for i in range(21)])
dfp = pandas.DataFrame(
    predictions[-7], columns='S Ipred R Dpred'.split()).set_index(dates2)
dfp[["Ipred"]].plot(ax=ax[0, 1])
dfp[["Dpred"]].plot(ax=ax[1, 1])
dfp = pandas.DataFrame(
    X[-7:], columns='S Itrue R Dtrue'.split()).set_index(
        pandas.to_datetime(dates[-7:]))
dfp[["Itrue"]].plot(ax=ax[0, 1])
dfp[["Dtrue"]].plot(ax=ax[1, 1])
ax[0, 1].set_title("Prediction à partir de %s" % dates[-7])

dt = pandas.to_datetime(dates[-1])
dates2 = pandas.to_datetime([dt + timedelta(i) for i in range(21)])
dfp = pandas.DataFrame(
    predictions[-1], columns='S Ipred R Dpred'.split()).set_index(dates2)
dfp[["Ipred"]].plot(ax=ax[0, 2])
dfp[["Dpred"]].plot(ax=ax[1, 2])
ax[0, 1].set_title("Prediction à partir de %s" % dates[-1])
Prediction à partir de 2021-09-28 00:00:00, Prediction à partir de 2021-10-18 00:00:00

Ces prédictions varient beaucoup car une petite imprécision sur l’estimation a beaucoup d’impact à moyen terme.

predictions = model.simulate(X[-1:], 98)
fig, ax = plt.subplots(1, 2, figsize=(14, 6))
dt = pandas.to_datetime(dates[-1])
dates2 = pandas.to_datetime([dt + timedelta(i) for i in range(98)])
dfp = pandas.DataFrame(
    predictions[-1], columns='S Ipred R Dpred'.split()).set_index(dates2)
dfp[["Ipred"]].plot(ax=ax[0])
dfp[["Dpred"]].plot(ax=ax[1])
ax[1].set_title("Prediction à partir de %s" % dates[-1])
Prediction à partir de 2021-10-18 00:00:00

Taille fenêtre glissante sur 7 jours

On fait varier le paramètre delay pour voir comment le modèle réagit. Sur 7 jours d’abord.

dfcoef, model = rolling_estimation(X, y, delay=7, verbose=1, dates=dates)
dfcoef.index = to_datetime(dfcoef.index)
dfcoef.tail()

Out:

k=7 iter=297 loss=82118838.857 l1=0.000187 coef=[0.04552812 0.06615735 0.00057051] R0=0.6822955069546848 lr=1e-06 cn=0.0
k=14 iter=116 loss=42395332.571 l1=0.000131 coef=[0.03388128 0.07070502 0.00015651] R0=0.4781335764309917 lr=1e-06 cn=0.0
k=21 iter=45 loss=32086235.429 l1=0.000125 coef=[0.02840958 0.07826192 0.00121316] R0=0.35746521818423305 lr=1e-06 cn=0.0
k=28 iter=21 loss=39595995.429 l1=0.000105 coef=[0.02445439 0.08917194 0.001269  ] R0=0.2703907218372358 lr=1e-06 cn=0.0
k=35 iter=500 loss=2108767.286 l1=3.11e-05 coef=[0.04864873 0.08875469 0.00070017] R0=0.5438355450986722 lr=0.01 cn=0.0
k=42 iter=500 loss=2493526.286 l1=3.54e-05 coef=[0.09014343 0.05388682 0.00041456] R0=1.6600578485934179 lr=0.01 cn=0.0
k=49 iter=19 loss=25884363.429 l1=9.82e-05 coef=[1.30458714e-01 2.81901475e-02 1.01430478e-04] R0=4.611220827545018 lr=1e-06 cn=0.0
k=56 iter=227 loss=45647881.143 l1=0.000115 coef=[0.16181802 0.01660641 0.00073281] R0=9.332487615582112 lr=1e-06 cn=0.0
k=63 iter=14 loss=81213622.857 l1=0.000147 coef=[0.09764927 0.0141155  0.00037113] R0=6.740644290450995 lr=1e-06 cn=0.0
k=70 iter=500 loss=121330048.000 l1=0.000172 coef=[0.06866423 0.02076102 0.00025447] R0=3.267315820705774 lr=1e-06 cn=0.0
k=77 iter=487 loss=36870932.571 l1=0.000132 coef=[0.05665065 0.04053999 0.00017504] R0=1.3913941113475443 lr=1e-06 cn=0.0
k=84 iter=107 loss=67424498.286 l1=0.000155 coef=[0.04951806 0.0474443  0.00021477] R0=1.0390061641938293 lr=1e-06 cn=0.0
k=91 iter=500 loss=197023542.857 l1=0.000248 coef=[0.0472938  0.04999891 0.00034828] R0=0.9393533789232777 lr=1e-06 cn=0.0
k=98 iter=500 loss=138938715.429 l1=0.000228 coef=[0.03560012 0.05739187 0.00027188] R0=0.6173742667347124 lr=1e-06 cn=0.0
k=105 iter=4 loss=122461787.429 l1=0.000212 coef=[0.03341086 0.06179188 0.00068002] R0=0.5348141783742126 lr=1e-06 cn=0.0
k=112 iter=500 loss=248892306.286 l1=0.000302 coef=[0.02797476 0.06681352 0.00015066] R0=0.4177571278650538 lr=1e-06 cn=0.0
k=116 iter=500 loss=354434742.857 l1=0.000361 coef=[0.03339813 0.06484452 0.00202794] R0=0.4994302469003445 lr=1e-06 cn=0.0
k=118 iter=133 loss=263564836.571 l1=0.000309 coef=[0.00644488 0.06314045 0.0005644 ] R0=0.1011677590242504 lr=1e-06 cn=0.0
k=120 iter=500 loss=168491026.286 l1=0.000208 coef=[0.03811493 0.06971048 0.002793  ] R0=0.5256980047897521 lr=1e-06 cn=0.0
k=122 iter=76 loss=80542427.429 l1=0.000161 coef=[0.01124734 0.07043097 0.0002878 ] R0=0.15904312543311586 lr=1e-06 cn=0.0
k=124 iter=500 loss=52674171.429 l1=0.000128 coef=[0.03686681 0.07081919 0.00080076] R0=0.5147561839982272 lr=0.0001 cn=0.0
k=126 iter=29 loss=51142354.286 l1=0.000121 coef=[0.04026344 0.06902158 0.00133247] R0=0.5722974532885126 lr=1e-06 cn=0.0
k=128 iter=41 loss=50667286.857 l1=0.000118 coef=[0.03994196 0.06769501 0.00072618] R0=0.583766021421008 lr=1e-06 cn=0.0
k=130 iter=185 loss=37946429.714 l1=0.000103 coef=[0.03077926 0.0665201  0.00096663] R0=0.4560786451230146 lr=1e-06 cn=0.0
k=132 iter=500 loss=23728089.143 l1=8.77e-05 coef=[0.04136966 0.06558755 0.00092258] R0=0.6220053911140937 lr=0.0001 cn=0.0
k=134 iter=65 loss=23255961.143 l1=8.34e-05 coef=[0.04325968 0.06473037 0.00130575] R0=0.6550911544862528 lr=1e-06 cn=0.0
k=136 iter=398 loss=22624443.429 l1=8.12e-05 coef=[0.05214854 0.05976173 0.00073605] R0=0.8619909588876742 lr=1e-06 cn=0.0
k=137 iter=406 loss=16495793.143 l1=7.93e-05 coef=[0.03146016 0.06063334 0.00043533] R0=0.5151603347359637 lr=0.0001 cn=0.0
k=138 iter=500 loss=15677443.429 l1=7.01e-05 coef=[0.05225977 0.06187891 0.00067477] R0=0.8354387245537107 lr=0.0001 cn=0.0
k=139 iter=39 loss=15539889.143 l1=6.92e-05 coef=[0.05554502 0.06204189 0.00046615] R0=0.8886059072823536 lr=1e-06 cn=0.0
k=140 iter=30 loss=15031870.857 l1=6.43e-05 coef=[0.05651864 0.0592276  0.00081397] R0=0.9413250717837466 lr=1e-06 cn=0.0
k=141 iter=17 loss=14933709.714 l1=6.31e-05 coef=[0.05903956 0.05809908 0.00112311] R0=0.9969161544678117 lr=1e-06 cn=0.0
k=142 iter=464 loss=14473688.000 l1=6.04e-05 coef=[0.05539412 0.0570612  0.00033547] R0=0.9651103427565784 lr=0.0001 cn=0.0
k=143 iter=96 loss=14568329.143 l1=6.36e-05 coef=[0.0530912  0.05735227 0.00065   ] R0=0.9153295201981863 lr=1e-06 cn=0.0
k loss loss_l1 it R0 lr correctness beta mu nu
date
2021-10-14 139 1.553989e+07 0.000069 39 0.888606 0.000001 0.0 0.055545 0.062042 0.000466
2021-10-15 140 1.503187e+07 0.000064 30 0.941325 0.000001 0.0 0.056519 0.059228 0.000814
2021-10-16 141 1.493371e+07 0.000063 17 0.996916 0.000001 0.0 0.059040 0.058099 0.001123
2021-10-17 142 1.447369e+07 0.000060 464 0.965110 0.000100 0.0 0.055394 0.057061 0.000335
2021-10-18 143 1.456833e+07 0.000064 96 0.915330 0.000001 0.0 0.053091 0.057352 0.000650


Graphe.

dfcoef['R0=1'] = 1


fig, ax = plt.subplots(2, 3, figsize=(14, 6))
with warnings.catch_warnings():
    warnings.simplefilter("ignore", MatplotlibDeprecationWarning)
    dfcoef[["mu", "nu"]].plot(ax=ax[0, 0], logy=True)
    dfcoef[["beta"]].plot(ax=ax[0, 1], logy=True)
    dfcoef[["loss_l1"]].plot(ax=ax[1, 0], logy=True)
    dfcoef[["R0", "R0=1"]].plot(ax=ax[0, 2])
    df[-Nlast:].drop('safe', axis=1).plot(ax=ax[1, 1], logy=True)
    for i in range(ax.shape[1]):
        for tick in ax[1, i].get_xticklabels():
            tick.set_rotation(30)
    ax[0, 2].set_ylim(0, 5)
    fig.suptitle('Estimation de R0 tout au long de la période\n'
                 'Estimation sur 1 semaine', fontsize=12)
plt.show()
Estimation de R0 tout au long de la période Estimation sur 1 semaine

Total running time of the script: ( 52 minutes 59.682 seconds)

Gallery generated by Sphinx-Gallery