In this notebook, we'll infer the posterior distribution of yeast dataset using generalised gamma process graph model.
Original source of the dataset with detailed description: http://www.cise.ufl.edu/research/sparse/matrices/Pajek/yeast.html
In [1]:
import os
import pickle
import time
from collections import defaultdict
import matplotlib.pyplot as plt
import numpy as np
from scipy.io import loadmat
from sgp import GGPgraphmcmc
%matplotlib inline
In [2]:
mat = loadmat('../data/yeast/yeast.mat')
graph = mat['Problem'][0][0][2]
In [3]:
modelparam = dict()
mcmcparam = dict()
modelparam['alpha'] = (0, 0)
modelparam['sigma'] = (0, 0)
modelparam['tau'] = (0, 0)
mcmcparam['niter'] = 500
mcmcparam['nburn'] = 1
mcmcparam['thin'] = 1
mcmcparam['leapfrog.L'] = 5
mcmcparam['leapfrog.epsilon'] = 0.1
mcmcparam['leapfrog.nadapt'] = 1
mcmcparam['latent.MH_nb'] = 1
mcmcparam['hyper.MH_nb'] = 2
mcmcparam['hyper.rw_std'] = [0.02, 0.02]
mcmcparam['store_w'] = True
typegraph='undirected' # or simple
samples, stats = GGPgraphmcmc(graph, modelparam, mcmcparam, typegraph, verbose=True)
The invalid values are carefully handled in the inference codes. It is safe to ignore the warning messages.
In [4]:
plt.plot(samples['sigma'])
plt.title('Trace plot of $\sigma$ variable')
Out[4]:
When the sigma is less than 0, the inferred graph is dense.
In [5]:
plt.plot(stats['w_rate'])
plt.title('MH acceptance rate for weight w')
Out[5]:
In [6]:
plt.plot(stats['hyper_rate'])
plt.title('MH acceptance rate for hyper-params')
Out[6]:
checking the acceptance ratio