{"action":"created","issue":{"url":"https://api.github.com/repos/yamasakih/predictiveness-curve/issues/56","repository_url":"https://api.github.com/repos/yamasakih/predictiveness-curve","labels_url":"https://api.github.com/repos/yamasakih/predictiveness-curve/issues/56/labels{/name}","comments_url":"https://api.github.com/repos/yamasakih/predictiveness-curve/issues/56/comments","events_url":"https://api.github.com/repos/yamasakih/predictiveness-curve/issues/56/events","html_url":"https://github.com/yamasakih/predictiveness-curve/issues/56","id":467773825,"node_id":"MDU6SXNzdWU0Njc3NzM4MjU=","number":56,"title":"plot_predictiveness_curve function raises ZeroDivisionError","user":{"login":"yamasakih","id":10294378,"node_id":"MDQ6VXNlcjEwMjk0Mzc4","avatar_url":"https://avatars3.githubusercontent.com/u/10294378?v=4","gravatar_id":"","url":"https://api.github.com/users/yamasakih","html_url":"https://github.com/yamasakih","followers_url":"https://api.github.com/users/yamasakih/followers","following_url":"https://api.github.com/users/yamasakih/following{/other_user}","gists_url":"https://api.github.com/users/yamasakih/gists{/gist_id}","starred_url":"https://api.github.com/users/yamasakih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yamasakih/subscriptions","organizations_url":"https://api.github.com/users/yamasakih/orgs","repos_url":"https://api.github.com/users/yamasakih/repos","events_url":"https://api.github.com/users/yamasakih/events{/privacy}","received_events_url":"https://api.github.com/users/yamasakih/received_events","type":"User","site_admin":false},"labels":[{"id":1393040064,"node_id":"MDU6TGFiZWwxMzkzMDQwMDY0","url":"https://api.github.com/repos/yamasakih/predictiveness-curve/labels/bug","name":"bug","color":"d73a4a","default":true}],"state":"open","locked":false,"assignee":{"login":"yamasakih","id":10294378,"node_id":"MDQ6VXNlcjEwMjk0Mzc4","avatar_url":"https://avatars3.githubusercontent.com/u/10294378?v=4","gravatar_id":"","url":"https://api.github.com/users/yamasakih","html_url":"https://github.com/yamasakih","followers_url":"https://api.github.com/users/yamasakih/followers","following_url":"https://api.github.com/users/yamasakih/following{/other_user}","gists_url":"https://api.github.com/users/yamasakih/gists{/gist_id}","starred_url":"https://api.github.com/users/yamasakih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yamasakih/subscriptions","organizations_url":"https://api.github.com/users/yamasakih/orgs","repos_url":"https://api.github.com/users/yamasakih/repos","events_url":"https://api.github.com/users/yamasakih/events{/privacy}","received_events_url":"https://api.github.com/users/yamasakih/received_events","type":"User","site_admin":false},"assignees":[{"login":"yamasakih","id":10294378,"node_id":"MDQ6VXNlcjEwMjk0Mzc4","avatar_url":"https://avatars3.githubusercontent.com/u/10294378?v=4","gravatar_id":"","url":"https://api.github.com/users/yamasakih","html_url":"https://github.com/yamasakih","followers_url":"https://api.github.com/users/yamasakih/followers","following_url":"https://api.github.com/users/yamasakih/following{/other_user}","gists_url":"https://api.github.com/users/yamasakih/gists{/gist_id}","starred_url":"https://api.github.com/users/yamasakih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yamasakih/subscriptions","organizations_url":"https://api.github.com/users/yamasakih/orgs","repos_url":"https://api.github.com/users/yamasakih/repos","events_url":"https://api.github.com/users/yamasakih/events{/privacy}","received_events_url":"https://api.github.com/users/yamasakih/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/yamasakih/predictiveness-curve/milestones/3","html_url":"https://github.com/yamasakih/predictiveness-curve/milestone/3","labels_url":"https://api.github.com/repos/yamasakih/predictiveness-curve/milestones/3/labels","id":4449062,"node_id":"MDk6TWlsZXN0b25lNDQ0OTA2Mg==","number":3,"title":"v0.2.2","description":"","creator":{"login":"yamasakih","id":10294378,"node_id":"MDQ6VXNlcjEwMjk0Mzc4","avatar_url":"https://avatars3.githubusercontent.com/u/10294378?v=4","gravatar_id":"","url":"https://api.github.com/users/yamasakih","html_url":"https://github.com/yamasakih","followers_url":"https://api.github.com/users/yamasakih/followers","following_url":"https://api.github.com/users/yamasakih/following{/other_user}","gists_url":"https://api.github.com/users/yamasakih/gists{/gist_id}","starred_url":"https://api.github.com/users/yamasakih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yamasakih/subscriptions","organizations_url":"https://api.github.com/users/yamasakih/orgs","repos_url":"https://api.github.com/users/yamasakih/repos","events_url":"https://api.github.com/users/yamasakih/events{/privacy}","received_events_url":"https://api.github.com/users/yamasakih/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":16,"state":"open","created_at":"2019-06-28T13:29:37Z","updated_at":"2019-07-13T22:48:06Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2019-07-13T22:48:06Z","updated_at":"2019-07-13T23:11:05Z","closed_at":null,"author_association":"OWNER","body":"```python\r\nscores = np.array([10, 9, 5, 1, 8, 7, 6, 4, 3, 2])\r\nlabels = np.zeros((10, ), dtype='int32')\r\nlabels[:4] = 1\r\n    \r\nfig = plot_predictiveness_curve(scores, labels, kind='EF')\r\n---------------------------------------------------------------------------\r\nZeroDivisionError                         Traceback (most recent call last)\r\n<ipython-input-33-76a20ab8dc06> in <module>()\r\n----> 1 fig = plot_predictiveness_curve(scores, labels, kind='EF')\r\n\r\n~/repositories/predictiveness-curve/predictiveness_curve/base.py in plot_predictiveness_curve(risks, labels, classes, normalize, points, figsize, fontsize, kind, xlabel, top_ylabel, bottom_ylabel, **kwargs)\r\n    155         enrichment_factors = calculate_enrichment_factor(risks,\r\n    156                                                          labels,\r\n--> 157                                                          threshold=thresholds)\r\n    158         _set_axes(ax, lim, fontsize)\r\n    159         ax.plot(thresholds, enrichment_factors, **kwargs)\r\n\r\n~/repositories/predictiveness-curve/predictiveness_curve/base.py in calculate_enrichment_factor(scores, labels, classes, threshold)\r\n    226 \r\n    227     _calculate_enrichment_factor = np.frompyfunc(f, 1, 1)\r\n--> 228     return _calculate_enrichment_factor(threshold)\r\n    229 \r\n    230 \r\n\r\n~/repositories/predictiveness-curve/predictiveness_curve/base.py in f(threshold)\r\n    197     def f(threshold):\r\n    198         n = int(np.floor(scores.size * threshold))\r\n--> 199         return (np.count_nonzero(labels[-n:]) / n) / positive_ratio\r\n    200 \r\n    201     scores = np.array(scores)\r\n```"},"comment":{"url":"https://api.github.com/repos/yamasakih/predictiveness-curve/issues/comments/511160155","html_url":"https://github.com/yamasakih/predictiveness-curve/issues/56#issuecomment-511160155","issue_url":"https://api.github.com/repos/yamasakih/predictiveness-curve/issues/56","id":511160155,"node_id":"MDEyOklzc3VlQ29tbWVudDUxMTE2MDE1NQ==","user":{"login":"yamasakih","id":10294378,"node_id":"MDQ6VXNlcjEwMjk0Mzc4","avatar_url":"https://avatars3.githubusercontent.com/u/10294378?v=4","gravatar_id":"","url":"https://api.github.com/users/yamasakih","html_url":"https://github.com/yamasakih","followers_url":"https://api.github.com/users/yamasakih/followers","following_url":"https://api.github.com/users/yamasakih/following{/other_user}","gists_url":"https://api.github.com/users/yamasakih/gists{/gist_id}","starred_url":"https://api.github.com/users/yamasakih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yamasakih/subscriptions","organizations_url":"https://api.github.com/users/yamasakih/orgs","repos_url":"https://api.github.com/users/yamasakih/repos","events_url":"https://api.github.com/users/yamasakih/events{/privacy}","received_events_url":"https://api.github.com/users/yamasakih/received_events","type":"User","site_admin":false},"created_at":"2019-07-13T23:11:05Z","updated_at":"2019-07-13T23:11:05Z","author_association":"OWNER","body":"Variable n became zero when score size and threshold were very small.\r\n\r\n```python\r\n    def f(threshold):\r\n        n = int(np.floor(scores.size * threshold))\r\n        return (np.count_nonzero(labels[-n:]) / n) / positive_ratio\r\n```"}}
{"actor":{"display_login":"yamasakih"}}