Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIR-F model: optimize weight of variables in parameter estimation error function #196

Closed
lisphilar opened this issue Aug 19, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@lisphilar
Copy link
Owner

lisphilar commented Aug 19, 2020

Summary

In parameter estimation of SIR-F model, weight of variables in error function is set to (S, I, R, F)=(1, 10, 10, 2). This means score of error function is (S_diff * 1 + I_diff * 10 + R_diff * 10 + F_diff * 2) / 23.
However, (S, I, R, F)=(1, 1, 1, 1) seems better for performance. Because allowance of estimation was restricted in #165, this change does not impact on the quality of estimation.

Related classes

  • covsirphy.SIRF
  • covsirphy.Estimator

Codes and outputs:

import covsirphy as cs
# Dataset preparation
data_loader = cs.DataLoader("input")
jhu_data = data_loader.jhu()
population_data = data_loader.population()
snl = cs.Scenario(jhu_data, population_data, "Italy")
snl.trend()
snl.estimate()

In my local environment, the stdout is as follows.

<SIR-F model: parameter estimation>
Running optimization with 8 CPUs...
        4th phase (22Apr2020 - 01May2020): finished  354 trials in 0 min 25 sec
        5th phase (02May2020 - 09May2020): finished  370 trials in 0 min 30 sec
        7th phase (20May2020 - 05Jun2020): finished  744 trials in 1 min  0 sec
        1st phase (24Mar2020 - 31Mar2020): finished  766 trials in 1 min  0 sec
        3rd phase (13Apr2020 - 21Apr2020): finished  739 trials in 1 min  0 sec
        6th phase (10May2020 - 19May2020): finished  738 trials in 1 min  0 sec
        8th phase (06Jun2020 - 10Jul2020): finished  703 trials in 1 min  1 sec
        2nd phase (01Apr2020 - 12Apr2020): finished  738 trials in 1 min  1 sec
        9th phase (11Jul2020 - 17Aug2020): finished 1073 trials in 1 min  0 sec
Completed optimization. Total: 1 min 26 sec

Environment

  • CovsirPhy version: 2.7.0
  • Python version; 3.8
  • Installation: pipenv
  • OS: WSL
@lisphilar lisphilar added the bug Something isn't working label Aug 19, 2020
@lisphilar lisphilar added this to the Release CovsirPhy v2.7.1 milestone Aug 19, 2020
@lisphilar
Copy link
Owner Author

With the change of weights, stdout was changed to

<SIR-F model: parameter estimation>
Running optimization with 8 CPUs...
        6th phase (10May2020 - 19May2020): finished  201 trials in 0 min 20 sec
        7th phase (20May2020 - 05Jun2020): finished  194 trials in 0 min 20 sec
        1st phase (24Mar2020 - 31Mar2020): finished  578 trials in 0 min 45 sec
        4th phase (22Apr2020 - 01May2020): finished  620 trials in 0 min 50 sec
        3rd phase (13Apr2020 - 21Apr2020): finished  774 trials in 1 min  0 sec
        8th phase (06Jun2020 - 10Jul2020): finished  729 trials in 1 min  0 sec
        2nd phase (01Apr2020 - 12Apr2020): finished  769 trials in 1 min  0 sec
        5th phase (02May2020 - 09May2020): finished  776 trials in 1 min  0 sec
        9th phase (11Jul2020 - 17Aug2020): finished 1104 trials in 1 min  0 sec
Completed optimization. Total: 1 min 22 sec

@lisphilar
Copy link
Owner Author

With refactoring (creating Estimator._score(variable,...) and avoid repeating calculation of tau-free dataframe), stdout was changed to

<SIR-F model: parameter estimation>
Running optimization with 8 CPUs...
        6th phase (10May2020 - 19May2020): finished  225 trials in 0 min 15 sec
        7th phase (20May2020 - 05Jun2020): finished  228 trials in 0 min 15 sec
        4th phase (22Apr2020 - 01May2020): finished  627 trials in 0 min 40 sec
        1st phase (24Mar2020 - 31Mar2020): finished  607 trials in 0 min 40 sec
        5th phase (02May2020 - 09May2020): finished  884 trials in 0 min 55 sec
        3rd phase (13Apr2020 - 21Apr2020): finished  960 trials in 1 min  0 sec
        2nd phase (01Apr2020 - 12Apr2020): finished  969 trials in 1 min  0 sec
        8th phase (06Jun2020 - 10Jul2020): finished  886 trials in 1 min  0 sec
        9th phase (11Jul2020 - 17Aug2020): finished 1187 trials in 1 min  0 sec
Completed optimization. Total: 1 min 16 sec

@lisphilar
Copy link
Owner Author

In the previous versions, difference of actual and predicted values of recent records were weightened. However, this is un-necessary because the phases are shortened with update of S-R trend analysis.

This results in

<SIR-F model: parameter estimation>
Running optimization with 8 CPUs...
        6th phase (10May2020 - 19May2020): finished  154 trials in 0 min 10 sec
        1st phase (24Mar2020 - 31Mar2020): finished  227 trials in 0 min 15 sec
        3rd phase (13Apr2020 - 21Apr2020): finished  312 trials in 0 min 20 sec
        2nd phase (01Apr2020 - 12Apr2020): finished  385 trials in 0 min 25 sec
        7th phase (20May2020 - 05Jun2020): finished  389 trials in 0 min 25 sec
        8th phase (06Jun2020 - 10Jul2020): finished  939 trials in 0 min 55 sec
        5th phase (02May2020 - 09May2020): finished 1107 trials in 1 min  0 sec
        4th phase (22Apr2020 - 01May2020): finished 1107 trials in 1 min  0 sec
        9th phase (11Jul2020 - 17Aug2020): finished 1231 trials in 1 min  0 sec
Completed optimization. Total: 1 min 11 sec

This was referenced Aug 19, 2020
@lisphilar
Copy link
Owner Author

Will be fixed in version 2.7.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant