{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/6037","repository_url":"https://api.github.com/repos/scikit-learn/scikit-learn","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/6037/labels{/name}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/6037/comments","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/6037/events","html_url":"https://github.com/scikit-learn/scikit-learn/pull/6037","id":122184798,"number":6037,"title":"[MRG] Ensuring consistent transforms for KernelPCA","user":{"login":"hlin117","id":1865885,"avatar_url":"https://avatars.githubusercontent.com/u/1865885?v=3","gravatar_id":"","url":"https://api.github.com/users/hlin117","html_url":"https://github.com/hlin117","followers_url":"https://api.github.com/users/hlin117/followers","following_url":"https://api.github.com/users/hlin117/following{/other_user}","gists_url":"https://api.github.com/users/hlin117/gists{/gist_id}","starred_url":"https://api.github.com/users/hlin117/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hlin117/subscriptions","organizations_url":"https://api.github.com/users/hlin117/orgs","repos_url":"https://api.github.com/users/hlin117/repos","events_url":"https://api.github.com/users/hlin117/events{/privacy}","received_events_url":"https://api.github.com/users/hlin117/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/labels/Needs%20Review","name":"Needs Review","color":"f7c6c7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-12-15T03:23:43Z","updated_at":"2016-02-07T07:51:03Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/6037","html_url":"https://github.com/scikit-learn/scikit-learn/pull/6037","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/6037.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/6037.patch"},"body":"Previously, the following script created an AssertionError:\r\n\r\n```\r\n>>>    state = np.random.RandomState(0)\r\n>>>    X = state.rand(10, 10)\r\n>>>    kpca = KernelPCA(random_state=state).fit(X)\r\n>>>    transformed1 = kpca.transform(X)\r\n>>>\r\n>>>    X_copy = X.copy()\r\n>>>    X[:, 0] = 666\r\n>>>    transformed2 = kpca.transform(X_copy)\r\n>>>    assert_array_almost_equal(transformed1, transformed2)\r\n```\r\n\r\nThat's because `KernelPCA.fit_X` has a reference to the original `X` for `transform`. I made a one line change to make sure this was not the case.\r\n\r\nAs far as I know, I think @mblondel did not intend for the following above to raise an error.\r\n\r\n## PR Includes\r\n\r\n* Small change to the source to ensure that a copy to the fit data is kept\r\n* A regression test. (Same script as above.)\r\n"},"comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/comments/180971827","html_url":"https://github.com/scikit-learn/scikit-learn/pull/6037#issuecomment-180971827","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/6037","id":180971827,"user":{"login":"hlin117","id":1865885,"avatar_url":"https://avatars.githubusercontent.com/u/1865885?v=3","gravatar_id":"","url":"https://api.github.com/users/hlin117","html_url":"https://github.com/hlin117","followers_url":"https://api.github.com/users/hlin117/followers","following_url":"https://api.github.com/users/hlin117/following{/other_user}","gists_url":"https://api.github.com/users/hlin117/gists{/gist_id}","starred_url":"https://api.github.com/users/hlin117/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hlin117/subscriptions","organizations_url":"https://api.github.com/users/hlin117/orgs","repos_url":"https://api.github.com/users/hlin117/repos","events_url":"https://api.github.com/users/hlin117/events{/privacy}","received_events_url":"https://api.github.com/users/hlin117/received_events","type":"User","site_admin":false},"created_at":"2016-02-07T07:51:03Z","updated_at":"2016-02-07T07:51:03Z","body":"Alright, it should be ready for code review again. Thanks @vene!"}}