{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/8280","repository_url":"https://api.github.com/repos/scikit-learn/scikit-learn","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/8280/labels{/name}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/8280/comments","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/8280/events","html_url":"https://github.com/scikit-learn/scikit-learn/pull/8280","id":205056543,"number":8280,"title":"[MRG+1] Bugfix for precision_recall_curve when all labels are negative","user":{"login":"varunagrawal","id":975964,"avatar_url":"https://avatars1.githubusercontent.com/u/975964?v=3","gravatar_id":"","url":"https://api.github.com/users/varunagrawal","html_url":"https://github.com/varunagrawal","followers_url":"https://api.github.com/users/varunagrawal/followers","following_url":"https://api.github.com/users/varunagrawal/following{/other_user}","gists_url":"https://api.github.com/users/varunagrawal/gists{/gist_id}","starred_url":"https://api.github.com/users/varunagrawal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/varunagrawal/subscriptions","organizations_url":"https://api.github.com/users/varunagrawal/orgs","repos_url":"https://api.github.com/users/varunagrawal/repos","events_url":"https://api.github.com/users/varunagrawal/events{/privacy}","received_events_url":"https://api.github.com/users/varunagrawal/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2017-02-03T02:30:55Z","updated_at":"2017-03-30T04:19:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/8280","html_url":"https://github.com/scikit-learn/scikit-learn/pull/8280","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/8280.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/8280.patch"},"body":"<!--\r\nThanks for contributing a pull request! Please ensure you have taken a look at\r\nthe contribution guidelines: https://github.com/scikit-learn/scikit-learn/blob/master/CONTRIBUTING.md#Contributing-Pull-Requests\r\n-->\r\n#### Reference Issue\r\n<!-- Example: Fixes #1234 -->\r\nFixes #8245 \r\n\r\n#### What does this implement/fix? Explain your changes.\r\nWhen all the `y_true` labels are negative, `precision_recall_curve` returns `nan` because of `recall` being set to `nan` instead of `1`. This is because of the direction division of the `tps` vector by `tps[-1]` which happens to be `0`.\r\n\r\nThis fix checks if `tps[-1]` is `0` and if yes, sets the recall to `1` directly since there are no True Positives or False Negatives, else we calculate `recall` as normal.\r\n\r\n\r\n#### Any other comments?\r\nI had to update `test_precision_recall_curve_toydata` since this test was expecting the `TrueDivide` exception to be raised which is no longer the case as a result of this fix. I added 2 test cases, one to check when all truth labels are negative and the other to check when all truth labels are positive to ensure precision calculation is accurate.\r\n\r\n<!--\r\nPlease be aware that we are a loose team of volunteers so patience is\r\nnecessary; assistance handling other issues is very welcome. We value\r\nall user contributions, no matter how minor they are. If we are slow to\r\nreview, either the pull request needs some benchmarking, tinkering,\r\nconvincing, etc. or more likely the reviewers are simply busy. In either\r\ncase, we ask for your understanding during the review process.\r\nFor more information, see our FAQ on this topic:\r\nhttp://scikit-learn.org/dev/faq.html#why-is-my-pull-request-not-getting-any-attention.\r\n\r\nThanks for contributing!\r\n-->\r\n"},"comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/comments/290298154","html_url":"https://github.com/scikit-learn/scikit-learn/pull/8280#issuecomment-290298154","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/8280","id":290298154,"user":{"login":"jnothman","id":78827,"avatar_url":"https://avatars1.githubusercontent.com/u/78827?v=3","gravatar_id":"","url":"https://api.github.com/users/jnothman","html_url":"https://github.com/jnothman","followers_url":"https://api.github.com/users/jnothman/followers","following_url":"https://api.github.com/users/jnothman/following{/other_user}","gists_url":"https://api.github.com/users/jnothman/gists{/gist_id}","starred_url":"https://api.github.com/users/jnothman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnothman/subscriptions","organizations_url":"https://api.github.com/users/jnothman/orgs","repos_url":"https://api.github.com/users/jnothman/repos","events_url":"https://api.github.com/users/jnothman/events{/privacy}","received_events_url":"https://api.github.com/users/jnothman/received_events","type":"User","site_admin":false},"created_at":"2017-03-30T04:19:05Z","updated_at":"2017-03-30T04:19:05Z","body":"Haven't had much time for reviewing, and I expect little availability for the next couple of weeks. Please be patient, and ping again if necessary."}}
{"actor":{"display_login":"jnothman"}}