Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mynameisvinn/basilisk
bayesian networks made easy
https://github.com/mynameisvinn/basilisk
bayesian-network causal-inference causal-models
Last synced: 14 days ago
JSON representation
bayesian networks made easy
- Host: GitHub
- URL: https://github.com/mynameisvinn/basilisk
- Owner: mynameisvinn
- Created: 2019-04-15T13:35:56.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-04-24T11:39:56.000Z (over 5 years ago)
- Last Synced: 2024-11-07T07:16:41.724Z (2 months ago)
- Topics: bayesian-network, causal-inference, causal-models
- Language: Jupyter Notebook
- Homepage:
- Size: 282 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# basilisk
quickly construct bayesian networks with basilisk. define the graph and provide joint observations, and basilik will handle everything else.## a working example
lets use [murphy's classic sprinkler example](https://www.cs.ubc.ca/~murphyk/Bayes/bayes_tutorial.pdf).first, define nodes and their corresponding parents. in bayesian networks, a parent has a *casual* relationship with its children.
```
C = Node("cloudy")
R = Node("rain", [C]) # rain's parent is cloudy
S = Node("sprinkler", [C])
W = Node("wet", [R, S])ls_nodes = [C, R, S, W]
```
then, instantiate a model and fit with joint observations.
```
model = BN(ls_nodes)obs = pd.read_csv("observations.csv") # joint observations
model.fit(obs) # fit a model, scikit-stylemodel.draw_graph(node_size=1000)
```
we can inspect conditional probability tables.
```
W.cpt # basilik automatically computes conditional probabilities
```
we can sample from any node in the graph.
```
model.execute(W)# {'cloudy': 'True', 'sprinkler': 'False', 'rain': 'True', 'wet': 'False'}
```