{"id":13570008,"url":"https://github.com/christophmark/bayesloop","last_synced_at":"2025-04-06T15:13:08.886Z","repository":{"id":2953800,"uuid":"41474112","full_name":"christophmark/bayesloop","owner":"christophmark","description":"Probabilistic programming framework that facilitates objective model selection for time-varying parameter models. ","archived":false,"fork":false,"pushed_at":"2024-04-19T16:42:44.000Z","size":11687,"stargazers_count":157,"open_issues_count":2,"forks_count":28,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-30T14:11:21.482Z","etag":null,"topics":["anomaly-detection","bayesian-inference","model-selection","probabilistic-programming","time-series-analysis"],"latest_commit_sha":null,"homepage":"http://bayesloop.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/christophmark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-27T08:11:41.000Z","updated_at":"2025-03-28T20:46:53.000Z","dependencies_parsed_at":"2024-11-05T02:42:44.372Z","dependency_job_id":null,"html_url":"https://github.com/christophmark/bayesloop","commit_stats":{"total_commits":501,"total_committers":3,"mean_commits":167.0,"dds":0.005988023952095856,"last_synced_commit":"6ea3b88c2eee330858b14566aa170402e2ca7f0a"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophmark%2Fbayesloop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophmark%2Fbayesloop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophmark%2Fbayesloop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophmark%2Fbayesloop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christophmark","download_url":"https://codeload.github.com/christophmark/bayesloop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247500469,"owners_count":20948880,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anomaly-detection","bayesian-inference","model-selection","probabilistic-programming","time-series-analysis"],"created_at":"2024-08-01T14:00:47.122Z","updated_at":"2025-04-06T15:13:08.858Z","avatar_url":"https://github.com/christophmark.png","language":"Python","readme":"[![bayesloop](https://raw.githubusercontent.com/christophmark/bayesloop/master/docs/images/logo_400x100px.png)](http://bayesloop.com)\n\n[![Build status](https://github.com/christophmark/bayesloop/workflows/Tests/badge.svg?branch=master)](https://github.com/christophmark/bayesloop/actions/workflows/test.yml)\n[![Documentation status](https://readthedocs.org/projects/bayesloop/badge/?version=latest)](http://docs.bayesloop.com) \n[![Coverage Status](https://codecov.io/gh/christophmark/bayesloop/branch/master/graph/badge.svg?token=637W4M2RCE)](https://codecov.io/gh/christophmark/bayesloop)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![DOI](https://zenodo.org/badge/41474112.svg)](https://zenodo.org/badge/latestdoi/41474112)\n\nTime series analysis today is an important cornerstone of quantitative science in many disciplines, including natural and life sciences as well as economics and social sciences. Regarding diverse phenomena like tumor cell migration, brain activity and stock trading, a similarity of these complex systems becomes apparent: the observable data we measure – cell migration paths, neuron spike rates and stock prices – are the result of a multitude of underlying processes that act over a broad range of spatial and temporal scales. It is thus to expect that the statistical properties of these systems are not constant, but themselves show stochastic or deterministic dynamics of their own. Time series models used to understand the dynamics of complex systems therefore have to account for temporal changes of the models' parameters.\n\n*bayesloop* is a python module that focuses on fitting time series models with time-varying parameters and model selection based on [Bayesian inference](https://cocosci.berkeley.edu/tom/papers/tutorial.pdf). Instead of relying on [MCMC methods](http://www.cs.ubc.ca/~arnaud/andrieu_defreitas_doucet_jordan_intromontecarlomachinelearning.pdf), *bayesloop* uses a grid-based approach to evaluate probability distributions, allowing for an efficient approximation of the [marginal likelihood (evidence)](http://alumni.media.mit.edu/~tpminka/statlearn/demo/). The marginal likelihood represents a powerful tool to objectively compare different models and/or optimize the hyper-parameters of hierarchical models. To avoid the [curse of dimensionality](https://en.wikipedia.org/wiki/Curse_of_dimensionality) when analyzing time series models with time-varying parameters, *bayesloop* employs a sequential inference algorithm that is based on the [forward-backward-algorithm](https://en.wikipedia.org/wiki/Forward%E2%80%93backward_algorithm) used in [Hidden Markov models](http://www.cs.sjsu.edu/~stamp/RUA/HMM.pdf). Here, the relevant parameter spaces are kept low-dimensional by processing time series data step by step. The module covers a large class of time series models and is easily extensible.\n\n*bayesloop* has been successfully employed in cancer research (studying the migration paths of invasive tumor cells), financial risk assessment, climate research and accident analysis. For a detailed description of these applications, see the following articles:\n\n**Bayesian model selection for complex dynamic systems**\u003cbr\u003e\nMark C., Metzner C., Lautscham L., Strissel P.L., Strick R. and Fabry B.\u003cbr\u003e\n[*Nature Communications 9:1803 (2018)*](https://www.nature.com/articles/s41467-018-04241-5)\n\n**Superstatistical analysis and modelling of heterogeneous random walks**\u003cbr\u003e\nMetzner C., Mark C., Steinwachs J., Lautscham L., Stadler F. and Fabry B.\u003cbr\u003e\n[*Nature Communications 6:7516 (2015)*](https://www.nature.com/articles/ncomms8516)\n\n## Features\n* infer time-varying parameters from time series data \n* compare hypotheses about parameter dynamics (model evidence)\n* create custom models based on SymPy and SciPy\n* straight-forward handling of missing data points\n* predict future parameter values\n* detect change-points and structural breaks in time series data\n* employ model selection to online data streams\n\n## Getting started\nFor a comprehensive introduction and overview of the main features that *bayesloop* provides, see the [documentation](http://docs.bayesloop.com).\n\nThe following code provides a minimal example of an analysis carried out using *bayesloop*. The data here consists of the number of coal mining disasters in the UK per year from 1851 to 1962 (see this [article](http://www.dima.unige.it/~riccomag/Teaching/ProcessiStocastici/coal-mining-disaster-original%20paper.pdf) for further information).\n```python\nimport bayesloop as bl\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nS = bl.HyperStudy()  # start new data study\nS.loadExampleData()  # load data array\n\n# observed number of disasters is modeled by Poisson distribution\nL = bl.om.Poisson('rate')\n\n# disaster rate itself may change gradually over time\nT = bl.tm.GaussianRandomWalk('sigma', bl.cint(0, 1.0, 20), target='rate')\n\nS.set(L, T)\nS.fit()  # inference\n\n# plot data together with inferred parameter evolution\nplt.figure(figsize=(8, 3))\n\nplt.subplot2grid((1, 3), (0, 0), colspan=2)\nplt.xlim([1852, 1961])\nplt.bar(S.rawTimestamps, S.rawData, align='center', facecolor='r', alpha=.5)\nS.plot('rate')\nplt.xlabel('year')\n\n# plot hyper-parameter distribution\nplt.subplot2grid((1, 3), (0, 2))\nplt.xlim([0, 1])\nS.plot('sigma', facecolor='g', alpha=0.7, lw=1, edgecolor='k')\nplt.tight_layout()\nplt.show()\n```\n\n![Analysis plot](https://raw.githubusercontent.com/christophmark/bayesloop/master/docs/images/example.png)\n\nThis analysis indicates a significant improvement of safety conditions between 1880 and 1900. Check out the [documentation](http://docs.bayesloop.com) for further insights!\n\n## Installation\nThe easiest way to install the latest release version of *bayesloop* is via `pip`:\n```\npip install bayesloop\n```\nAlternatively, a zipped version can be downloaded [here](https://github.com/christophmark/bayesloop/releases). The module is installed by calling `python setup.py install`.\n\n### Development version\nThe latest development version of *bayesloop* can be installed from the master branch using pip (requires git):\n```\npip install git+https://github.com/christophmark/bayesloop\n```\nAlternatively, use this [zipped version](https://github.com/christophmark/bayesloop/zipball/master) or clone the repository.\n\n## Dependencies\n*bayesloop* is tested on Python 3.8. It depends on NumPy, SciPy, SymPy, matplotlib, tqdm and cloudpickle. All except the last two are already included in the [Anaconda distribution](https://www.continuum.io/downloads) of Python. Windows users may also take advantage of pre-compiled binaries for all dependencies, which can be found at [Christoph Gohlke's page](http://www.lfd.uci.edu/~gohlke/pythonlibs/).\n\n## Optional dependencies\n*bayesloop* supports multiprocessing for computationally expensive analyses, based on the [pathos](https://github.com/uqfoundation/pathos) module. The latest version can be obtained directly from GitHub using pip (requires git):\n```\npip install git+https://github.com/uqfoundation/pathos\n```\n**Note**: Windows users need to install a C compiler *before* installing pathos. One possible solution for 64bit systems is to install [Microsoft Visual C++ 2008 SP1 Redistributable Package (x64)](http://www.microsoft.com/en-us/download/confirmation.aspx?id=2092) and [Microsoft Visual C++ Compiler for Python 2.7](http://www.microsoft.com/en-us/download/details.aspx?id=44266).\n\n## License\n[The MIT License (MIT)](https://github.com/christophmark/bayesloop/blob/master/LICENSE)\n\nIf you have any further questions, suggestions or comments, do not hesitate to contact me: \u0026#098;\u0026#097;\u0026#121;\u0026#101;\u0026#115;\u0026#108;\u0026#111;\u0026#111;\u0026#112;\u0026#064;\u0026#103;\u0026#109;\u0026#097;\u0026#105;\u0026#108;\u0026#046;\u0026#099;\u0026#111;\u0026#109;\n","funding_links":[],"categories":["Time Series","Date and Time","Uncategorized","Python"],"sub_categories":["NLP","Others","Automatic Plotting","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristophmark%2Fbayesloop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristophmark%2Fbayesloop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristophmark%2Fbayesloop/lists"}