GitHub PullRequestReviewCommentEvent at 2014-08-18 12:35:37
Repository: scikit-learn
Actor: vene
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/16350173","id":16350173,"diff_hunk":"@@ -41,41 +48,19 @@ def l1_min_c(X, y, loss='l2', fit_intercept=True, intercept_scaling=1.0):\n     l1_min_c: float\n         minimum value for C\n     \"\"\"\n-    import scipy.sparse as sp\n \n     if loss not in ('l2', 'log'):\n         raise ValueError('loss type not in (\"l2\", \"log\")')\n \n-    y = np.asarray(y)\n-\n-    if sp.issparse(X):\n-        X = sp.csc_matrix(X)\n-        hstack = sp.hstack\n-        dot = operator.mul\n-    else:\n-        X = np.asarray(X)\n-        hstack = np.hstack\n-        dot = np.dot\n+    X = check_array(X, accept_sparse='csc')\n+    check_consistent_length(X, y)\n \n+    Y = LabelBinarizer(neg_label=-1).fit_transform(y).T\n+    # maximum absolute value over classes and features\n+    den = np.max(np.abs(safe_sparse_dot(Y, X)))\n     if fit_intercept:\n         bias = intercept_scaling * np.ones((np.size(y), 1))\n-        X = hstack((X, bias))\n-\n-    classes = np.unique(y)\n-    n_classes = np.size(classes)\n-    if n_classes <= 2:\n-        c = classes[0]\n-        y = y.reshape((1, -1))\n-        _y = np.empty(y.shape)\n-        _y[y == c] = 1\n-        _y[y != c] = -1\n-    else:\n-        _y = np.empty((n_classes, np.size(y)))\n-        for i, c in enumerate(classes):\n-            _y[i, y == c] = 1\n-            _y[i, y != c] = -1\n-\n-    den = np.max(np.abs(dot(_y, X)))\n+        den = max(den, abs(np.dot(Y, bias)).max())\n \n     if den == 0.0:\n         raise ValueError('Ill-posed l1_min_c calculation')","path":"sklearn/svm/bounds.py","position":62,"original_position":62,"commit_id":"9088acac8c6a985245e635fdbb70fabd1acacde3","original_commit_id":"9088acac8c6a985245e635fdbb70fabd1acacde3","user":{"login":"vene","id":241745,"avatar_url":"https://avatars.githubusercontent.com/u/241745?v=2","gravatar_id":"b75596821d60780897218679101cf28f","url":"https://api.github.com/users/vene","html_url":"https://github.com/vene","followers_url":"https://api.github.com/users/vene/followers","following_url":"https://api.github.com/users/vene/following{/other_user}","gists_url":"https://api.github.com/users/vene/gists{/gist_id}","starred_url":"https://api.github.com/users/vene/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vene/subscriptions","organizations_url":"https://api.github.com/users/vene/orgs","repos_url":"https://api.github.com/users/vene/repos","events_url":"https://api.github.com/users/vene/events{/privacy}","received_events_url":"https://api.github.com/users/vene/received_events","type":"User","site_admin":false},"body":"`den == 0.0` is equivalent to saying that for each feature, the sum of the positive-class values is equal to the sum of the negative-class values. I think it's more like: there is no axis-aligned boundary that can perform better than an even split. (eg. for the xor problem this is ill-posed, but if you replace the (1, 1) point by (1, 2), it works with `den == 1`.\r\n\r\nSo I guess there's no better way of putting it than \"ill-posed\", and it seems very unlikely to occur in practice.","created_at":"2014-08-18T12:35:37Z","updated_at":"2014-08-18T12:35:37Z","html_url":"https://github.com/scikit-learn/scikit-learn/pull/3564#discussion_r16350173","pull_request_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3564","_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/16350173"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/3564#discussion_r16350173"},"pull_request":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3564"}}},"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3564","id":19824574,"html_url":"https://github.com/scikit-learn/scikit-learn/pull/3564","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/3564.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/3564.patch","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/3564","number":3564,"state":"open","locked":false,"title":"[MRG] update sklearn.svm.bounds to use recent helpers","user":{"login":"jnothman","id":78827,"avatar_url":"https://avatars.githubusercontent.com/u/78827?v=2","gravatar_id":"7677b43f6049d41c64cc332c381028ac","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},"body":"Here was some code with stale conventions. If it is useful code, perhaps it should be available in `linear_model` (and for alpha), not just in `svm`.","created_at":"2014-08-15T00:46:42Z","updated_at":"2014-08-18T12:35:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"42a164bf1acd9e08cd16f80889e9b1647cea5251","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3564/commits","review_comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3564/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/3564/comments","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/9088acac8c6a985245e635fdbb70fabd1acacde3","head":{"label":"jnothman:bounds","ref":"bounds","sha":"9088acac8c6a985245e635fdbb70fabd1acacde3","user":{"login":"jnothman","id":78827,"avatar_url":"https://avatars.githubusercontent.com/u/78827?v=2","gravatar_id":"7677b43f6049d41c64cc332c381028ac","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},"repo":{"id":8691611,"name":"scikit-learn","full_name":"jnothman/scikit-learn","owner":{"login":"jnothman","id":78827,"avatar_url":"https://avatars.githubusercontent.com/u/78827?v=2","gravatar_id":"7677b43f6049d41c64cc332c381028ac","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},"private":false,"html_url":"https://github.com/jnothman/scikit-learn","description":"scikit-learn: machine learning in Python","fork":true,"url":"https://api.github.com/repos/jnothman/scikit-learn","forks_url":"https://api.github.com/repos/jnothman/scikit-learn/forks","keys_url":"https://api.github.com/repos/jnothman/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jnothman/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jnothman/scikit-learn/teams","hooks_url":"https://api.github.com/repos/jnothman/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/jnothman/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/jnothman/scikit-learn/events","assignees_url":"https://api.github.com/repos/jnothman/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/jnothman/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/jnothman/scikit-learn/tags","blobs_url":"https://api.github.com/repos/jnothman/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jnothman/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jnothman/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/jnothman/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jnothman/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/jnothman/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/jnothman/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/jnothman/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/jnothman/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/jnothman/scikit-learn/subscription","commits_url":"https://api.github.com/repos/jnothman/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/jnothman/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/jnothman/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/jnothman/scikit-learn/issues/comments/{number}","contents_url":"https://api.github.com/repos/jnothman/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/jnothman/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jnothman/scikit-learn/merges","archive_url":"https://api.github.com/repos/jnothman/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jnothman/scikit-learn/downloads","issues_url":"https://api.github.com/repos/jnothman/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/jnothman/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/jnothman/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/jnothman/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jnothman/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/jnothman/scikit-learn/releases{/id}","created_at":"2013-03-10T21:10:51Z","updated_at":"2014-06-25T07:16:07Z","pushed_at":"2014-08-18T04:16:27Z","git_url":"git://github.com/jnothman/scikit-learn.git","ssh_url":"git@github.com:jnothman/scikit-learn.git","clone_url":"https://github.com/jnothman/scikit-learn.git","svn_url":"https://github.com/jnothman/scikit-learn","homepage":"http://scikit-learn.org","size":58599,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"6d8ccbcb982e6c1e9be63c5ad9d16aa1190a32e9","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-08-18T08:29:15Z","pushed_at":"2014-08-18T12:33:30Z","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":115302,"stargazers_count":3853,"watchers_count":3853,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":2046,"mirror_url":null,"open_issues_count":471,"forks":2046,"open_issues":471,"watchers":3853,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3564"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/3564"},"issue":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/3564"},"comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/3564/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3564/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/3564/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/9088acac8c6a985245e635fdbb70fabd1acacde3"}}}}