Skip to main content

BayesNetCreacion

This library has the objective of building Bayesian networks and making probabilistic inference over them. Also, adding some other additional features that could serve the developers that make use of this library.

This library has zero dependencies to assure it is futureproof, easier to debug, to contribute to and use.

For the most part this library works over classes like BayesNetCreacion and Node, this was chosen so that in a way it could facilitate the usage of the OOP paradigm.

For further inquiries you about the usage of the library you can consult Usage section of this repo or the testing python file to see the Burglar Alarm System example being used.

Features

  • Created without using any dependencies/libraries.

  • Can create Bayesian Networks, represented as a dictionary.

  • Calculation of probabilistic inference given the created Bayesian Network.

  • Can check if network is fully defined or not.

  • Has the capability of returning a compact representation of the network as a string.

  • Can return the network's factors as a dictionary.

  • Is able to return the numeration of the network given evidence and a query.

Prerequisites

  • Python 3.10.^

Install

pip install BayesNetCreacion

Usage

from BayesNetCreacion import BayesNetCreacion, Node #Import the library



examplenode = Node('E') #Create a Node object

example2node = Node('E2') #Create another Node object

example2node.set_parents([str(examplenode)]) #Set node as parent



bnc = BayesNetCreacion() #Instantiate the Bayes Network class



#Add both nodes into the network

bnc.add_node(examplenode)

bnc.add_node(example2node) 



#Add the probability values of each node 

bnc.add_prob({

    ('E', True): 0.001,

    ('E', False): 0.999,

    ('E2', True, 'E', True): 0.25,

    ('E2', True, 'E', False): 0.9,

    ('E2', False, 'E', True): 0.75,

    ('E2', False, 'E', False): 0.1

})



#Features:



#Get dictionary with network

bn = bnc.get_network()



#Probabilistic inference

evidence = {'E': True}

query = 'E2'



result = bnc.probabilistic_inference(query, evidence) #Calculate the inference

print(result) #Profit?



#Compact

WIP



#Factors

print(bnc.get_factors())



#Definition Check

WIP



#Enumeration

evidence = {'E': False}

query = 'E2'

result = bnc.pre_enum(query, evidence) #Calculate numeration

print(result)

Author

👤 Andrés de la Roca

Metadata

Release files for BayesNetCreacion 1.2.0

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

Source distribution (sdist)

Source distribution for BayesNetCreacion 1.2.0
File Size Uploaded Provenance Actions
BayesNetCreacion-1.2.0.tar.gz 5.2 kB Without provenance Details for BayesNetCreacion-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for BayesNetCreacion 1.2.0
File Interpreter ABI Platform Actions
BayesNetCreacion-1.2.0-py3-none-any.whl Python 3 none any Details for BayesNetCreacion-1.2.0-py3-none-any.whl

Total release size: 11.4 kB

Release files / BayesNetCreacion-1.2.0.tar.gz

Download URL BayesNetCreacion-1.2.0.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
544b18de0aebdc90b152754392850bbe9a59f4761278f27afe966db81f1ea9df
BLAKE2b-256 checksum
How to use checksums
acf77279a9839ccd5e3dba8d6e50157ebdf7416ecec3be11688fc2264863bc1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / BayesNetCreacion-1.2.0-py3-none-any.whl

Download URL BayesNetCreacion-1.2.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d59054c97782440590f4ddf75f207c8cdf3a5fc035df7411fe991518968d81f1
BLAKE2b-256 checksum
How to use checksums
9a09df9a5f0fc51425c7e0c5f53eedbe37f643a83f4acbfacbdeb69601f2e999
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Security for BayesNetCreacion 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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