Skip to main content

Implementación del algoritmo para una red Bayesiana.

Project description

Explicación de la funcionalidad de la librería.

La presente librería permite crear y analizar redes bayesianas. Para lo mismo, se necsita crear lo siguiente:

  1. Una red que contenga los nodos y las aristas que se desean analizar de la siguiente forma:

red = { "A": ["B", "C"], "B": [], "C": ["D"], "D": [] }

  1. Una red de probabildades que contenga las probabilidades de cada nodo de la siguiente forma:

probabilidades = { "A": {"distribucion": [0.1, 0.9], "padres": []}, "B": {"distribucion": [0.8, 0.2], "padres": [("A", 0), ("A", 1)]}, # 0.8 = P(B=0|A=0, C=0), 0.2 = P(B=0|A=0, C=1) "C": {"distribucion": [0.7, 0.3], "padres": [("A", 0), ("A", 1)]}, # 0.7 = P(C=0|A=0, C=0), 0.3 = P(C=0|A=0, C=1) "D": {"distribucion": [0.6, 0.4], "padres": [("C", 0), ("C", 1)]} # 0.6 = P(D=0|C=0), 0.4 = P(D=0|C=1) }

  1. Estas dos redes se deben pasar a la librería de BayesianNetwork de la siguiente forma:

bayes = BayesianNetwork(red, probabilidades)

Esto devolverá un texto que indica si la red está completamente descrita o no.

  1. Para calcular la probabilidad de una variable, se debe llamar a la función de la siguiente forma:

Crear un query de la siguiente forma: query = ("A", ("B", 0), ("C", 1), ("D", 0))

Luego, llamar a la función de inferencia de la siguiente forma: bayes.inferencia(red, probabilidades, query)

Con lo anterior se obtiene la probabilidad de la variable A, dada la evidencia de que B=0, C=1 y D=0.

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

RedBayes-0.0.3.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

RedBayes-0.0.3-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file RedBayes-0.0.3.tar.gz.

File metadata

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

File hashes

Hashes for RedBayes-0.0.3.tar.gz
Algorithm Hash digest
SHA256 4965eb4c15e5ba454b55828aca1dc0f8ca7e1a4754aea1bc79ab6cbfdb03a319
MD5 a9803671be0f64adbdfe93bc83f1b31d
BLAKE2b-256 f82103409d6d0d12a86cb4a7f2484667994888e62f472abaacad4590e2fc9e97

See more details on using hashes here.

File details

Details for the file RedBayes-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: RedBayes-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for RedBayes-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f49fe2fe3550ec3e5ac83b8e91c5b186105cd29e091c10268241148831ba93ea
MD5 407592ad3dbe91f7b7984e84353cc1d1
BLAKE2b-256 d5a4655d3bfd17b15b1f2e94af86cb79b4bb47363dba1dd6fcc2e0d2bef9e8c7

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