Metadata-Version: 2.1
Name: thomas-core
Version: 0.1.1
Summary: Thomas, a library for working with Bayesian Networks.
Home-page: https://github.com/mellesies/thomas-core
Author: Melle Sieswerda
Author-email: m.sieswerda@iknl.nl
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >= 3.6
Description-Content-Type: text/markdown
Requires-Dist: lark-parser
Requires-Dist: matplotlib (>=3.1)
Requires-Dist: networkx (>=2.4)
Requires-Dist: numpy (>=1.18)
Requires-Dist: pandas (>=1)
Requires-Dist: termcolor

[![Coverage Status](https://coveralls.io/repos/github/mellesies/thomas-core/badge.svg?branch=master)](https://coveralls.io/github/mellesies/thomas-core?branch=master)
[![Build Status](https://travis-ci.org/mellesies/thomas-core.svg?branch=master)](https://travis-ci.org/mellesies/thomas-core)
[![badge](https://img.shields.io/badge/launch-JupyterLab%20binder-579ACA.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFkAAABZCAMAAABi1XidAAAB8lBMVEX///9XmsrmZYH1olJXmsr1olJXmsrmZYH1olJXmsr1olJXmsrmZYH1olL1olJXmsr1olJXmsrmZYH1olL1olJXmsrmZYH1olJXmsr1olL1olJXmsrmZYH1olL1olJXmsrmZYH1olL1olL0nFf1olJXmsrmZYH1olJXmsq8dZb1olJXmsrmZYH1olJXmspXmspXmsr1olL1olJXmsrmZYH1olJXmsr1olL1olJXmsrmZYH1olL1olLeaIVXmsrmZYH1olL1olL1olJXmsrmZYH1olLna31Xmsr1olJXmsr1olJXmsrmZYH1olLqoVr1olJXmsr1olJXmsrmZYH1olL1olKkfaPobXvviGabgadXmsqThKuofKHmZ4Dobnr1olJXmsr1olJXmspXmsr1olJXmsrfZ4TuhWn1olL1olJXmsqBi7X1olJXmspZmslbmMhbmsdemsVfl8ZgmsNim8Jpk8F0m7R4m7F5nLB6jbh7jbiDirOEibOGnKaMhq+PnaCVg6qWg6qegKaff6W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/sSRs2w7ovVHKtjrX2pd7ZMlTxAYfBAL9jiDwfLkq55Tm7ifhMlTGPyCAs7RFRhn47JnlcB9RM5T97ASuZXIcVNuUDIndpDbdsfrqsOppeXl5Y+XVKdjFCTh+zGaVuj0d9zy05PPK3QzBamxdwtTCrzyg/2Rvf2EstUjordGwa/kx9mSJLr8mLLtCW8HHGJc2R5hS219IiF6PnTusOqcMl57gm0Z8kanKMAQg0qSyuZfn7zItsbGyO9QlnxY0eCuD1XL2ys/MsrQhltE7Ug0uFOzufJFE2PxBo/YAx8XPPdDwWN0MrDRYIZF0mSMKCNHgaIVFoBbNoLJ7tEQDKxGF0kcLQimojCZopv0OkNOyWCCg9XMVAi7ARJzQdM2QUh0gmBozjc3Skg6dSBRqDGYSUOu66Zg+I2fNZs/M3/f/Grl/XnyF1Gw3VKCez0PN5IUfFLqvgUN4C0qNqYs5YhPL+aVZYDE4IpUk57oSFnJm4FyCqqOE0jhY2SMyLFoo56zyo6becOS5UVDdj7Vih0zp+tcMhwRpBeLyqtIjlJKAIZSbI8SGSF3k0pA3mR5tHuwPFoa7N7reoq2bqCsAk1HqCu5uvI1n6JuRXI+S1Mco54YmYTwcn6Aeic+kssXi8XpXC4V3t7/ADuTNKaQJdScAAAAAElFTkSuQmCC)](https://mybinder.org/v2/gh/mellesies/thomas-core/master?urlpath=%2Flab%2Ftree%2Fnotebooks)

# Thomas
Very simple (almost naive ;-) bayesian network implementation.

Contains examples (`thomas.core.examples`) from the book "Probabilistic
Graphical Models: Principles and Techniques" from Koller and Friedman ([PGM
Stanford](http://pgm.stanford.edu)) and from the lecture by [Adnan
Darwiche](http://web.cs.ucla.edu/~darwiche/) on YouTube: * [6a. Inference by
Variable Elimination I (Chapter
6)](https://www.youtube.com/watch?v=7oRReD_ayWo). * [6b. Inference by Variable
Elimination II (Chapter 6)](https://www.youtube.com/watch?v=QSSmx1ndUvg).

## Installation

### Regular installation
To install the latest version from **PyPI**:

```bash
    pip install thomas-core
```

Install from PyyPI TEST:

```bash
    pip install -i https://test.pypi.org/simple/ --extra-index-url=https://pypi.python.org/simple thomas-core
    pip install -i https://test.pypi.org/simple/ --extra-index-url=https://pypi.python.org/simple thomas-jupyter-widget
```


To install the latest version from **source**:

```bash
    pip install git+https://github.com/mellesies/thomas-core
```

### Development installation
To do a development install:

```bash
    git clone https://github.com/mellesies/thomas-core
    cd thomas-core
    pip install -e .
```

### Additional packages
If you're using JupyterLab, I'd recommend also installing the Widget that can display Bayesian Networks.

## Docker
A Docker image is available should you just want to try things out.The following command will start a JupyterLab server, listening on [http://localhost:8888](http://localhost:8888).

```bash
    docker run --rm -it -p 8888:8888 mellesies/thomas-core
```


## Usage
To get started with querying a network, try the following:
```python
from thomas.core import examples

# Load an example network
Gs = examples.get_student_network()

# This should output the prior probability of random variable 'S' (SAT score).
print(Gs.P('S'))
print()

# Expected output:
# P(S)
# S
# s0    0.725
# s1    0.275
# dtype: float64

# Query for the conditional probability of S given the student is intelligent.
print(Gs.P('S|I=i1'))

# Expected output:
# P(S)
# S
# s0    0.2
# s1    0.8
# dtype: float64
```

Alternatively, you can have a go at the example notebooks through [Binder](https://mybinder.org):
* [notebooks/1. Factors.ipynb](https://mybinder.org/v2/gh/mellesies/thomas-core/master?filepath=notebooks%2F1.%20Factors.ipynb)
* [notebooks/2. Bags of factors.ipynb](https://mybinder.org/v2/gh/mellesies/thomas-core/master?filepath=notebooks%2F2.%20Bags%20of%20factors.ipynb)
* [notebooks/3. Conditional probability tables.ipynb](https://mybinder.org/v2/gh/mellesies/thomas-core/master?filepath=notebooks%2F3.%20Conditional%20probability%20tables.ipynb)
* [notebooks/4. Bayesian Networks.ipynb](https://mybinder.org/v2/gh/mellesies/thomas-core/master?filepath=notebooks%2F4.%20Bayesian%20Networks.ipynb)


