{"id":42253690,"url":"https://github.com/mbforbes/py-factorgraph","last_synced_at":"2026-01-27T05:17:16.658Z","repository":{"id":47798691,"uuid":"56087252","full_name":"mbforbes/py-factorgraph","owner":"mbforbes","description":"Factor graphs and loopy belief propagation implemented in Python","archived":false,"fork":false,"pushed_at":"2022-07-23T15:11:34.000Z","size":449,"stargazers_count":194,"open_issues_count":0,"forks_count":37,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-12-07T04:12:26.541Z","etag":null,"topics":["factor","factor-graph","graph","lbp","loopy-belief-propagation","sum-product"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mbforbes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-12T18:19:37.000Z","updated_at":"2025-09-18T07:24:26.000Z","dependencies_parsed_at":"2022-08-30T09:00:22.622Z","dependency_job_id":null,"html_url":"https://github.com/mbforbes/py-factorgraph","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mbforbes/py-factorgraph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbforbes%2Fpy-factorgraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbforbes%2Fpy-factorgraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbforbes%2Fpy-factorgraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbforbes%2Fpy-factorgraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mbforbes","download_url":"https://codeload.github.com/mbforbes/py-factorgraph/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbforbes%2Fpy-factorgraph/sbom","scorecard":{"id":630938,"data":{"date":"2025-08-11","repo":{"name":"github.com/mbforbes/py-factorgraph","commit":"9306f181a071338878f34ce8e13ce15a7fec46d3"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 1/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/mbforbes/py-factorgraph/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/mbforbes/py-factorgraph/test.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:23","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:24","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:25","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":3,"reason":"7 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2018-34 / GHSA-2fc2-6r4j-p65h","Warn: Project is vulnerable to: PYSEC-2021-856 / GHSA-5545-2q6w-2gh6","Warn: Project is vulnerable to: PYSEC-2019-108 / GHSA-9fq2-x9r6-wfmf","Warn: Project is vulnerable to: PYSEC-2018-33 / GHSA-cw6w-4rcx-xphc","Warn: Project is vulnerable to: PYSEC-2021-857 / GHSA-f7c7-j99h-c22f","Warn: Project is vulnerable to: GHSA-fpfv-jqm9-f5jm","Warn: Project is vulnerable to: PYSEC-2017-1 / GHSA-frgw-fgh6-9g52"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 1 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T07:53:34.483Z","repository_id":47798691,"created_at":"2025-08-21T07:53:34.483Z","updated_at":"2025-08-21T07:53:34.483Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28803650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T03:44:14.111Z","status":"ssl_error","status_checked_at":"2026-01-27T03:43:33.507Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["factor","factor-graph","graph","lbp","loopy-belief-propagation","sum-product"],"created_at":"2026-01-27T05:17:16.047Z","updated_at":"2026-01-27T05:17:16.648Z","avatar_url":"https://github.com/mbforbes.png","language":"Python","readme":"# py-factorgraph\n\n[![Build status](https://github.com/mbforbes/py-factorgraph/actions/workflows/test.yml/badge.svg)](https://github.com/mbforbes/py-factorgraph/actions)\n[![Coverage Status](https://coveralls.io/repos/github/mbforbes/py-factorgraph/badge.svg?branch=master)](https://coveralls.io/github/mbforbes/py-factorgraph?branch=master)\n[![license MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/mbforbes/py-factorgraph/blob/master/LICENSE.txt)\n\nThis is a tiny python library that allows you to build factor graphs and run\nthe (loopy) belief propagation algorithm with ease. It depends only on\n[`numpy`](http://www.numpy.org/).\n\n## Installation\n\n```bash\npip install factorgraph\n```\n\n## Example\n\nCode (found in `examples/simplegraph.py`)\n\n```python\nimport numpy as np\nimport factorgraph as fg\n\n# Make an empty graph\ng = fg.Graph()\n\n# Add some discrete random variables (RVs)\ng.rv('a', 2)\ng.rv('b', 3)\n\n# Add some factors, unary and binary\ng.factor(['a'], potential=np.array([0.3, 0.7]))\ng.factor(['b', 'a'], potential=np.array([\n        [0.2, 0.8],\n        [0.4, 0.6],\n        [0.1, 0.9],\n]))\n\n# Run (loopy) belief propagation (LBP)\niters, converged = g.lbp(normalize=True)\nprint('LBP ran for %d iterations. Converged = %r' % (iters, converged))\nprint()\n\n# Print out the final messages from LBP\ng.print_messages()\nprint()\n\n# Print out the final marginals\ng.print_rv_marginals(normalize=True)\n```\n\nRun with `python -m examples.simplegraph`. Output:\n\n```\nLBP ran for 3 iterations. Converged = True\n\nCurrent outgoing messages:\n\tb -\u003e f(b, a) \t[ 0.33333333  0.33333333  0.33333333]\n\tf(a) -\u003e a \t[ 0.3  0.7]\n\ta -\u003e f(a) \t[ 0.23333333  0.76666667]\n\ta -\u003e f(b, a) \t[ 0.3  0.7]\n\tf(b, a) -\u003e b \t[ 0.34065934  0.2967033   0.36263736]\n\tf(b, a) -\u003e a \t[ 0.23333333  0.76666667]\n\nMarginals for RVs (normalized):\na\n\t 0 \t 0.11538461538461539\n\t 1 \t 0.8846153846153845\nb\n\t 0 \t 0.34065934065934067\n\t 1 \t 0.29670329670329676\n\t 2 \t 0.3626373626373626\n```\n\n## Visualization\n\nYou can use [`factorgraph-viz`](https://github.com/mbforbes/factorgraph-viz) to\nvisualize factor graphs interactively in your web browser.\n\n[![An example rendering of a factor graph using the factorgraph-viz library](factorgraph-viz.png)](https://github.com/mbforbes/factorgraph-viz)\n\n## Tests\n\n```bash\npip install pytest-cov coveralls\npy.test --cov=factorgraph tests/\n```\n\n## Projects using `py-factorgraph`\n\n_Open an issue or send a PR if you'd like your project listed here._\n\n- [verbphysics](https://github.com/uwnlp/verbphysics)\n\n## Contributing\n\nThere's plenty of low-hanging fruit to work on if you'd like to contribute to\nthis project. Here are some ideas:\n\n- [ ] Unit tests\n- [ ] Auto-generated python docs (what's popular these days?)\n- [ ] Performance: measure bottlenecks and improve them (ideas: numba;\n  parallelization for large graphs;)\n- [ ] Remove or improve ctrl-C catching (the `E_STOP`)\n- [ ] Cleaning up the API (essentially duplicate constructors for `RV`s and\n  `Factor`s within the `Graph` code; probably should have a node superclass for\n  `RV`s and `Factor`s that pulls out common code).\n\n## Releasing\n\nNotes for myself on how to release new versions:\n\n```bash\n# Bump version in setup.py. Then,\npython setup.py sdist\npip install twine\ntwine upload dist/*\n```\n\n## Thanks\n\n- to Matthew R. Gormley and Jason Eisner for the [Structured Belief Propagation\n  for NLP Tutorial](https://www.cs.cmu.edu/~mgormley/bp-tutorial/), which was\n  extremely helpful for me in learning about factor graphs and understanding\n  the sum product algorithm.\n\n- to Ryan Lester for [pyfac](https://github.com/rdlester/pyfac), whose tests I\n  used directly to test my implementation\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbforbes%2Fpy-factorgraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmbforbes%2Fpy-factorgraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbforbes%2Fpy-factorgraph/lists"}