{"action":"created","issue":{"url":"https://api.github.com/repos/pgmpy/pgmpy/issues/378","labels_url":"https://api.github.com/repos/pgmpy/pgmpy/issues/378/labels{/name}","comments_url":"https://api.github.com/repos/pgmpy/pgmpy/issues/378/comments","events_url":"https://api.github.com/repos/pgmpy/pgmpy/issues/378/events","html_url":"https://github.com/pgmpy/pgmpy/pull/378","id":68982899,"number":378,"title":"Efficient factor product","user":{"login":"jhonatanoliveira","id":3395429,"avatar_url":"https://avatars.githubusercontent.com/u/3395429?v=3","gravatar_id":"","url":"https://api.github.com/users/jhonatanoliveira","html_url":"https://github.com/jhonatanoliveira","followers_url":"https://api.github.com/users/jhonatanoliveira/followers","following_url":"https://api.github.com/users/jhonatanoliveira/following{/other_user}","gists_url":"https://api.github.com/users/jhonatanoliveira/gists{/gist_id}","starred_url":"https://api.github.com/users/jhonatanoliveira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhonatanoliveira/subscriptions","organizations_url":"https://api.github.com/users/jhonatanoliveira/orgs","repos_url":"https://api.github.com/users/jhonatanoliveira/repos","events_url":"https://api.github.com/users/jhonatanoliveira/events{/privacy}","received_events_url":"https://api.github.com/users/jhonatanoliveira/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-04-16T18:29:25Z","updated_at":"2015-04-18T01:58:32Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pgmpy/pgmpy/pulls/378","html_url":"https://github.com/pgmpy/pgmpy/pull/378","diff_url":"https://github.com/pgmpy/pgmpy/pull/378.diff","patch_url":"https://github.com/pgmpy/pgmpy/pull/378.patch"},"body":"A factor product following \"Probabilistic Graphical Models\" (Koller 09) on page 359, Algorithm 10.A.1 - Efficient implementation of a factor product operation.\r\nKoller's algorithm was modified to fit the configuration used in pgmpy. For example, in pgmpy the configurations of Factor are supposed to be like (0,0,0) (0,0,1) (0,1,0) (1,0,0) and so on, instead of (0,0,0) (1,0,0) (0,1,0) (0,0,1) as expected for Koller's algorithm.\r\n\r\nKoller's implementation is around 98% faster than the current one in pgmpy. This benchmark was done by using a simple python script as follows:\r\n\r\n    from pgmpy.factors import Factor\r\n    from pgmpy.factors import factor_product\r\n    from time import time\r\n\r\n    phi = Factor(['x1', 'x2'], [2, 2], range(4))\r\n    phi1 = Factor(['x3', 'x4'], [2, 2], range(4))\r\n    t0 = time()\r\n    prod = factor_product(phi, phi1)\r\n    t1 = time()\r\n    print(t1-t0)\r\n\r\nAfter running 6 time each implementation, here is the results:\r\n\r\n<img src=\"https://cloud.githubusercontent.com/assets/3395429/7188269/ad75ccd0-e433-11e4-8f32-7e4586a2f439.png\" alt=\"Comparison\" width=\"400\">\r\n\r\nUnfortunately, we don't know how to use *JobLib*. But we leave this **TODO** with the hope that using parallel computation can improve  this implementation even further."},"comment":{"url":"https://api.github.com/repos/pgmpy/pgmpy/issues/comments/94113225","html_url":"https://github.com/pgmpy/pgmpy/pull/378#issuecomment-94113225","issue_url":"https://api.github.com/repos/pgmpy/pgmpy/issues/378","id":94113225,"user":{"login":"landscape-bot","id":10010231,"avatar_url":"https://avatars.githubusercontent.com/u/10010231?v=3","gravatar_id":"","url":"https://api.github.com/users/landscape-bot","html_url":"https://github.com/landscape-bot","followers_url":"https://api.github.com/users/landscape-bot/followers","following_url":"https://api.github.com/users/landscape-bot/following{/other_user}","gists_url":"https://api.github.com/users/landscape-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/landscape-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/landscape-bot/subscriptions","organizations_url":"https://api.github.com/users/landscape-bot/orgs","repos_url":"https://api.github.com/users/landscape-bot/repos","events_url":"https://api.github.com/users/landscape-bot/events{/privacy}","received_events_url":"https://api.github.com/users/landscape-bot/received_events","type":"User","site_admin":false},"created_at":"2015-04-18T01:58:32Z","updated_at":"2015-04-18T01:58:32Z","body":"[![Code Health](https://landscape.io/badge/147583/landscape.svg?style=flat)](https://landscape.io/diff/134385)\nRepository health decreased by 0.31% when pulling **[3df07fa](https://github.com/jhonatanoliveira/pgmpy/commit/3df07fa2d15b5dff142a179d1d2022143080a91c) on jhonatanoliveira:efficient-factor-manipulation** into **[2403efe](https://github.com/pgmpy/pgmpy/commit/2403efef43831a5b3e446fc0b612c784bbb1d6b7) on pgmpy:dev**.\n\n * [12 new problems were found](https://landscape.io/diff/134385) (including 0 errors and 0 code smells).\n * No problems were fixed."}}