{"id":15024114,"url":"https://github.com/sap-archive/bayesian-network-builder","last_synced_at":"2025-10-06T08:31:30.010Z","repository":{"id":47479400,"uuid":"272706448","full_name":"SAP-archive/bayesian-network-builder","owner":"SAP-archive","description":"Domain specific language for modelling dynamic Bayesian networks and estimating posteriors","archived":true,"fork":false,"pushed_at":"2024-07-02T12:54:09.000Z","size":269,"stargazers_count":13,"open_issues_count":2,"forks_count":4,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-12-25T04:17:00.764Z","etag":null,"topics":["bayes","bayesian-inference","bayesian-networks","dsl"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SAP-archive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-16T12:48:54.000Z","updated_at":"2024-07-02T12:54:52.000Z","dependencies_parsed_at":"2024-12-25T04:17:04.103Z","dependency_job_id":"57abe868-4f5e-422e-8705-a8fc6c5c73a1","html_url":"https://github.com/SAP-archive/bayesian-network-builder","commit_stats":null,"previous_names":["sap-archive/bayesian-network-builder","sap/bayesian-network-builder"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP-archive%2Fbayesian-network-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP-archive%2Fbayesian-network-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP-archive%2Fbayesian-network-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP-archive%2Fbayesian-network-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SAP-archive","download_url":"https://codeload.github.com/SAP-archive/bayesian-network-builder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235515424,"owners_count":19002481,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bayes","bayesian-inference","bayesian-networks","dsl"],"created_at":"2024-09-24T19:59:49.046Z","updated_at":"2025-10-06T08:31:24.663Z","avatar_url":"https://github.com/SAP-archive.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Important Notice\n\nThis public repository is read-only and no longer maintained.\n\n![](https://img.shields.io/badge/STATUS-NOT%20CURRENTLY%20MAINTAINED-red.svg?longCache=true\u0026style=flat)\n\n---\n\n\n\u003cimg src=\"https://raw.githubusercontent.com/SAP/bayesian-network-builder/master/docs/logo.png\" width=\"100\"\u003e Bayesian Network Builder \n=====\n\nA [Bayesian Belief Network](https://en.wikipedia.org/wiki/Bayesian_network) (BBN), or simply Bayesian Network, is a statistical model used to describe the [conditional dependencies](https://en.wikipedia.org/wiki/Conditional_dependence) between different random variables.\n\n# Random Variables\n```scala\nimport com.sap.bnb.bn._\nval bool = Flip(.6)\nprintln(bool)\n```\n\n```\nfalse-\u003e.40, true-\u003e.60\n```\n\n```scala\nimport com.sap.bnb.bn._\nval categorical = Cards(\"male\" -\u003e .5,\"female\" -\u003e .5)\n\n```\n\n# Burglary Example\nI'm at work, neighbor John calls to say my alarm is ringing, but\nneighbor Mary doesn't call. Sometimes the alarm is set off by\nminor earthquakes. Both burglary and earthquake are rather rare events.\n\nThe question we want to answer: _**Is there really a burglar at home?**_\n\nConsidering that:\n\n- John always calls when he hears the alarm, but sometimes\n  confuses the telephone ringing with the alarm.\n\n- Mary likes rather loud music and sometimes misses the alarm. \n\n![Burglary](docs/alarm.png)\n```scala\nimport com.sap.bnb.bn._\nimport com.sap.bnb.dsl._\n\nval g = graph {\n \"burglar\" \u003c~ Flip(.001)\n \"earthquake\" \u003c~ Flip(.002)\n \"alarm\" \u003c~ (\"burglar\", \"earthquake\",\n     (true, true) -\u003e Flip(.95),\n     (true, false) -\u003e Flip(.94),\n     (false, true) -\u003e Flip(.29),\n     (false, false) -\u003e Flip(.001))\n  \"alarm\" ~ (true -\u003e Flip(.9), false -\u003e Flip(.05)) ~\u003e \"JohnCalls\"\n  \"alarm\" ~ (true -\u003e Flip(.7), false -\u003e Flip(.01)) ~\u003e \"MaryCalls\"\n}\nval burglar = g.evidences(\"JohnCalls\" -\u003e true, \"MaryCalls\" -\u003e false)\n      .solve(\"burglar\").value.get\nprintln(s\"posterior: $burglar\")\nprintln(\"chances burglary: \" + f\"${burglar.chances(true) * 100}%2.1f%%\")\n```\n\n```\nposterior: true -\u003e .005, false -\u003e .995\nchances burglary: 0,6%\n```\n\n# Dynamic Bayesian Networks\nA Dynamic Bayesian Network (DBN) is a Bayesian network (BN) which relates variables to each other over adjacent time steps. \n![](docs/dbn.png)\n```scala\nimport com.sap.bnb.bn._\nimport com.sap.bnb.dsl._\nval g = graph {\n  \"highPressure\" ~ (true -\u003e Flip(.9), false -\u003e Flip(.2)) ~\u003e \"sunny\"\n  \"sunny\" ~ (true -\u003e Flip(.05), false -\u003e Flip(.8)) ~\u003e \"highHumidity\"\n  \"highHumidity\" ~ (true -\u003e Flip(.2), false -\u003e Flip(.9)) ~~\u003e \"highPressure\"\n}\nval w1 = g.evidences(\"highPressure\" -\u003e true).solve[Boolean](\"sunny\")\nprintln(\"sunny day 1: \" + f\"${w1.value.get.chances(true) * 100}#2.1f%%\") \nval w2 = w1.next.solve[Boolean](\"sunny\")\nprintln(\"sunny day 2: \" + f\"${w2.value.get.chances(true) * 100}#2.1f%%\") \n```\n```\nsunny day 1: 89%\nsunny day 2: 76%\n```\n\n## Get Started\nInstall [sbt](https://www.scala-sbt.org/1.x/docs/Setup.html).\n\n```sbt\nsbt test publishLocal\n```\n\nthen in your sbt project add \n```sbt\nlibraryDependencies += \"com.sap\" % \"bnb\" % \"0.1\"\n```\n\n## Contribute\n\nContributions are welcome!\nIf you're interested please check these two important documents:\n\n* [CONTRIBUTING.md](CONTRIBUTING.md) contains operational details on how to contribute and explains how to engage with the community. If you are new to this project and want to contribute, please start here.\n\n## Contact\n\nContact me under [Giancarlo Frison](https://gfrison.com)\n\n## Licensing \n\nCopyright 2020-2021 SAP SE or an SAP affiliate company and bayesian-network-builder contributors. Please see our [LICENSE](LICENSE) for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/SAP/bayesian-network-builder).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsap-archive%2Fbayesian-network-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsap-archive%2Fbayesian-network-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsap-archive%2Fbayesian-network-builder/lists"}