Metadata-Version: 2.1
Name: thomas-core
Version: 0.1.3
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.7
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).

## Table of contents
1. [Regular Installation](#regular-installation)
2. [Alternatives](#alternatives)
3. [Usage](#usage)
4. [Development installation](#development-installation)

![img](https://raw.githubusercontent.com/mellesies/thomas-jupyter-widget/master/img/screenshot.png)

# Regular installation
To install the latest version from PyPI:

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

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

```bash
pip install thomas-jupyter-widget
```

See the [repository](https://github.com/mellesies/thomas-jupyter-widget) (or the screenshot above) for details on how to use it.

# Alternatives
If you don't feel like installing thomas locally, there are two alternative ways to give the platform a try.

## Docker
If you have docker available, 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
```

## Binder
[mybinder.org](https://mybinder.org) courteously provides an environment where you can try out Thomas without any local installation. Just click [here](https://mybinder.org/v2/gh/mellesies/thomas-core/master?urlpath=%2Flab%2Ftree%2Fnotebooks) (or the badge above) and after some waiting, JupyterLab should open in your browser.

You can also directly open one of the example notebooks:
* [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)


# Usage
To get started with querying a network, launch `python3` and 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
```


# Development installation
To do a development install:

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



