{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/135912066","pull_request_review_id":59381388,"id":135912066,"diff_hunk":"@@ -1911,9 +1911,29 @@ def brier_score_loss(y_true, y_prob, sample_weight=None, pos_label=None):\n     y_prob = column_or_1d(y_prob)\n     assert_all_finite(y_true)\n     assert_all_finite(y_prob)\n+    check_consistent_length(y_true, y_prob)\n \n+    if y_prob.max() > 1:\n+        raise ValueError(\"y_prob contains values greater than 1.\")\n+    if y_prob.min() < 0:\n+        raise ValueError(\"y_prob contains values less than 0.\")\n+\n+    # currently, we only support binary classification\n+    classes = np.unique(y_true)\n+    if len(classes) > 2:\n+        raise ValueError(\"Only binary classification is supported.\")\n+\n+    # ensure valid y_true if pos_label is not specified\n     if pos_label is None:\n-        pos_label = y_true.max()\n+        if (np.array_equal(classes, [0]) or\n+           np.array_equal(classes, [-1]) or\n+           np.array_equal(classes, [1])):\n+            pos_label = 1.","path":"sklearn/metrics/classification.py","position":14,"original_position":22,"commit_id":"adfbbec50f326fe0a3678ea29c630269ef258fe1","original_commit_id":"941c57800cd70af64c2156e5fc1c1af2fa45ef06","user":{"login":"amueller","id":449558,"avatar_url":"https://avatars3.githubusercontent.com/u/449558?v=4","gravatar_id":"","url":"https://api.github.com/users/amueller","html_url":"https://github.com/amueller","followers_url":"https://api.github.com/users/amueller/followers","following_url":"https://api.github.com/users/amueller/following{/other_user}","gists_url":"https://api.github.com/users/amueller/gists{/gist_id}","starred_url":"https://api.github.com/users/amueller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amueller/subscriptions","organizations_url":"https://api.github.com/users/amueller/orgs","repos_url":"https://api.github.com/users/amueller/repos","events_url":"https://api.github.com/users/amueller/events{/privacy}","received_events_url":"https://api.github.com/users/amueller/received_events","type":"User","site_admin":false},"body":"I don't understand. That test uses ``pos_label`` right?","created_at":"2017-08-29T21:07:08Z","updated_at":"2017-08-29T21:07:08Z","html_url":"https://github.com/scikit-learn/scikit-learn/pull/9562#discussion_r135912066","pull_request_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/9562","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/135912066"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/9562#discussion_r135912066"},"pull_request":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/9562"}},"in_reply_to_id":133566458},"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/9562","id":135929213,"html_url":"https://github.com/scikit-learn/scikit-learn/pull/9562","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/9562.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/9562.patch","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/9562","number":9562,"state":"open","locked":false,"title":"[MRG] Improvement and bug fix for brier_score_loss","user":{"login":"qinhanmin2014","id":12003569,"avatar_url":"https://avatars2.githubusercontent.com/u/12003569?v=4","gravatar_id":"","url":"https://api.github.com/users/qinhanmin2014","html_url":"https://github.com/qinhanmin2014","followers_url":"https://api.github.com/users/qinhanmin2014/followers","following_url":"https://api.github.com/users/qinhanmin2014/following{/other_user}","gists_url":"https://api.github.com/users/qinhanmin2014/gists{/gist_id}","starred_url":"https://api.github.com/users/qinhanmin2014/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qinhanmin2014/subscriptions","organizations_url":"https://api.github.com/users/qinhanmin2014/orgs","repos_url":"https://api.github.com/users/qinhanmin2014/repos","events_url":"https://api.github.com/users/qinhanmin2014/events{/privacy}","received_events_url":"https://api.github.com/users/qinhanmin2014/received_events","type":"User","site_admin":false},"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\nPartly discussed in #9521  \r\n\r\n#### What does this implement/fix? Explain your changes.\r\nBug fix:\r\n(1)fix a bug where brier_score_loss only support binary classification\r\nbut fail to throw an error for multiclass y_true by @jnothman \r\n(2)fix the calculation of  brier_score_loss when there is only a single class in y_true\r\n```python\r\nbrier_score_loss([0], [0.4])\r\n# output : 0.16\r\nbrier_score_loss([1], [0.4])\r\n# output : 0.16, should be 0.36\r\n```\r\nImprovement:\r\nadd a check to ensure valid y_true if pos_label is not specified by @amueller \r\n(one will need to specify pos_label if y_true only contains one value except for -1 / 0 / 1\r\nwhen 1 is supposed be pos_label)\r\n\r\n#### Any other comments?\r\nregression tests are also added\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","created_at":"2017-08-16T02:30:11Z","updated_at":"2017-08-29T21:07:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d0ba020c4827ddec47661d855de43808d2581311","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/9562/commits","review_comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/9562/comments","review_comment_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/9562/comments","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/adfbbec50f326fe0a3678ea29c630269ef258fe1","head":{"label":"qinhanmin2014:my-feature-2","ref":"my-feature-2","sha":"adfbbec50f326fe0a3678ea29c630269ef258fe1","user":{"login":"qinhanmin2014","id":12003569,"avatar_url":"https://avatars2.githubusercontent.com/u/12003569?v=4","gravatar_id":"","url":"https://api.github.com/users/qinhanmin2014","html_url":"https://github.com/qinhanmin2014","followers_url":"https://api.github.com/users/qinhanmin2014/followers","following_url":"https://api.github.com/users/qinhanmin2014/following{/other_user}","gists_url":"https://api.github.com/users/qinhanmin2014/gists{/gist_id}","starred_url":"https://api.github.com/users/qinhanmin2014/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qinhanmin2014/subscriptions","organizations_url":"https://api.github.com/users/qinhanmin2014/orgs","repos_url":"https://api.github.com/users/qinhanmin2014/repos","events_url":"https://api.github.com/users/qinhanmin2014/events{/privacy}","received_events_url":"https://api.github.com/users/qinhanmin2014/received_events","type":"User","site_admin":false},"repo":{"id":99676558,"name":"scikit-learn","full_name":"qinhanmin2014/scikit-learn","owner":{"login":"qinhanmin2014","id":12003569,"avatar_url":"https://avatars2.githubusercontent.com/u/12003569?v=4","gravatar_id":"","url":"https://api.github.com/users/qinhanmin2014","html_url":"https://github.com/qinhanmin2014","followers_url":"https://api.github.com/users/qinhanmin2014/followers","following_url":"https://api.github.com/users/qinhanmin2014/following{/other_user}","gists_url":"https://api.github.com/users/qinhanmin2014/gists{/gist_id}","starred_url":"https://api.github.com/users/qinhanmin2014/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qinhanmin2014/subscriptions","organizations_url":"https://api.github.com/users/qinhanmin2014/orgs","repos_url":"https://api.github.com/users/qinhanmin2014/repos","events_url":"https://api.github.com/users/qinhanmin2014/events{/privacy}","received_events_url":"https://api.github.com/users/qinhanmin2014/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/qinhanmin2014/scikit-learn","description":"scikit-learn: machine learning in Python","fork":true,"url":"https://api.github.com/repos/qinhanmin2014/scikit-learn","forks_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/forks","keys_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/teams","hooks_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/events","assignees_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/tags","blobs_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/subscription","commits_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/merges","archive_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/downloads","issues_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/releases{/id}","deployments_url":"https://api.github.com/repos/qinhanmin2014/scikit-learn/deployments","created_at":"2017-08-08T09:40:39Z","updated_at":"2017-08-08T09:40:51Z","pushed_at":"2017-08-28T14:45:41Z","git_url":"git://github.com/qinhanmin2014/scikit-learn.git","ssh_url":"git@github.com:qinhanmin2014/scikit-learn.git","clone_url":"https://github.com/qinhanmin2014/scikit-learn.git","svn_url":"https://github.com/qinhanmin2014/scikit-learn","homepage":"http://scikit-learn.org","size":84748,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"scikit-learn:master","ref":"master","sha":"cb16003751e23bf0b1d158a26343f99ebc785571","user":{"login":"scikit-learn","id":365630,"avatar_url":"https://avatars2.githubusercontent.com/u/365630?v=4","gravatar_id":"","url":"https://api.github.com/users/scikit-learn","html_url":"https://github.com/scikit-learn","followers_url":"https://api.github.com/users/scikit-learn/followers","following_url":"https://api.github.com/users/scikit-learn/following{/other_user}","gists_url":"https://api.github.com/users/scikit-learn/gists{/gist_id}","starred_url":"https://api.github.com/users/scikit-learn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scikit-learn/subscriptions","organizations_url":"https://api.github.com/users/scikit-learn/orgs","repos_url":"https://api.github.com/users/scikit-learn/repos","events_url":"https://api.github.com/users/scikit-learn/events{/privacy}","received_events_url":"https://api.github.com/users/scikit-learn/received_events","type":"Organization","site_admin":false},"repo":{"id":843222,"name":"scikit-learn","full_name":"scikit-learn/scikit-learn","owner":{"login":"scikit-learn","id":365630,"avatar_url":"https://avatars2.githubusercontent.com/u/365630?v=4","gravatar_id":"","url":"https://api.github.com/users/scikit-learn","html_url":"https://github.com/scikit-learn","followers_url":"https://api.github.com/users/scikit-learn/followers","following_url":"https://api.github.com/users/scikit-learn/following{/other_user}","gists_url":"https://api.github.com/users/scikit-learn/gists{/gist_id}","starred_url":"https://api.github.com/users/scikit-learn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scikit-learn/subscriptions","organizations_url":"https://api.github.com/users/scikit-learn/orgs","repos_url":"https://api.github.com/users/scikit-learn/repos","events_url":"https://api.github.com/users/scikit-learn/events{/privacy}","received_events_url":"https://api.github.com/users/scikit-learn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scikit-learn/scikit-learn","description":"scikit-learn: machine learning in Python","fork":false,"url":"https://api.github.com/repos/scikit-learn/scikit-learn","forks_url":"https://api.github.com/repos/scikit-learn/scikit-learn/forks","keys_url":"https://api.github.com/repos/scikit-learn/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scikit-learn/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scikit-learn/scikit-learn/teams","hooks_url":"https://api.github.com/repos/scikit-learn/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/events","assignees_url":"https://api.github.com/repos/scikit-learn/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/scikit-learn/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/scikit-learn/scikit-learn/tags","blobs_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/scikit-learn/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/scikit-learn/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/scikit-learn/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/scikit-learn/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/scikit-learn/scikit-learn/subscription","commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/scikit-learn/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/scikit-learn/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scikit-learn/scikit-learn/merges","archive_url":"https://api.github.com/repos/scikit-learn/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scikit-learn/scikit-learn/downloads","issues_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/scikit-learn/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/scikit-learn/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/scikit-learn/scikit-learn/releases{/id}","deployments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/deployments","created_at":"2010-08-17T09:43:38Z","updated_at":"2017-08-29T13:50:12Z","pushed_at":"2017-08-29T20:59:03Z","git_url":"git://github.com/scikit-learn/scikit-learn.git","ssh_url":"git@github.com:scikit-learn/scikit-learn.git","clone_url":"https://github.com/scikit-learn/scikit-learn.git","svn_url":"https://github.com/scikit-learn/scikit-learn","homepage":"http://scikit-learn.org","size":85744,"stargazers_count":20856,"watchers_count":20856,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11190,"mirror_url":null,"open_issues_count":1445,"forks":11190,"open_issues":1445,"watchers":20856,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/9562"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/9562"},"issue":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/9562"},"comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/9562/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/9562/comments"},"review_comment":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/9562/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/adfbbec50f326fe0a3678ea29c630269ef258fe1"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"amueller"}}