An open API service indexing awesome lists of open source software.

https://github.com/roma-glushko/posterior

๐ŸŽฒ A lightweight framework for Bayes inference.
https://github.com/roma-glushko/posterior

bayesian-inference data-science framework statistics

Last synced: 3 months ago
JSON representation

๐ŸŽฒ A lightweight framework for Bayes inference.

Awesome Lists containing this project

README

          

# Posterior

A lightweight framework for Bayes's inference.

## Usage

```python

"""
Problem:
There are two bowls of cookies.
Bowl 1 contains 30 vanilla cookies and 10 chocolate cookies.
Bowl 2 contains 20 of each.
You choose one of the bowls at random and, without looking, then select a cookie at random.
The cookie is vanilla.
What is the probability that it came from Bowl 1?
"""

from posterior.hypotheses import Hypotheses

cookie_likelihood = {
"bowl1": {
"chocolate": 1 / 4,
"vanilla": 3 / 4
},
"bowl2": {
"chocolate": 1 / 2,
"vanilla": 1 / 2,
},
}

hypotheses = Hypotheses(["bowl1", "bowl2"], likelihood=cookie_likelihood)
hypotheses.evaluate("vanilla")

print(hypotheses)
```

Output:

```bash
โ•’โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ••
โ”‚ Outcomes โ”‚ Probabilities โ”‚
โ•žโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ก
โ”‚ bowl1 โ”‚ 0.6 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ bowl2 โ”‚ 0.4 โ”‚
โ•˜โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•›
```