{"id":17726960,"url":"https://github.com/fs02/pgm-plus","last_synced_at":"2025-10-28T05:35:16.167Z","repository":{"id":152367309,"uuid":"83988469","full_name":"Fs02/PGM-plus","owner":"Fs02","description":"A C++ Probabilistic Graphical Model Library","archived":false,"fork":false,"pushed_at":"2017-07-21T02:00:07.000Z","size":95,"stargazers_count":6,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-05-01T12:16:47.612Z","etag":null,"topics":["bayesian-network","pgm"],"latest_commit_sha":null,"homepage":null,"language":"C++","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/Fs02.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-05T17:25:26.000Z","updated_at":"2024-02-23T02:11:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"77e80f0b-3a40-45a4-8e07-e9f6e4f84156","html_url":"https://github.com/Fs02/PGM-plus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fs02%2FPGM-plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fs02%2FPGM-plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fs02%2FPGM-plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fs02%2FPGM-plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fs02","download_url":"https://codeload.github.com/Fs02/PGM-plus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243538060,"owners_count":20307100,"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":["bayesian-network","pgm"],"created_at":"2024-10-25T17:22:15.975Z","updated_at":"2025-10-28T05:35:11.120Z","avatar_url":"https://github.com/Fs02.png","language":"C++","readme":"# PGM-plus\nA C++ Probabilistic Graphical Model Library\n\n## Features\nScoring Function:\n- Akaike Information Criterion (AIC)\n- Bayesian Dirichlet equivalent uniform (BDeu)\n- Bayesian Information Criterion (BIC)\n- Factorized Conditional Log Likelihood (fCLL)\n- Log Likelihood\n\nSearch Algorithm:\n- Greedy Hill Climbing\n- Simulated Annealing\n\nInference:\n- Brute force\n\n## Usage\nThe easiest way to use this library is to include and compile alongside your project.\n\n## Example\n```\n#include \u003cstring\u003e\n#include \u003cpgm/pgm.h\u003e\n#include \u003ccmath\u003e\n#include \u003ciostream\u003e\n\nint main()\n{\n    // bayesnet\n    pgm::Bayesnet bn;\n    bn.add_node(\"A\", {\"F\", \"T\"});\n    bn.add_node(\"B\", {\"F\", \"T\"});\n    bn.add_node(\"C\", {\"F\", \"T\"});\n    bn.add_node(\"D\", {\"F\", \"T\"});\n    bn.add_node(\"E\", {\"F\", \"T\"});\n\n    // dataset\n    pgm::Dataset dataset;\n    for (std::size_t i = 0; i \u003c 20; ++i)\n        dataset.push({{\"A\", \"T\"}, {\"B\", \"F\"}, {\"C\", \"T\"}, {\"D\", \"T\"}, {\"E\", \"T\"}});\n\n    for (std::size_t i = 0; i \u003c 15; ++i)\n        dataset.push({{\"A\", \"T\"}, {\"B\", \"F\"}, {\"C\", \"F\"}, {\"D\", \"F\"}, {\"E\", \"F\"}});\n\n    for (std::size_t i = 0; i \u003c 10; ++i)\n        dataset.push({{\"A\", \"F\"}, {\"B\", \"T\"}, {\"C\", \"F\"}, {\"D\", \"T\"}, {\"E\", \"T\"}});\n\n    for (std::size_t i = 0; i \u003c 15; ++i)\n        dataset.push({{\"A\", \"F\"}, {\"B\", \"F\"}, {\"C\", \"T\"}, {\"D\", \"T\"}, {\"E\", \"T\"}});\n\n    for (std::size_t i = 0; i \u003c 5; ++i)\n        dataset.push({{\"A\", \"F\"}, {\"B\", \"F\"}, {\"C\", \"F\"}, {\"D\", \"F\"}, {\"E\", \"F\"}});\n\n    for (std::size_t i = 0; i \u003c 2; ++i)\n        dataset.push({{\"A\", \"T\"}, {\"B\", \"T\"}, {\"C\", \"F\"}, {\"D\", \"T\"}, {\"E\", \"F\"}});\n\n    // Train with simulated annealing and factorized conditional log likelihood\n    pgm::SimulatedAnnealing annealing;\n    annealing.verbose(true);\n    annealing.init_as_naive_bayes(\"A\");\n    pgm::Fcll score(dataset, \"A\");\n    pgm::SampleEstimate estimate;\n\n    annealing(bn, score);\n    estimate(bn, dataset);\n\n    std::cout \u003c\u003c bn;\n\n    // predict\n    std::size_t correct = 0;\n    for (std::size_t i = 0; i \u003c dataset.size(); ++i)\n    {\n        auto row = dataset[i];\n        if (row[\"A\"] == bn.infer(\"A\", row))\n            ++correct;\n    }\n    std::cout \u003c\u003c \"Correct : \" \u003c\u003c correct \u003c\u003c \"/\" \u003c\u003c dataset.size() \u003c\u003c \"\\n\";\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffs02%2Fpgm-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffs02%2Fpgm-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffs02%2Fpgm-plus/lists"}