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 Bayes de la siguiente forma:

bayes = Bayes(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

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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: jbnetwork-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 jbnetwork-0.0.3.tar.gz
Algorithm Hash digest
SHA256 260f4febf0a2f40a0245844a665f3db5e2ef78be3d73cf7c6c7252f163334c03
MD5 2069616b6f6b54ff945c3b163b5d1928
BLAKE2b-256 653a8214b2aeded28f284ebf77f22ee18b26adbeb29844ca0d4d40aabfd4663a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jbnetwork-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 jbnetwork-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0e5f28e166b40e2652e5d0079fffdd7df5342acebbef0b2d4a200dae3a3295bf
MD5 2273dd5cf482c72e1d9a5e0f6ea79390
BLAKE2b-256 e06e59c5e687cbe45fc4ead594fb44cfd3452c0503b710617f4306b479a171e0

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