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

Prefix method #329

Merged
merged 10 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pipeline/src/constructors/make_Rt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ reproduction number is 1.0, that is the following holds:

This implies that the long-term muliplicative growth of the infected community is 1.0.



# Arguments
- `pipeline::RoughEndemicPipeline`: The `RoughEndemicPipeline` object for which Rt is being constructed.
- `N_steps::Int = 10`: The number of steps to generate random values for Rt.
Expand Down
21 changes: 6 additions & 15 deletions pipeline/src/infer/generate_inference_results.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@ Generate inference results based on the given configuration of inference model o
"""
function generate_inference_results(
truthdata, inference_config, pipeline::AbstractEpiAwarePipeline;
tspan, inference_method,
prefix_name = "observables", datadir_name = "epiaware_observables")
tspan, inference_method, datadir_name = "epiaware_observables")
config = InferenceConfig(
inference_config; case_data = truthdata["y_t"], tspan, epimethod = inference_method)

# produce or load inference results
prfx = prefix_name * "_igp_" * string(inference_config["igp"]) * "_latentmodel_" *
inference_config["latent_namemodels"].first * "_truth_gi_mean_" *
string(truthdata["truth_gi_mean"]) * "_used_gi_mean_" *
string(inference_config["gi_mean"])
prfx = _inference_prefix(truthdata, inference_config, pipeline)

inference_results, inferencefile = produce_or_load(
infer, config, datadir(datadir_name); prefix = prfx)
Expand All @@ -51,15 +47,12 @@ which is deleted after the function call.
"""
function generate_inference_results(
truthdata, inference_config, pipeline::EpiAwareExamplePipeline;
tspan, inference_method, prefix_name = "testmode_observables")
tspan, inference_method)
config = InferenceConfig(inference_config; case_data = truthdata["y_t"],
tspan = tspan, epimethod = inference_method)

# produce or load inference results
prfx = prefix_name * "_igp_" * string(inference_config["igp"]) * "_latentmodel_" *
inference_config["latent_namemodels"].first * "_truth_gi_mean_" *
string(truthdata["truth_gi_mean"]) * "_used_gi_mean_" *
string(inference_config["gi_mean"])
prfx = _inference_prefix(truthdata, inference_config, pipeline)

datadir_name = mktempdir()

Expand All @@ -73,14 +66,12 @@ Method for prior predictive modelling.
"""
function generate_inference_results(
inference_config, pipeline::RtwithoutRenewalPriorPipeline;
tspan, prefix_name = "prior_observables")
tspan)
config = InferenceConfig(
inference_config; case_data = missing, tspan, epimethod = DirectSample())

# produce or load inference results
prfx = prefix_name * "_igp_" * string(inference_config["igp"]) * "_latentmodel_" *
inference_config["latent_namemodels"].first * "_truth_gi_mean_" *
string(inference_config["gi_mean"])
prfx = _inference_prefix(truthdata, inference_config, pipeline)

datadir_name = mktempdir()

Expand Down
1 change: 1 addition & 0 deletions pipeline/src/infer/infer.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include("InferenceConfig.jl")
include("inference_prefix.jl")
include("generate_inference_results.jl")
include("map_inference_results.jl")
include("define_epiprob.jl")
54 changes: 54 additions & 0 deletions pipeline/src/infer/inference_prefix.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""
This is an internal method that generates the prefix for the inference results file name.
"""
function _inference_prefix(truthdata, inference_config, pipeline::AbstractEpiAwarePipeline)
seabbs marked this conversation as resolved.
Show resolved Hide resolved
return "observables" * "_igp_" * string(inference_config["igp"]) * "_latentmodel_" *
inference_config["latent_namemodels"].first * "_truth_gi_mean_" *
string(truthdata["truth_gi_mean"]) * "_used_gi_mean_" *
string(inference_config["gi_mean"])
end

function _inference_prefix(truthdata, inference_config, pipeline::EpiAwareExamplePipeline)
return "testmode_observables" * "_igp_" * string(inference_config["igp"]) *
"_latentmodel_" *
inference_config["latent_namemodels"].first * "_truth_gi_mean_" *
string(truthdata["truth_gi_mean"]) * "_used_gi_mean_" *
string(inference_config["gi_mean"])
end

function _inference_prefix(
truthdata, inference_config, pipeline::RtwithoutRenewalPriorPipeline)
return "prior_observables" * "_igp_" * string(inference_config["igp"]) *
"_latentmodel_" *
inference_config["latent_namemodels"].first * "_truth_gi_mean_" *
string(inference_config["gi_mean"])
end

function _inference_prefix(truthdata, inference_config, pipeline::SmoothOutbreakPipeline)
return "smooth_outbreak" * "_igp_" * string(inference_config["igp"]) * "_latentmodel_" *
inference_config["latent_namemodels"].first * "_truth_gi_mean_" *
string(truthdata["truth_gi_mean"]) * "_used_gi_mean_" *
string(inference_config["gi_mean"])
end

function _inference_prefix(truthdata, inference_config, pipeline::MeasuresOutbreakPipeline)
return "measures_outbreak" * "_igp_" * string(inference_config["igp"]) *
"_latentmodel_" *
inference_config["latent_namemodels"].first * "_truth_gi_mean_" *
string(truthdata["truth_gi_mean"]) * "_used_gi_mean_" *
string(inference_config["gi_mean"])
end

function _inference_prefix(truthdata, inference_config, pipeline::SmoothEndemicPipeline)
return "smooth_endemic" * "_igp_" * string(inference_config["igp"]) * "_latentmodel_" *
inference_config["latent_namemodels"].first * "_truth_gi_mean_" *
string(truthdata["truth_gi_mean"]) * "_used_gi_mean_" *
string(inference_config["gi_mean"])
end

function _inference_prefix(truthdata, inference_config, pipeline::RoughEndemicPipeline)
return "rough_endemic" * "_igp_" * string(inference_config["igp"]) * "_latentmodel_" *
inference_config["latent_namemodels"].first * "_truth_gi_mean_" *
string(truthdata["truth_gi_mean"]) * "_used_gi_mean_" *
string(inference_config["gi_mean"])
end
4 changes: 3 additions & 1 deletion pipeline/src/simulate/generate_truthdata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ the `simulate` function to generate the truth data. This is the default method.
"""
function generate_truthdata(
truth_data_config, pipeline::AbstractEpiAwarePipeline; plot = true,
datadir_str = "truth_data", prefix = "truth_data")
datadir_str = "truth_data")
default_params = make_default_params(pipeline)
config = TruthSimulationConfig(
truth_process = default_params["Rt"], gi_mean = truth_data_config["gi_mean"],
gi_std = truth_data_config["gi_std"], logit_daily_ascertainment = default_params["logit_daily_ascertainment"],
cluster_factor = default_params["cluster_factor"], I0 = default_params["I0"])

prefix = _simulate_prefix(pipeline)

truthdata, truthfile = produce_or_load(
simulate, config, datadir(datadir_str); prefix = prefix)
if plot
Expand Down
1 change: 1 addition & 0 deletions pipeline/src/simulate/simulate.jl
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include("TruthSimulationConfig.jl")
include("simulate_prefix.jl")
include("generate_truthdata.jl")
12 changes: 12 additions & 0 deletions pipeline/src/simulate/simulate_prefix.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
Internal method for setting the prefix for the truth data file name.
"""
_simulate_prefix(pipeline::AbstractEpiAwarePipeline) = "truth_data"
seabbs marked this conversation as resolved.
Show resolved Hide resolved

_simulate_prefix(pipeline::SmoothOutbreakPipeline) = "truth_data_smooth_outbreak"

_simulate_prefix(pipeline::MeasuresOutbreakPipeline) = "truth_data_measures_outbreak"

_simulate_prefix(pipeline::SmoothEndemicPipeline) = "truth_data_smooth_endemic"

_simulate_prefix(pipeline::RoughEndemicPipeline) = "truth_data_rough_endemic"
Loading