Skip to main content

Library capable of creating Bayesian Networks and making probabilistic inference over them, as well additional functions

Project description

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.^

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

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

BayesNetCreacion-1.1.4.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

BayesNetCreacion-1.1.4-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file BayesNetCreacion-1.1.4.tar.gz.

File metadata

  • Download URL: BayesNetCreacion-1.1.4.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for BayesNetCreacion-1.1.4.tar.gz
Algorithm Hash digest
SHA256 a68f9fd30d58932959c3a733c2bc2e6c4c9b4b65f5a9dcdd022ccb01bdaee4a1
MD5 a37ad76d1e2add0c709be794c280aa3f
BLAKE2b-256 97b846fe141bb28be810f852b7258aafa7589c6937259f1a2dc56e2a10e4739a

See more details on using hashes here.

File details

Details for the file BayesNetCreacion-1.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for BayesNetCreacion-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8c85c70f219ebcfa7e47714973166249d2b76465701aac453ff6e57a3d30f45f
MD5 62e3ccd6ad98ecc57d2332fa2f0419c6
BLAKE2b-256 d22ed3b2517fc65c095953e9d45dcfd598ebd3e8887df875be3dc6e32c53e61e

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