Name | micodag JSON |
Version |
0.0.8
JSON |
| download |
home_page | None |
Summary | A Python package of mixed integer convex programming for directed acyclic graphs. |
upload_time | 2024-09-08 04:05:26 |
maintainer | None |
docs_url | None |
author | Tong Xu |
requires_python | >=3.9 |
license | MIT |
keywords |
python
bayesian network
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
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](https://github.com/AtomXT/MICP-NID)
- Source code: https://github.com/AtomXT/micodag
# Install
```angular2html
$ pip install micodag
```
# Simple example
Please download the following test files:
[data](https://github.com/AtomXT/MICP-NID/blob/b600b9ecbe51cc3d633ca17c6d1a760658acff9d/Data/RealWorldDatasetsTXu/3bowling/data_3bowling_n_500_iter_1.csv),
[true graph](https://github.com/AtomXT/MICP-NID/blob/b600b9ecbe51cc3d633ca17c6d1a760658acff9d/Data/RealWorldDatasetsTXu/3bowling/Sparse_Original_edges_9_500_3.txt),
and
[moral graph](https://github.com/AtomXT/MICP-NID/blob/b600b9ecbe51cc3d633ca17c6d1a760658acff9d/Data/RealWorldDatasetsTXu/3bowling/Sparse_Moral_edges_9_500_3.txt).
```
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)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "micodag",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "python, Bayesian network",
"author": "Tong Xu",
"author_email": "tongxu2027@u.northwestern.edu",
"download_url": "https://files.pythonhosted.org/packages/b8/e4/68d6d1fceeeed676da85b178eca3e03b9f9d3f24929233479909a1779fc1/micodag-0.0.8.tar.gz",
"platform": null,
"description": "micodag is a Python package for learning Bayesian network using mixed integer convex programming. \n\n- Related paper:\n 1. Integer Programming for Learning Directed Acyclic Graphs from Non-identifiable Gaussian Models\n 2. An Asymptotically Optimal Coordinate Descent Algorithm for Learning Bayesian Networks from Gaussian Models\n- Authors: Tong Xu, Armeen Taeb, Simge Kucukyavuz, Ali Shojaie\n- Code for reproducing experiments in the paper is available on [Github](https://github.com/AtomXT/MICP-NID)\n- Source code: https://github.com/AtomXT/micodag\n\n# Install\n\n```angular2html\n$ pip install micodag\n```\n\n# Simple example\n\nPlease download the following test files:\n [data](https://github.com/AtomXT/MICP-NID/blob/b600b9ecbe51cc3d633ca17c6d1a760658acff9d/Data/RealWorldDatasetsTXu/3bowling/data_3bowling_n_500_iter_1.csv),\n [true graph](https://github.com/AtomXT/MICP-NID/blob/b600b9ecbe51cc3d633ca17c6d1a760658acff9d/Data/RealWorldDatasetsTXu/3bowling/Sparse_Original_edges_9_500_3.txt),\nand\n [moral graph](https://github.com/AtomXT/MICP-NID/blob/b600b9ecbe51cc3d633ca17c6d1a760658acff9d/Data/RealWorldDatasetsTXu/3bowling/Sparse_Moral_edges_9_500_3.txt).\n\n\n```\nimport micodag as mic\nimport pandas as pd\nimport numpy as np\n\ndata = pd.read_csv(\"data_3bowling_n_500_iter_1.csv\", header=None)\nmoral = pd.read_table('Sparse_Moral_edges_9_500_3.txt', delimiter=\",\", header=None)\ntrue_B = pd.read_table('Sparse_Original_edges_9_500_3.txt', delimiter=\",\", header=None)\nn, p = data.shape\nlam = 12*np.log(p)/n\n\ntrue_moral_ = [[0] * data.shape[1] for i in range(data.shape[1])]\nfor i in range(len(moral)):\n true_moral_[moral.iloc[i, 0] - 1][moral.iloc[i, 1] - 1] = 1\ntrue_moral_ = np.array(true_moral_)\n\nRGAP, B, _, obj, _ = mic.optimize(data, moral, lam)\nest, min_obj = mic.CD(data, true_moral_, MAX_cycles=400,\n lam=np.sqrt(12 * np.log(p) / n))\nB_arcs = pd.DataFrame([[i+1, j+1] for i in range(p) for j in range(p) if B[i, j] != 0])\nB_arcs_cd = pd.DataFrame([[i+1, j+1] for i in range(p) for j in range(p) if est[i, j] != 0])\nprint(B_arcs)\nprint(B_arcs_cd)\nprint(true_B)\n\n```\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python package of mixed integer convex programming for directed acyclic graphs.",
"version": "0.0.8",
"project_urls": null,
"split_keywords": [
"python",
" bayesian network"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b8e468d6d1fceeeed676da85b178eca3e03b9f9d3f24929233479909a1779fc1",
"md5": "0959ebcf517e370c7bed38ad8042ccf5",
"sha256": "b976ecff1e8869ebaa3f94c24628c004b3fea6f1408c0c8713e985813169fa29"
},
"downloads": -1,
"filename": "micodag-0.0.8.tar.gz",
"has_sig": false,
"md5_digest": "0959ebcf517e370c7bed38ad8042ccf5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 6575,
"upload_time": "2024-09-08T04:05:26",
"upload_time_iso_8601": "2024-09-08T04:05:26.583899Z",
"url": "https://files.pythonhosted.org/packages/b8/e4/68d6d1fceeeed676da85b178eca3e03b9f9d3f24929233479909a1779fc1/micodag-0.0.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-08 04:05:26",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "micodag"
}