{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/202547713","pull_request_review_id":137271669,"id":202547713,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMjU0NzcxMw==","diff_hunk":"@@ -257,6 +260,33 @@ def test_lda_store_covariance():\n     )\n \n \n+@pytest.mark.parametrize('n_features', [3, 5])\n+@pytest.mark.parametrize('n_classes', [5, 3])\n+def test_lda_dimension_warning(n_classes, n_features):\n+    RNG = check_random_state(0)\n+    n_samples = 10\n+    X = RNG.randn(n_samples , n_features)\n+    # we create n_classes labels by repeating and truncating a\n+    # range(n_classes) until n_samples\n+    y = np.tile(range(n_classes), n_samples // n_classes + 1)[:n_samples]\n+    max_components = min(n_features, n_classes - 1)\n+\n+    for n_components in [max_components - 1, None, max_components]:\n+        # if n_components < min(n_classes - 1, n_features), no warning\n+        lda = LinearDiscriminantAnalysis(n_components=n_components)\n+        assert_no_warnings(lda.fit, X, y)\n+\n+    for n_components in [max_components + 1,\n+                         max(n_features, n_classes - 1) + 1]:\n+        # if n_components < min(n_classes - 1, n_features), raise warning","path":"sklearn/tests/test_discriminant_analysis.py","position":33,"original_position":33,"commit_id":"723757725de669e1b33d0b2a92c639ba991beb53","original_commit_id":"8059aa28f1e3e24a35d00c3cb7c56ed12a5da6f3","user":{"login":"wdevazelhes","id":31916524,"node_id":"MDQ6VXNlcjMxOTE2NTI0","avatar_url":"https://avatars2.githubusercontent.com/u/31916524?v=4","gravatar_id":"","url":"https://api.github.com/users/wdevazelhes","html_url":"https://github.com/wdevazelhes","followers_url":"https://api.github.com/users/wdevazelhes/followers","following_url":"https://api.github.com/users/wdevazelhes/following{/other_user}","gists_url":"https://api.github.com/users/wdevazelhes/gists{/gist_id}","starred_url":"https://api.github.com/users/wdevazelhes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wdevazelhes/subscriptions","organizations_url":"https://api.github.com/users/wdevazelhes/orgs","repos_url":"https://api.github.com/users/wdevazelhes/repos","events_url":"https://api.github.com/users/wdevazelhes/events{/privacy}","received_events_url":"https://api.github.com/users/wdevazelhes/received_events","type":"User","site_admin":false},"body":"yes, sorry, typo","created_at":"2018-07-15T16:37:07Z","updated_at":"2018-07-15T16:37:07Z","html_url":"https://github.com/scikit-learn/scikit-learn/pull/11526#discussion_r202547713","pull_request_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11526","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/202547713"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/11526#discussion_r202547713"},"pull_request":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11526"}},"in_reply_to_id":202545758},"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11526","id":201501170,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAxNTAxMTcw","html_url":"https://github.com/scikit-learn/scikit-learn/pull/11526","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/11526.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/11526.patch","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11526","number":11526,"state":"open","locked":false,"title":"[MRG] FIX: warns when invalid n_components in LinearDiscriminantAnalysis","user":{"login":"wdevazelhes","id":31916524,"node_id":"MDQ6VXNlcjMxOTE2NTI0","avatar_url":"https://avatars2.githubusercontent.com/u/31916524?v=4","gravatar_id":"","url":"https://api.github.com/users/wdevazelhes","html_url":"https://github.com/wdevazelhes","followers_url":"https://api.github.com/users/wdevazelhes/followers","following_url":"https://api.github.com/users/wdevazelhes/following{/other_user}","gists_url":"https://api.github.com/users/wdevazelhes/gists{/gist_id}","starred_url":"https://api.github.com/users/wdevazelhes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wdevazelhes/subscriptions","organizations_url":"https://api.github.com/users/wdevazelhes/orgs","repos_url":"https://api.github.com/users/wdevazelhes/repos","events_url":"https://api.github.com/users/wdevazelhes/events{/privacy}","received_events_url":"https://api.github.com/users/wdevazelhes/received_events","type":"User","site_admin":false},"body":"#### Reference Issues/PRs\r\nFixes #10048.\r\nFixes #8956. (The second dimension of scalings will always be thresholded (not only for svd, (see https://github.com/scikit-learn/scikit-learn/issues/8956#issuecomment-376881805)))\r\n\r\n#### What does this implement/fix? Explain your changes.\r\nThis PR: \r\n - Raises a `ChangedBehaviourWarning` when the user sets `n_components` > `min(n_features, n_classes - 1)`. In this case it sets the `max_features` (the number of first components to take) to `min(n_features, n_classes - 1)` (and this way it doesn't take the `n_components` into account anymore). It does not throws an error like PCA not to break user code (cf comment: https://github.com/scikit-learn/scikit-learn/issues/6355#issuecomment-340855091). I should maybe provide a `FutureWarning` and throw an error in the future ? \r\n- Changes the docstring, saying that we should have `n_components < min(n_features, n_classes - 1)` (and not just `n_components` < `n_classes - 1`)\r\n- Tests that if the condition is verified no warning is thrown otherwise a warning is thrown\r\n\r\nI did not check explicitly the dimension (just the presence/absence of warnings) because it can still happen that the dimension is unexpected if input points are colinear. I was thinking to tackle this in another PR (raise a warning in that case and/or return the whole `scalings_` (including zeros) without truncation) (see #11528)","created_at":"2018-07-15T14:38:25Z","updated_at":"2018-07-15T16:37:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"353ae6ac1230478aeba610b50085e278a6aa8488","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11526/commits","review_comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11526/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/11526/comments","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/723757725de669e1b33d0b2a92c639ba991beb53","head":{"label":"wdevazelhes:fix/warn_n_components_lineardiscriminantanalysis","ref":"fix/warn_n_components_lineardiscriminantanalysis","sha":"723757725de669e1b33d0b2a92c639ba991beb53","user":{"login":"wdevazelhes","id":31916524,"node_id":"MDQ6VXNlcjMxOTE2NTI0","avatar_url":"https://avatars2.githubusercontent.com/u/31916524?v=4","gravatar_id":"","url":"https://api.github.com/users/wdevazelhes","html_url":"https://github.com/wdevazelhes","followers_url":"https://api.github.com/users/wdevazelhes/followers","following_url":"https://api.github.com/users/wdevazelhes/following{/other_user}","gists_url":"https://api.github.com/users/wdevazelhes/gists{/gist_id}","starred_url":"https://api.github.com/users/wdevazelhes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wdevazelhes/subscriptions","organizations_url":"https://api.github.com/users/wdevazelhes/orgs","repos_url":"https://api.github.com/users/wdevazelhes/repos","events_url":"https://api.github.com/users/wdevazelhes/events{/privacy}","received_events_url":"https://api.github.com/users/wdevazelhes/received_events","type":"User","site_admin":false},"repo":{"id":103367679,"node_id":"MDEwOlJlcG9zaXRvcnkxMDMzNjc2Nzk=","name":"scikit-learn","full_name":"wdevazelhes/scikit-learn","owner":{"login":"wdevazelhes","id":31916524,"node_id":"MDQ6VXNlcjMxOTE2NTI0","avatar_url":"https://avatars2.githubusercontent.com/u/31916524?v=4","gravatar_id":"","url":"https://api.github.com/users/wdevazelhes","html_url":"https://github.com/wdevazelhes","followers_url":"https://api.github.com/users/wdevazelhes/followers","following_url":"https://api.github.com/users/wdevazelhes/following{/other_user}","gists_url":"https://api.github.com/users/wdevazelhes/gists{/gist_id}","starred_url":"https://api.github.com/users/wdevazelhes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wdevazelhes/subscriptions","organizations_url":"https://api.github.com/users/wdevazelhes/orgs","repos_url":"https://api.github.com/users/wdevazelhes/repos","events_url":"https://api.github.com/users/wdevazelhes/events{/privacy}","received_events_url":"https://api.github.com/users/wdevazelhes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wdevazelhes/scikit-learn","description":"scikit-learn: machine learning in Python","fork":true,"url":"https://api.github.com/repos/wdevazelhes/scikit-learn","forks_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/forks","keys_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/teams","hooks_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/events","assignees_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/tags","blobs_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/subscription","commits_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/merges","archive_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/downloads","issues_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/releases{/id}","deployments_url":"https://api.github.com/repos/wdevazelhes/scikit-learn/deployments","created_at":"2017-09-13T07:25:48Z","updated_at":"2018-06-25T08:51:46Z","pushed_at":"2018-07-15T15:26:36Z","git_url":"git://github.com/wdevazelhes/scikit-learn.git","ssh_url":"git@github.com:wdevazelhes/scikit-learn.git","clone_url":"https://github.com/wdevazelhes/scikit-learn.git","svn_url":"https://github.com/wdevazelhes/scikit-learn","homepage":"http://scikit-learn.org","size":91146,"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,"archived":false,"open_issues_count":1,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"scikit-learn:master","ref":"master","sha":"e860fd2d125f7869ec985599edcb6efc7b0df913","user":{"login":"scikit-learn","id":365630,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2NTYzMA==","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,"node_id":"MDEwOlJlcG9zaXRvcnk4NDMyMjI=","name":"scikit-learn","full_name":"scikit-learn/scikit-learn","owner":{"login":"scikit-learn","id":365630,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2NTYzMA==","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":"2018-07-15T15:54:10Z","pushed_at":"2018-07-15T15:53:33Z","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":91535,"stargazers_count":29328,"watchers_count":29328,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14558,"mirror_url":null,"archived":false,"open_issues_count":1676,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":14558,"open_issues":1676,"watchers":29328,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11526"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/11526"},"issue":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11526"},"comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11526/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11526/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/11526/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/723757725de669e1b33d0b2a92c639ba991beb53"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"wdevazelhes"}}