harmonic

Machine learning assisted marginal likelihood (Bayesian evidence) estimation for Bayesian model selection

https://github.com/astro-informatics/harmonic

Science Score: 59.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
    Links to: arxiv.org, scholar.google
  • Committers with academic emails
    11 of 15 committers (73.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.8%) to scientific vocabulary

Keywords

bayesian-inference code machine-learning statistics-toolbox
Last synced: 6 months ago · JSON representation

Repository

Machine learning assisted marginal likelihood (Bayesian evidence) estimation for Bayesian model selection

Basic Info
Statistics
  • Stars: 69
  • Watchers: 10
  • Forks: 9
  • Open Issues: 34
  • Releases: 7
Topics
bayesian-inference code machine-learning statistics-toolbox
Created about 8 years ago · Last pushed 9 months ago
Metadata Files
Readme License

README.rst

.. |github| image:: https://img.shields.io/badge/GitHub-harmonic-brightgreen.svg?style=flat
    :target: https://github.com/astro-informatics/harmonic
.. |tests| image:: https://github.com/astro-informatics/harmonic/actions/workflows/python.yml/badge.svg
    :target: https://github.com/astro-informatics/harmonic/actions/workflows/python.yml
.. |docs| image:: https://readthedocs.org/projects/ansicolortags/badge/?version=latest
    :target: https://astro-informatics.github.io/harmonic/
.. |codecov| image:: https://codecov.io/gh/astro-informatics/harmonic/branch/main/graph/badge.svg?token=1s4SATphHV
    :target: https://codecov.io/gh/astro-informatics/harmonic
.. |pypi| image:: https://badge.fury.io/py/harmonic.svg
    :target: https://badge.fury.io/py/harmonic
.. |licence| image:: https://img.shields.io/badge/License-GPL-blue.svg
    :target: http://perso.crans.org/besson/LICENSE.html
.. |arxiv1| image:: http://img.shields.io/badge/arXiv-2111.12720-orange.svg?style=flat
    :target: https://arxiv.org/abs/2111.12720
.. |arxiv2| image:: http://img.shields.io/badge/arXiv-2207.04037-orange.svg?style=flat
    :target: https://arxiv.org/abs/2207.04037
.. |arxiv3| image:: http://img.shields.io/badge/arXiv-2307.00048-orange.svg?style=flat
    :target: https://arxiv.org/abs/2307.00048
.. |arxiv4| image:: http://img.shields.io/badge/arXiv-2405.05969-orange.svg?style=flat
    :target: https://arxiv.org/abs/2405.05969
.. .. image:: https://img.shields.io/pypi/pyversions/harmonic.svg
..     :target: https://pypi.python.org/pypi/harmonic/

|github| |tests| |docs| |codecov| |pypi| |licence| |arxiv1| |arxiv2| |arxiv3| |arxiv4|


|logo|

.. |logo| image:: /docs/assets/harm_badge_simple.svg
    :width: 90
=================================================================================================================

``harmonic`` is an open source, well tested and documented Python implementation of the *learnt harmonic mean estimator* (`McEwen et al. 2021 `_) to compute the marginal likelihood (Bayesian evidence), required for Bayesian model selection.

For an accessible overview of the *learnt harmonic mean estimator* please see this `Towards Data Science article `_.

While ``harmonic`` requires only posterior samples, and so is agnostic to the technique used to perform Markov chain Monte Carlo (MCMC) sampling, ``harmonic`` works well with MCMC sampling techniques that naturally provide samples from multiple chains by their ensemble nature, such as affine invariant ensemble samplers.  For instance, ``harmonic`` can be used with the popular `emcee `_ code implementing the affine invariant sampler of `Goodman & Weare (2010) `_, or the `NumPyro `_ code implementing various MCMC algorithms.

Basic usage is highlighted in this `interactive demo `_. 

Overview video
==============

.. image:: docs/assets/video_screenshot.png
    :target: https://www.youtube.com/watch?v=RHoQItSA4J4


Installation
============

Brief installation instructions are given below (for further details see the `full installation documentation `_).  

Quick install (PyPi)
--------------------
The ``harmonic`` package can be installed by running

.. code-block:: bash
    
    pip install harmonic

Install from source (GitHub)
----------------------------
The ``harmonic`` package can also be installed from source by running

.. code-block:: bash

    git clone https://github.com/astro-informatics/harmonic
    cd harmonic

and installing within the root directory, with one command 

.. code-block:: bash

    pip install .

To check the install has worked correctly run the unit tests with 

.. code-block:: bash

    pytest 

To build the documentation from source run

.. code-block:: bash

    cd docs && make html

Then open ``./docs/_build/html/index.html`` in a browser.

Documentation
=============

Comprehensive  `documentation for harmonic `_ is available.

Contributors
============

`Jason D. McEwen `_, `Christopher G. R. Wallis `_, `Matthew A. Price `_, `Matthew M. Docherty `_, `Alessio Spurio Mancini `_, `Alicja Polanska `_, `Kiyam Lin `_.


Attribution
===========

Please cite `McEwen et al. (2021) `_ if this code package has been of use in your project. 

A BibTeX entry for the paper is:

.. code-block:: 

     @article{harmonic, 
        author = {Jason~D.~McEwen and Christopher~G.~R.~Wallis and Matthew~A.~Price and Matthew~M.~Docherty},
         title = {Machine learning assisted {B}ayesian model comparison: learnt harmonic mean estimator},
       journal = {ArXiv},
        eprint = {arXiv:2111.12720},
          year = 2021
     }


Please *also* cite `Polanska et al. (2024) `_ if using normalizing flow models.

A BibTeX entry for the paper is:

.. code-block::

    @misc{polanska2024learned,
        title={Learned harmonic mean estimation of the Bayesian evidence with normalizing flows}, 
        author={Alicja Polanska and Matthew A. Price and Davide Piras and Alessio Spurio Mancini and Jason D. McEwen},
        year={2024},
        eprint={2405.05969},
        archivePrefix={arXiv},
        primaryClass={astro-ph.IM}
    }

Please *also* cite `Spurio Mancini et al. (2022) `_ if this code has been of use in a simulation-based inference project.

A BibTeX entry for the paper is:

.. code-block::

     @article{spurio-mancini:harmonic_sbi,
        author   = {A.~Spurio Mancini and M.~M.~Docherty and M.~A.~Price and J.~D.~McEwen},
        doi      = {10.1093/rasti/rzad051},
        eprint   = {arXiv:2207.04037},
        journal  = {{RASTI}, in press},
        title    = {{B}ayesian model comparison for simulation-based inference},
        year     = {2023}
     }


License
=======

``harmonic`` is released under the GPL-3 license (see `LICENSE.txt `_), subject to 
the non-commercial use condition (see `LICENSE_EXT.txt `_)

.. code-block::

     harmonic
     Copyright (C) 2021 Jason D. McEwen, Christopher G. R. Wallis, 
     Matthew A. Price, Matthew M. Docherty, Alessio Spurio Mancini, 
     Alicja Polanska & contributors

     This program is released under the GPL-3 license (see LICENSE.txt), 
     subject to a non-commercial use condition (see LICENSE_EXT.txt).

     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Owner

  • Name: AstroInfo Team @ UCL
  • Login: astro-informatics
  • Kind: organization
  • Location: United Kingdom

GitHub Events

Total
  • Create event: 5
  • Release event: 1
  • Issues event: 9
  • Watch event: 13
  • Delete event: 5
  • Member event: 1
  • Issue comment event: 9
  • Push event: 27
  • Pull request review event: 15
  • Pull request review comment event: 6
  • Pull request event: 11
Last Year
  • Create event: 5
  • Release event: 1
  • Issues event: 9
  • Watch event: 13
  • Delete event: 5
  • Member event: 1
  • Issue comment event: 9
  • Push event: 27
  • Pull request review event: 15
  • Pull request review comment event: 6
  • Pull request event: 11

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 968
  • Total Committers: 15
  • Avg Commits per committer: 64.533
  • Development Distribution Score (DDS): 0.705
Past Year
  • Commits: 48
  • Committers: 2
  • Avg Commits per committer: 24.0
  • Development Distribution Score (DDS): 0.146
Top Committers
Name Email Commits
Jason McEwen j****n@g****m 286
alicjapolanska a****2@u****k 268
Cosmomatt m****7@u****k 161
mdochertyastro m****1@u****k 122
CosmoMatt m****e@k****m 54
Christopher Wallis c****s@C****l 25
Christopher Wallis c****s@e****k 15
Christopher Wallis c****s@e****k 12
Alicja Polanska a****a@g****m 7
Christopher Wallis c****s@d****k 7
Christopher Wallis c****s@e****k 6
Christopher Wallis c****s@e****k 2
Alessio Spurio Mancini a****i@u****k 1
Christopher Wallis c****s@e****k 1
Christopher Wallis c****s@m****k 1

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 102
  • Total pull requests: 89
  • Average time to close issues: 5 months
  • Average time to close pull requests: 30 days
  • Total issue authors: 11
  • Total pull request authors: 6
  • Average comments per issue: 0.94
  • Average comments per pull request: 1.26
  • Merged pull requests: 79
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 10
  • Pull requests: 8
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 14 days
  • Issue authors: 3
  • Pull request authors: 3
  • Average comments per issue: 0.1
  • Average comments per pull request: 1.25
  • Merged pull requests: 7
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • jasonmcewen (46)
  • alicjapolanska (23)
  • mmdocherty (17)
  • CosmoMatt (4)
  • stefanocovino (1)
  • lix2k3 (1)
  • dpiras (1)
  • myth-1995 (1)
  • AB-physics (1)
  • eblur (1)
  • sahiljhawar (1)
Pull Request Authors
  • alicjapolanska (37)
  • CosmoMatt (24)
  • jasonmcewen (20)
  • mmdocherty (19)
  • Kiyam (4)
  • alessiospuriomancini (1)
Top Labels
Issue Labels
infrastructure (6) enhancement (4) documentation (3) future release (2) high priority (2) bug (2) low priority (1) wontfix (1)
Pull Request Labels
enhancement (2) high priority (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 376 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 14
  • Total maintainers: 4
pypi.org: harmonic

Python package for efficient Bayesian evidence computation

  • Versions: 14
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 376 Last month
Rankings
Dependent packages count: 7.3%
Stargazers count: 11.2%
Forks count: 13.3%
Average: 14.0%
Downloads: 16.3%
Dependent repos count: 22.1%
Last synced: 6 months ago

Dependencies

requirements/requirements-core.txt pypi
  • colorlog ==4.1.0
  • cython ==0.29.17
  • ipython ==7.16.1
  • jupyter ==1.0.0
  • numpy ==1.19.2
  • pyyaml ==5.4
  • scikit-learn ==0.22.2.post1
  • scipy ==1.4.1
requirements/requirements-docs.txt pypi
  • nbsphinx-link ==1.3.0
  • sphinx ==4.2.0
  • sphinx-git ==11.0.0
  • sphinx-rtd-dark-mode ==1.2.4
  • sphinx-rtd-theme ==1.0.0
  • sphinx-tabs ==3.2.0
  • sphinx_toolbox ==2.15.0
  • sphinxcontrib-bibtex ==2.4.1
  • sphinxcontrib-texfigure ==0.1.3
requirements/requirements-examples.txt pypi
  • corner ==2.0.1
  • emcee ==3.0.2
  • getdist ==1.1.0
  • matplotlib ==3.2.1
requirements/requirements-test.txt pypi
  • codecov *
  • pytest-cov *
.github/workflows/python.yml actions
  • JamesIves/github-pages-deploy-action 4.1.5 composite
  • actions/checkout v2.3.1 composite
  • actions/setup-python v2 composite
pyproject.toml pypi
setup.py pypi