Skip to main content

Conditional Tree Bayesian Network for multi-label classification

Project description

Conditional Tree Bayesian Network

This package can be used as a library to fit a Conditional Tree Bayesian Network (CTBN)[1].

The main module is the CTBN class.

  1. Use the fit() method to fit the CTBN to your multi-label classification data [1]. This method generates an optimal CTBN which is an instance of DirectedGraph using the Chu-Liu-Edmond's algorithm for finding a maximum spanning arborescence [2].
  2. The predict() method returns the most likely assignment to the class variables along with the probability of the assignment. The predict method uses the junction tree algorithm[3] to run the most likely explanation(MLE) query.

Usage

An example of using the package can be found in the jupyter notebook here.

# Import the CTBN class and assuming you have a dataset X_train and Y_train which are numpy arrays.
from ctbn import CTBN
model = CTBN()
model.fit(X_train, Y_train)

#Calling the fit method will generate an optimal CTBN graph of type
#DirectedGraph defined in src/graph_preliminaries.py

#Get predictions and the probability of a prediction on a single sample
#using the predict method. This method will in turn call the junction tree
#algorithm to run the max-sum algorithm on a test_sample.

max_log_prob, max_assignment = model.predict(test_sample)

References

[1] Batal, Iyad and Hong, Charmgil and Hauskrecht, Milos (2013). An Efficient Probabilistic Framework for Multi-Dimensional Classification. In Proceedings of the 22nd ACM International Conference on Information amp; Knowledge Management, CIKM ’13, New York, NY,USA, pp. 2417–2422. Association for Computing Machinery. https://doi.org/10.1145/2505515.2505594

[2] Chu, Y. J. and T. H. Liu, "On the Shortest Arborescence of a Directed Graph," Sci. Sinica, 14, 1965, pp. 1396-1400.

[3] Koller, D., & Friedman, N. (2009). Probabilistic Graphical Models: Principles and Techniques. MIT Press.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

CTBN-0.0.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

CTBN-0.0.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file CTBN-0.0.1.tar.gz.

File metadata

  • Download URL: CTBN-0.0.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.10

File hashes

Hashes for CTBN-0.0.1.tar.gz
Algorithm Hash digest
SHA256 94e97ad04ae4672abafb23ac2aea892a012ee560f2d46d2bd6f79f88de594719
MD5 37636cdb726c2f634aa0442894b2bd74
BLAKE2b-256 5768ff71cc2cea5083fa5e13530916a07dca84f143e50a11749e9007ccc53fbe

See more details on using hashes here.

File details

Details for the file CTBN-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: CTBN-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.10

File hashes

Hashes for CTBN-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 260364f8fc6622d8cf4dc0c25f064197c8b384f13c363964a6528c6472d497b5
MD5 e23743a2258dda7c1e1dd73bba1d48e3
BLAKE2b-256 1e0c5e22036930d521761dc2f60b0c19c3fe5ad81e2c85536d72923988170178

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page