autofit.Emcee#
- class Emcee[source]#
Bases:
AbstractMCMCAn Emcee non-linear search.
For a full description of Emcee, checkout its Github and readthedocs webpages:
https://emcee.readthedocs.io/en/stable/
If you use Emcee as part of a published work, please cite the package following the instructions under the Attribution section of the GitHub page.
- Parameters:
name (
Optional[str]) – The name of the search, controlling the last folder results are output.path_prefix (
Optional[str]) – The path of folders prefixing the name folder where results are output.unique_tag (
Optional[str]) – The name of a unique tag for this model-fit, which will be given a unique entry in the sqlite database and also acts as the folder after the path prefix and before the search name.nwalkers (
int) – The number of walkers in the ensemble used to sample parameter space.nsteps (
int) – The number of steps that must be taken by every walker.initializer (
Optional[Initializer]) – Generates the initialize samples of non-linear parameter space (see autofit.non_linear.initializer).auto_correlation_settings – Customizes and performs auto correlation calculations performed during and after the search.
number_of_cores (
int) – The number of cores sampling is performed using a Python multiprocessing Pool instance.silence (
bool) – If True, the default print output of the non-linear search is silenced.session (
Optional[Session]) – An SQLalchemy session instance so the results of the model-fit are written to an SQLite database.
Methods
Override in subclasses to reduce sampler iterations for test mode.
check_modelcopy_with_pathsexact_fitfitFit a model, M with some function f that takes instances of the class represented by model M and gives a score for their fitness.
make_poolMake the pool instance used to parallelize a NonLinearSearch alongside a set of unique ids for every process in the pool.
make_sneakier_poolmake_sneaky_poolCreate a pool for multiprocessing that uses slight-of-hand to avoid copying the fitness function between processes multiple times.
optimisePerform optimisation for expectation propagation.
Output the sampler results to hard-disk in their internal format.
perform_updatePerform an update of the non-linear search's model-fitting results.
perform_visualizationPerform visualization of the non-linear search's model-fitting results.
plot_resultsplot_start_pointVisualize the starting point of the non-linear search, using an instance of the model at the starting point of the maximum likelihood estimator.
post_fit_outputCleans up the output folderds after a completed non-linear search.
pre_fit_outputOutputs attributes of fit before the non-linear search begins.
result_via_completed_fitReturns the result of the non-linear search of a completed model-fit.
samples_fromLoads the samples of a non-linear search from its output files.
Returns a Samples object from the emcee internal results.
start_resume_fitAttributes
The Emcee hdf5 backend, which provides access to all samples, likelihoods, etc.
loggerLog 'msg % args' with severity 'DEBUG'.
namepathsshould_plot_start_pointtimerReturns the timer of the search, which is used to output informaiton such as how long the search took and how much parallelization sped up the search time.
- apply_test_mode()[source]#
Override in subclasses to reduce sampler iterations for test mode.
Called during __init__ when test mode is active (level 1). Subclasses should directly mutate instance attributes to minimize the number of iterations the sampler performs.
- output_search_internal(search_internal)[source]#
Output the sampler results to hard-disk in their internal format.
Emcee uses a backend to store and load results, therefore the outputting of the search internal to a dill file is disabled.
- Parameters:
sampler – The nautilus sampler object containing the results of the model-fit.
- samples_via_internal_from(model, search_internal=None)[source]#
Returns a Samples object from the emcee internal results.
The samples contain all information on the parameter space sampling (e.g. the parameters, log likelihoods, etc.).
The internal search results are converted from the native format used by the search to lists of values (e.g. parameter_lists, log_likelihood_list).
- Parameters:
model – Maps input vectors of unit parameter values to physical values and model instances via priors.
- property backend_filename#
- property backend: emcee.backends.HDFBackend#
The Emcee hdf5 backend, which provides access to all samples, likelihoods, etc. of the non-linear search.
The sampler is described in the “Results” section at https://dynesty.readthedocs.io/en/latest/quickstart.html