Skip to main content

micodag is a Python package for learning Bayesian network using mixed integer convex programming.

  • Related paper:
    1. Integer Programming for Learning Directed Acyclic Graphs from Non-identifiable Gaussian Models
    2. An Asymptotically Optimal Coordinate Descent Algorithm for Learning Bayesian Networks from Gaussian Models
  • Authors: Tong Xu, Armeen Taeb, Simge Kucukyavuz, Ali Shojaie
  • Code for reproducing experiments in the paper is available on Github
  • Source code: https://github.com/AtomXT/micodag

Install

$ pip install micodag

Simple example

Please download the following test files: data, true graph, and moral graph.

import micodag as mic
import pandas as pd
import numpy as np

data = pd.read_csv("data_3bowling_n_500_iter_1.csv", header=None)
moral = pd.read_table('Sparse_Moral_edges_9_500_3.txt', delimiter=",", header=None)
true_B = pd.read_table('Sparse_Original_edges_9_500_3.txt', delimiter=",", header=None)
n, p = data.shape
lam = 12*np.log(p)/n

true_moral_ = [[0] * data.shape[1] for i in range(data.shape[1])]
for i in range(len(moral)):
    true_moral_[moral.iloc[i, 0] - 1][moral.iloc[i, 1] - 1] = 1
true_moral_ = np.array(true_moral_)

RGAP, B, _, obj, _ = mic.optimize(data, moral, lam)
est, min_obj = mic.CD(data, true_moral_, MAX_cycles=400,
                  lam=np.sqrt(12 * np.log(p) / n))
B_arcs = pd.DataFrame([[i+1, j+1] for i in range(p) for j in range(p) if B[i, j] != 0])
B_arcs_cd = pd.DataFrame([[i+1, j+1] for i in range(p) for j in range(p) if est[i, j] != 0])
print(B_arcs)
print(B_arcs_cd)
print(true_B)

Metadata

Release files for micodag 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for micodag 0.0.9
File Size Uploaded
micodag-0.0.9.tar.gz 6.9 kB Details

Release files / micodag-0.0.9.tar.gz

Download URL micodag-0.0.9.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d03f31f1f3b988308bdc9a712be4ab15afad7d6d7ae634460eaa5de5b05eb4e2
BLAKE2b-256 checksum
How to use checksums
8811859296bddecbf11dcfc0f861f3ecc6880a8510d359b04619da05f1320ec4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.0.9 This release

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.3

1 release file

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page