Skip to content
Snippets Groups Projects
abc.html 12.7 KiB
Newer Older
Documenter.jl's avatar
Documenter.jl committed
<!DOCTYPE html>
Documenter.jl's avatar
Documenter.jl committed
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Approximate Bayesian Computation · MarkovProcesses.jl</title><script data-outdated-warner src="../assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.045/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.24/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="../index.html"><img src="../assets/logo.png" alt="MarkovProcesses.jl logo"/></a><div class="docs-package-name"><span class="docs-autofit"><a href="../index.html">MarkovProcesses.jl</a></span></div><form class="docs-search" action="../search.html"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="../index.html">Home</a></li><li><a class="tocitem" href="../starting.html">Getting Started</a></li><li><a class="tocitem" href="../create_model.html">Create a model</a></li><li><span class="tocitem">API</span><ul><li><a class="tocitem" href="model.html">Model</a></li><li><a class="tocitem" href="trajectory.html">Trajectory</a></li><li class="is-active"><a class="tocitem" href="abc.html">Approximate Bayesian Computation</a></li><li><a class="tocitem" href="plots.html">Plots</a></li></ul></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">API</a></li><li class="is-active"><a href="abc.html">Approximate Bayesian Computation</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href="abc.html">Approximate Bayesian Computation</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com//blob/master/docs/src/api/abc.md" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="Approximate-Bayesian-Computation-related-methods"><a class="docs-heading-anchor" href="#Approximate-Bayesian-Computation-related-methods">Approximate Bayesian Computation related methods</a><a id="Approximate-Bayesian-Computation-related-methods-1"></a><a class="docs-heading-anchor-permalink" href="#Approximate-Bayesian-Computation-related-methods" title="Permalink"></a></h1><article class="docstring"><header><a class="docstring-binding" id="MarkovProcesses.abc_smc-Tuple{ParametricModel, AbstractVector, Function}" href="#MarkovProcesses.abc_smc-Tuple{ParametricModel, AbstractVector, Function}"><code>MarkovProcesses.abc_smc</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">abc_smc(pm::ParametricModel, l_obs, func_dist; nbr_particles, alpha, kernel_type, NT
        duration_time, bound_sim, sym_var_aut, verbose)</code></pre><p>Run the ABC-SMC algorithm with the pm parametric model. </p><p><code>func_dist(l_sim, l_obs)</code> is the distance function between simulations and observation,  it corresponds to <span>$\rho(\eta(y_sim), \eta(y_exp))\$</span>. <code>l_obs::Vector{&lt;:T2}</code> is a collection of observations. <code>dist</code> must have a signature of the form <code>func_dist(l_sim::Vector{T1}, l_obs::Vector{T2})</code>.</p><p>If <code>pm</code> is defined on a <code>ContinuousTimeModel</code>, then <code>T1</code> should verify <code>T1 &lt;: Trajectory</code>.</p><p>!!! Distance function and distributed ABC     If you use <code>abc_smc</code> with multiple workers, <code>dist</code> has to be defined      on every workers by using @everywhere.</p></div></section></article><article class="docstring"><header><a class="docstring-binding" id="MarkovProcesses.abc_model_choice_dataset-Tuple{Vector{&lt;:Union{Model, ParametricModel}}, Any, Function, Function, Int64, Int64}" href="#MarkovProcesses.abc_model_choice_dataset-Tuple{Vector{&lt;:Union{Model, ParametricModel}}, Any, Function, Function, Int64, Int64}"><code>MarkovProcesses.abc_model_choice_dataset</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">abc_model_choice_dataset(models,
Documenter.jl's avatar
Documenter.jl committed
                         summary_stats_observations,
                         summary_stats_func::Function, distance_func::Function,
Documenter.jl's avatar
Documenter.jl committed
                         k::Int, N_ref::Int; dir_results::Union{Nothing,String} = nothing)</code></pre><p>Creates a reference table for ABC model choice with discrete uniform prior distribution over the models.</p></div></section></article><article class="docstring"><header><a class="docstring-binding" id="MarkovProcesses.abc_model_choice_dataset-Tuple{Vector{&lt;:Union{Model, ParametricModel}}, Distribution{Distributions.Univariate, Distributions.Discrete}, Any, Function, Function, Int64, Int64}" href="#MarkovProcesses.abc_model_choice_dataset-Tuple{Vector{&lt;:Union{Model, ParametricModel}}, Distribution{Distributions.Univariate, Distributions.Discrete}, Any, Function, Function, Int64, Int64}"><code>MarkovProcesses.abc_model_choice_dataset</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">abc_model_choice_dataset(models, models_prior,
Documenter.jl's avatar
Documenter.jl committed
                         summary_stats_observations,
                         summary_stats_func::Function, distance_func::Function,
Documenter.jl's avatar
Documenter.jl committed
                         k::Int, N_ref::Int; dir_results::Union{Nothing,String} = nothing)</code></pre><p>Creates a reference table for ABC model choice.</p><p>The mandatory arguments are:</p><ul><li><code>models</code> is a list of objects inherited from <code>Model</code> or <code>ParametricModel</code>,</li><li><code>models_prior</code>: the prior over the models (by default: discrete uniform distribution)</li><li><code>summary_stats_observations</code> are the summary statitics of the observations,</li><li><code>summary_stats_func::Function</code>: the function that computes the summary statistics over a model simulation,</li><li><code>distance_func</code>: the distance function over the summary statistics space,</li><li><code>N_ref</code>: the number of samples in the reference table,</li><li><code>k</code>: the k nearest samples from the observations to keep in the reference table (k &lt; N_ref).</li></ul><p>The result is a <code>AbcModelChoiceDataset</code> with fields:</p><ul><li><code>summary_stats_matrix</code>: the (N<em>stats, N</em>ref) features matrix. Accessible via <code>.X</code>.</li><li><code>models_indexes</code>: the labels vector. Accessible via <code>.y</code>.</li></ul><p>If specified, <code>dir_results</code> is the directory where the summary statistics matrix and associated models are stored (CSV).</p></div></section></article><article class="docstring"><header><a class="docstring-binding" id="MarkovProcesses.posterior_proba_model-Tuple{MarkovProcesses.RandomForestABC}" href="#MarkovProcesses.posterior_proba_model-Tuple{MarkovProcesses.RandomForestABC}"><code>MarkovProcesses.posterior_proba_model</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">posterior_proba_model(rf_abc::RandomForestABC)</code></pre><p>Estimates the posterior probability of the model <span>$P(M = \widehat{M}(s_{obs}) | s_{obs})$</span> with the Random Forest ABC method.</p></div></section></article><article class="docstring"><header><a class="docstring-binding" id="MarkovProcesses.rf_abc_model_choice-Tuple{Vector{&lt;:Union{Model, ParametricModel}}, Any, Function, Int64}" href="#MarkovProcesses.rf_abc_model_choice-Tuple{Vector{&lt;:Union{Model, ParametricModel}}, Any, Function, Int64}"><code>MarkovProcesses.rf_abc_model_choice</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">rf_abc_model_choice(models, summary_stats_observations,
Documenter.jl's avatar
Documenter.jl committed
                    summary_stats_func::Function, N_ref::Int;
                    k::Int = N_ref, distance_func::Function = (x,y) -&gt; 1, 
Documenter.jl's avatar
Documenter.jl committed
                    hyperparameters_range::Dict)</code></pre><p>Run the Random Forest Approximate Bayesian Computation model choice method.</p><p>The mandatory arguments are:</p><ul><li><code>models</code> is a list of objects inherited from <code>Model</code> or <code>ParametricModel</code>,</li><li><code>summary_stats_observations</code> are the summary statitics of the observations</li><li><code>N_ref</code>: the number of samples in the reference table.</li><li><code>summary_stats_func::Function</code>: the function that computes the summary statistics over a model simulation.</li></ul><p>The optional arguments are:</p><ul><li><code>abc_trainset</code>: an already simulated dataset with `<code>abc_model_choice_dataset</code> (by default: nothing)</li><li><code>models_prior</code>: the prior over the models (by default: discrete uniform distribution)</li><li><code>k</code>: the k nearest samples from the observations to keep in the reference table (by default: k = N_ref)</li><li><code>distance_func</code>: the distance function, has to be defined if k &lt; N_ref</li><li><code>hyperparameters_range</code>: a dict with the hyperparameters range values for the cross validation fit of the    Random Forest (by default: <code>Dict(:n_estimators =&gt; [200], :min_samples_leaf =&gt; [1], :min_samples_split =&gt; [2])</code>).   See scikit-learn documentation of RandomForestClassifier for the hyperparameters name.</li></ul><p>The result is a <code>RandomForestABC</code> object with fields:</p><ul><li><code>reference_table</code> an AbcModelChoiceDataset that corresponds to the reference table of the algorithm, </li><li><code>clf</code> a random forest classifier (PyObject from scikit-learn),</li><li><code>summary_stats_observations</code> are the summary statitics of the observations</li><li><code>estim_model</code> is the underlying model of the observations inferred with the RF-ABC method.</li></ul></div></section></article></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="trajectory.html">« Trajectory</a><a class="docs-footer-nextpage" href="plots.html">Plots »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 0.27.24 on <span class="colophon-date" title="Monday 22 May 2023 14:03">Monday 22 May 2023</span>. Using Julia version 1.7.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>