PC constraint-based BN learning algorithm

Posted on Wed 17 August 2016 in score_based

The past while I have been working on basic constraint-based BN learning. This required a method to perform conditional independence tests on the data set. Surprisingly, such tests for conditional independence are not part of scipy.stats or other statistics libraries.

To test if X _|_ Y | Zs, one ...

Continue reading

HillClimbEstimator done

Posted on Sun 14 August 2016 in score_based

pgmpy now has a basic hill climb BN structure estimator.

Usage:

import pandas as pd
import numpy as np
from pgmpy.estimators import HillClimbSearch, BicScore

# create data sample with 9 random variables:
data = pd.DataFrame(np.random.randint(0, 5, size=(5000, 9)), columns=list('ABCDEFGHI'))
# add 10th dependent variable ...
Continue reading

BN structure score cross-check

Posted on Tue 02 August 2016 in score_based

After some doubts about the BN structure learning performance on a few test cases, I cross checked my structure scoring functions against the implementation from the bnlearn R package. After minor changes the implemented scores now yield the exact same results:

pgmpy:

~$ python
Python 3.5.2 (default, Jun 28 ...
Continue reading

Examples for basic BN learning,

Posted on Thu 07 July 2016 in score_based

I’ll soon finish basic score-based structure estimation for BayesianModels. Below is the current state of my PR, with two examples.

Changes in pgmpy/estimators/

I rearranged the estimator classes to inherit from each other like this:

.                                    MaximumLikelihoodEstimator
                                   /
                ParameterEstimator -- BayesianEstimator
              /
BaseEstimator                        ExhaustiveSearch
            | \                    /
            |   StructureEstimator -- HillClimbSearch
            |                      \
            |                        ConstraintBasedEstimator
            |
            |
            |                BayesianScore
            |              /
            StructureScore -- BicScore

BaseEstimator ...

Continue reading

Score-based Structure Learning BNs

Posted on Fri 24 June 2016 in score_based

With a bit of delay, I am now working on a basic PR for score-based structure estimation for Bayesian Networks. It comes with two ingredients:

  • The StructureScore-Class and its subclasses BayesianScore and BICScore. They are initialized with a data set and provide a score-method to compute how well ...
Continue reading