{"action":"created","issue":{"url":"https://api.github.com/repos/jmschrei/pomegranate/issues/199","repository_url":"https://api.github.com/repos/jmschrei/pomegranate","labels_url":"https://api.github.com/repos/jmschrei/pomegranate/issues/199/labels{/name}","comments_url":"https://api.github.com/repos/jmschrei/pomegranate/issues/199/comments","events_url":"https://api.github.com/repos/jmschrei/pomegranate/issues/199/events","html_url":"https://github.com/jmschrei/pomegranate/issues/199","id":185812794,"number":199,"title":"Divide by Zero during model.predict()","user":{"login":"villanuevab","id":3021974,"avatar_url":"https://avatars.githubusercontent.com/u/3021974?v=3","gravatar_id":"","url":"https://api.github.com/users/villanuevab","html_url":"https://github.com/villanuevab","followers_url":"https://api.github.com/users/villanuevab/followers","following_url":"https://api.github.com/users/villanuevab/following{/other_user}","gists_url":"https://api.github.com/users/villanuevab/gists{/gist_id}","starred_url":"https://api.github.com/users/villanuevab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/villanuevab/subscriptions","organizations_url":"https://api.github.com/users/villanuevab/orgs","repos_url":"https://api.github.com/users/villanuevab/repos","events_url":"https://api.github.com/users/villanuevab/events{/privacy}","received_events_url":"https://api.github.com/users/villanuevab/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-28T00:30:12Z","updated_at":"2016-10-28T18:05:48Z","closed_at":null,"body":"I am experiencing the ff. error:\r\n\r\n```\r\npomegranate_bn/main.py\", line 1651, in <module>\r\n    xhat = bn.predict(eval_assignments)\r\n  File \"pomegranate/BayesianNetwork.pyx\", line 534, in pomegranate.BayesianNetwork.BayesianNetwork.predict (pomegranate/BayesianNetwork.c:9013)\r\n  File \"pomegranate/BayesianNetwork.pyx\", line 401, in pomegranate.BayesianNetwork.BayesianNetwork.predict_proba (pomegranate/BayesianNetwork.c:7620)\r\n  File \"pomegranate/FactorGraph.pyx\", line 346, in pomegranate.FactorGraph.FactorGraph.predict_proba (pomegranate/FactorGraph.c:6548)\r\n  File \"pomegranate/distributions.pyx\", line 2872, in pomegranate.distributions.JointProbabilityTable.marginal (pomegranate/distributions.c:53196)\r\nZeroDivisionError: float division by zero\r\n```\r\n\r\nMy current best guess is that it may be underflow that is causing the divide by zero. There are a few cpd entries that are either very close to 1 or very close to 0, though at first glance the CPDs look normal.\r\n\r\nHere are the estimates provided by model.fit() that inform my hypothesis: \r\n```\r\n\r\n[ {\r\n    \"frozen\" :false,\r\n    \"class\" :\"Distribution\",\r\n    \"parameters\" :[\r\n        {\r\n            \"1\" :0.01997592985172195,\r\n            \"0\" :0.9800240701482781\r\n        }\r\n    ],\r\n    \"name\" :\"DiscreteDistribution\"\r\n}\r\n {\r\n    \"frozen\" :false,\r\n    \"class\" :\"Distribution\",\r\n    \"parameters\" :[\r\n        {\r\n            \"18_to_39\" :0.2779570950600276,\r\n            \"other\" :0.3034284589647708,\r\n            \"40_to_64\" :0.41861444597520164\r\n        }\r\n    ],\r\n    \"name\" :\"DiscreteDistribution\"\r\n}\r\n {\r\n    \"frozen\" :false,\r\n    \"class\" :\"Distribution\",\r\n    \"parameters\" :[\r\n        {\r\n            \"received\" :0.8874494257520664,\r\n            \"not_tested\" :0.00884606064162948,\r\n            \"abnormal\" :0.10370451360630406\r\n        }\r\n    ],\r\n    \"name\" :\"DiscreteDistribution\"\r\n}\r\n {\r\n    \"frozen\" :false,\r\n    \"class\" :\"Distribution\",\r\n    \"parameters\" :[\r\n        {\r\n            \"last_183_days\" :0.08045001057112543,\r\n            \"nc\" :0.024620769974820617,\r\n            \"last_730_days\" :0.8754847041628333,\r\n            \"anytime\" :0.019444515291220616\r\n        }\r\n    ],\r\n    \"name\" :\"DiscreteDistribution\"\r\n}\r\n {\r\n    \"frozen\" :false,\r\n    \"class\" :\"Distribution\",\r\n    \"parameters\" :[\r\n        {\r\n            \"last_183_days\" :0.0003660575851614395,\r\n            \"nc\" :0.00022436103596939293,\r\n            \"last_730_days\" :0.9993938368229136,\r\n            \"anytime\" :1.574455595560028e-05\r\n        }\r\n    ],\r\n    \"name\" :\"DiscreteDistribution\"\r\n}\r\n {\r\n    \"frozen\" :false,\r\n    \"class\" :\"Distribution\",\r\n    \"parameters\" :[\r\n        {\r\n            \"last_183_days\" :0.08620584436867061,\r\n            \"nc\" :0.015293222459225675,\r\n            \"last_730_days\" :0.8243879301941202,\r\n            \"anytime\" :0.07411300297798343\r\n        }\r\n    ],\r\n    \"name\" :\"DiscreteDistribution\"\r\n}\r\n {\r\n    \"frozen\" :false,\r\n    \"class\" :\"Distribution\",\r\n    \"parameters\" :[\r\n        {\r\n            \"last_183_days\" :0.2900160100245165,\r\n            \"nc\" :0.07025382548018391,\r\n            \"last_730_days\" :0.6370968829946763,\r\n            \"anytime\" :0.002633281500623366\r\n        }\r\n    ],\r\n    \"name\" :\"DiscreteDistribution\"\r\n}\r\n {\r\n    \"frozen\" :false,\r\n    \"class\" :\"Distribution\",\r\n    \"parameters\" :[\r\n        {\r\n            \"last_183_days\" :0.3559614807965031,\r\n            \"nc\" :0.07524135675707637,\r\n            \"last_730_days\" :0.5354859232430595,\r\n            \"anytime\" :0.03331123920336089\r\n        }\r\n    ],\r\n    \"name\" :\"DiscreteDistribution\"\r\n}]\r\n```\r\n\r\nWould appreciate input as to whether it is in fact these estimates that contribute to the error. If it could instead be due to missing data / the distribution of data in `eval_assignments`, opinions and recommendations on that would also be appreciated. "},"comment":{"url":"https://api.github.com/repos/jmschrei/pomegranate/issues/comments/256988597","html_url":"https://github.com/jmschrei/pomegranate/issues/199#issuecomment-256988597","issue_url":"https://api.github.com/repos/jmschrei/pomegranate/issues/199","id":256988597,"user":{"login":"jmschrei","id":3916816,"avatar_url":"https://avatars.githubusercontent.com/u/3916816?v=3","gravatar_id":"","url":"https://api.github.com/users/jmschrei","html_url":"https://github.com/jmschrei","followers_url":"https://api.github.com/users/jmschrei/followers","following_url":"https://api.github.com/users/jmschrei/following{/other_user}","gists_url":"https://api.github.com/users/jmschrei/gists{/gist_id}","starred_url":"https://api.github.com/users/jmschrei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmschrei/subscriptions","organizations_url":"https://api.github.com/users/jmschrei/orgs","repos_url":"https://api.github.com/users/jmschrei/repos","events_url":"https://api.github.com/users/jmschrei/events{/privacy}","received_events_url":"https://api.github.com/users/jmschrei/received_events","type":"User","site_admin":false},"created_at":"2016-10-28T18:05:48Z","updated_at":"2016-10-28T18:05:48Z","body":"It is possible that the distributions cause an issue where some combinations are not possible. Basically, the error is coming from trying to normalize each parent set but some parent sets not existing, giving you 0/0. However in that case pomegranate should still not ~fail~ even if the probability is 0. Without an example I can't say for sure what the issue is though. As soon as you post an example I'll look into it."}}
{"actor":{"display_login":"jmschrei"}}