GSoC 2016 Work Product

Posted on Mon 22 August 2016 in general

My GSoC 2016 work can be found here:

In addition, these two Pull Requests are not yet merged:

I wrote an introduction to pgmpy’s new structure learning ...

Continue reading

GSoC Project Status Quo

Posted on Fri 19 August 2016 in general

GSoC 2016 is coming to an end I’ve just sent the last PR necessary to complete the scope of my proposal. It has been an exciting project, and I do feel that I learned a lot. I was able to implement a number of basic BN structure estimation algorithms ...

Continue reading

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.


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:


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

Feature summary of BN structure learning in python pgm libraries

Posted on Sat 23 July 2016 in general

This is a (possibly already outdated) summary of structure learning capabilities of existing Python libraries for general Bayesian networks.


  • Discrete MLE Parameter estimation
  • Discrete constraint-based Structure estimation
  • Linear Gaussian MLE Parameter estimation
  • Linear Gaussian constraint-based Structure estimation

Version 1.1, released 2012, Python 2

bnfinder (also here)

  • Discrete ...
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

Bayesian Parameter Estimation for BNs

Posted on Fri 10 June 2016 in parameter_estimation

Now that ML Parameter Estimation works well, I’ve turned to Bayesian Parameter Estimation (all for discrete variables).

The Bayesian approach is, in practice, very similar to the ML case. Both involves counting how often each state of the variable obtains in the data, conditional of the parents state. I ...

Continue reading

MLE Parameter Estimation for BNs

Posted on Wed 18 May 2016 in parameter_estimation

At the moment pgmpy supports Maximum Likelihood Estimation (MLE) to estimate the conditional probability tables (CPTs) for the variables of a Bayesian Network, given some data set. In my first PR, I’ll refactor the current MLE parameter estimation code to make it a bit nicer to use. This includes ...

Continue reading

GSoC proposal accepted!

Posted on Tue 26 April 2016 in general

My proposal for Google Summer of Code 2016 has been accepted :). This means that I will spend part of my summer working on the pgmpy library. I will implement some techniques for Bayesian Network structure learning. You can have a look an my proposal here.

As a first step, I ...

Continue reading