GitHub PullRequestReviewCommentEvent at 2014-09-18 03:49:08
Repository: scikit-learn
Actor: ogrisel
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/17708095","id":17708095,"diff_hunk":"@@ -79,12 +97,20 @@ def predict(self, X):\n \n class LogOddsEstimator(BaseEstimator):\n     \"\"\"An estimator predicting the log odds ratio.\"\"\"\n-    def fit(self, X, y):\n-        n_pos = np.sum(y)\n-        n_neg = y.shape[0] - n_pos\n-        if n_neg == 0 or n_pos == 0:\n+    scale = 1.0\n+\n+    def fit(self, X, y, sample_weight=None):\n+        # pre-cond: pos, neg are encoded as 1, 0\n+        if sample_weight is None:\n+            pos = np.sum(y)\n+            neg = y.shape[0] - pos\n+        else:\n+            pos = np.sum(sample_weight * y)\n+            neg = np.sum(sample_weight * (1 - y))","path":"sklearn/ensemble/gradient_boosting.py","position":64,"original_position":64,"commit_id":"2d503283d3b1a9b08a54626837c88bcb9fadc158","original_commit_id":"2d503283d3b1a9b08a54626837c88bcb9fadc158","user":{"login":"ogrisel","id":89061,"avatar_url":"https://avatars.githubusercontent.com/u/89061?v=2","gravatar_id":"aee56554ec30edfd680e1c937ed4e54d","url":"https://api.github.com/users/ogrisel","html_url":"https://github.com/ogrisel","followers_url":"https://api.github.com/users/ogrisel/followers","following_url":"https://api.github.com/users/ogrisel/following{/other_user}","gists_url":"https://api.github.com/users/ogrisel/gists{/gist_id}","starred_url":"https://api.github.com/users/ogrisel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ogrisel/subscriptions","organizations_url":"https://api.github.com/users/ogrisel/orgs","repos_url":"https://api.github.com/users/ogrisel/repos","events_url":"https://api.github.com/users/ogrisel/events{/privacy}","received_events_url":"https://api.github.com/users/ogrisel/received_events","type":"User","site_admin":false},"body":"`np.average` might spare a memory allocation. Not a big deal though,","created_at":"2014-09-18T03:49:08Z","updated_at":"2014-09-18T03:49:08Z","html_url":"https://github.com/scikit-learn/scikit-learn/pull/3224#discussion_r17708095","pull_request_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3224","_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/17708095"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/3224#discussion_r17708095"},"pull_request":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3224"}}},"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3224","id":16553050,"html_url":"https://github.com/scikit-learn/scikit-learn/pull/3224","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/3224.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/3224.patch","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/3224","number":3224,"state":"open","locked":false,"title":"[MRG] Sample weights for gradient boosting","user":{"login":"pprett","id":111730,"avatar_url":"https://avatars.githubusercontent.com/u/111730?v=2","gravatar_id":"c9e2eeace0c2f0dcc21cfca626fd1797","url":"https://api.github.com/users/pprett","html_url":"https://github.com/pprett","followers_url":"https://api.github.com/users/pprett/followers","following_url":"https://api.github.com/users/pprett/following{/other_user}","gists_url":"https://api.github.com/users/pprett/gists{/gist_id}","starred_url":"https://api.github.com/users/pprett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pprett/subscriptions","organizations_url":"https://api.github.com/users/pprett/orgs","repos_url":"https://api.github.com/users/pprett/repos","events_url":"https://api.github.com/users/pprett/events{/privacy}","received_events_url":"https://api.github.com/users/pprett/received_events","type":"User","site_admin":false},"body":"and piggy-packed ``'exponential'`` loss for binary classification (= AdaBoost).\r\n\r\n~~I didn't implement sample weights for ``'lad'``, ``'huber'``, and ``'quantile'`` since it would require weighted median / percentiles. I will either raise a warning or exception in this case: what do you prefer?~~\r\n\r\ncc @glouppe\r\n\r\nTODO: ~~benchmark benchmark and some regression tests~~","created_at":"2014-05-30T20:23:15Z","updated_at":"2014-09-18T03:49:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7d7f0e293a258d66f85c2630054476fb2b4b0844","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3224/commits","review_comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3224/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/3224/comments","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/2d503283d3b1a9b08a54626837c88bcb9fadc158","head":{"label":"pprett:gbrt-sample-weight","ref":"gbrt-sample-weight","sha":"2d503283d3b1a9b08a54626837c88bcb9fadc158","user":{"login":"pprett","id":111730,"avatar_url":"https://avatars.githubusercontent.com/u/111730?v=2","gravatar_id":"c9e2eeace0c2f0dcc21cfca626fd1797","url":"https://api.github.com/users/pprett","html_url":"https://github.com/pprett","followers_url":"https://api.github.com/users/pprett/followers","following_url":"https://api.github.com/users/pprett/following{/other_user}","gists_url":"https://api.github.com/users/pprett/gists{/gist_id}","starred_url":"https://api.github.com/users/pprett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pprett/subscriptions","organizations_url":"https://api.github.com/users/pprett/orgs","repos_url":"https://api.github.com/users/pprett/repos","events_url":"https://api.github.com/users/pprett/events{/privacy}","received_events_url":"https://api.github.com/users/pprett/received_events","type":"User","site_admin":false},"repo":{"id":994120,"name":"scikit-learn","full_name":"pprett/scikit-learn","owner":{"login":"pprett","id":111730,"avatar_url":"https://avatars.githubusercontent.com/u/111730?v=2","gravatar_id":"c9e2eeace0c2f0dcc21cfca626fd1797","url":"https://api.github.com/users/pprett","html_url":"https://github.com/pprett","followers_url":"https://api.github.com/users/pprett/followers","following_url":"https://api.github.com/users/pprett/following{/other_user}","gists_url":"https://api.github.com/users/pprett/gists{/gist_id}","starred_url":"https://api.github.com/users/pprett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pprett/subscriptions","organizations_url":"https://api.github.com/users/pprett/orgs","repos_url":"https://api.github.com/users/pprett/repos","events_url":"https://api.github.com/users/pprett/events{/privacy}","received_events_url":"https://api.github.com/users/pprett/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pprett/scikit-learn","description":"scikit-learn main repo","fork":true,"url":"https://api.github.com/repos/pprett/scikit-learn","forks_url":"https://api.github.com/repos/pprett/scikit-learn/forks","keys_url":"https://api.github.com/repos/pprett/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pprett/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pprett/scikit-learn/teams","hooks_url":"https://api.github.com/repos/pprett/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/pprett/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/pprett/scikit-learn/events","assignees_url":"https://api.github.com/repos/pprett/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/pprett/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/pprett/scikit-learn/tags","blobs_url":"https://api.github.com/repos/pprett/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pprett/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pprett/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/pprett/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pprett/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/pprett/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/pprett/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/pprett/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/pprett/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/pprett/scikit-learn/subscription","commits_url":"https://api.github.com/repos/pprett/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/pprett/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/pprett/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/pprett/scikit-learn/issues/comments/{number}","contents_url":"https://api.github.com/repos/pprett/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/pprett/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pprett/scikit-learn/merges","archive_url":"https://api.github.com/repos/pprett/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pprett/scikit-learn/downloads","issues_url":"https://api.github.com/repos/pprett/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/pprett/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/pprett/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/pprett/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pprett/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/pprett/scikit-learn/releases{/id}","created_at":"2010-10-17T07:58:53Z","updated_at":"2014-06-26T22:00:09Z","pushed_at":"2014-09-17T10:14:37Z","git_url":"git://github.com/pprett/scikit-learn.git","ssh_url":"git@github.com:pprett/scikit-learn.git","clone_url":"https://github.com/pprett/scikit-learn.git","svn_url":"https://github.com/pprett/scikit-learn","homepage":"http://scikit-learn.sourceforge.net","size":57459,"stargazers_count":8,"watchers_count":8,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":8,"default_branch":"master"}},"base":{"label":"scikit-learn:master","ref":"master","sha":"12f63da2adaa8b7e87c9637fe769f1545b297b9e","user":{"login":"scikit-learn","id":365630,"avatar_url":"https://avatars.githubusercontent.com/u/365630?v=2","gravatar_id":"8a6ecb57b119c5a5b3d882d08a909278","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://avatars.githubusercontent.com/u/365630?v=2","gravatar_id":"8a6ecb57b119c5a5b3d882d08a909278","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}","created_at":"2010-08-17T09:43:38Z","updated_at":"2014-09-17T19:03:13Z","pushed_at":"2014-09-17T14:43:16Z","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":118663,"stargazers_count":4082,"watchers_count":4082,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2194,"mirror_url":null,"open_issues_count":495,"forks":2194,"open_issues":495,"watchers":4082,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3224"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/3224"},"issue":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/3224"},"comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/3224/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3224/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/3224/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/2d503283d3b1a9b08a54626837c88bcb9fadc158"}}}}