{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5497","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5497/labels{/name}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5497/comments","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5497/events","html_url":"https://github.com/scikit-learn/scikit-learn/pull/5497","id":112449713,"number":5497,"title":"[MRG] Supply arbitrary residual_metrics to RANSAC for 1-D targets","user":{"login":"MechCoder","id":1867024,"avatar_url":"https://avatars.githubusercontent.com/u/1867024?v=3","gravatar_id":"","url":"https://api.github.com/users/MechCoder","html_url":"https://github.com/MechCoder","followers_url":"https://api.github.com/users/MechCoder/followers","following_url":"https://api.github.com/users/MechCoder/following{/other_user}","gists_url":"https://api.github.com/users/MechCoder/gists{/gist_id}","starred_url":"https://api.github.com/users/MechCoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MechCoder/subscriptions","organizations_url":"https://api.github.com/users/MechCoder/orgs","repos_url":"https://api.github.com/users/MechCoder/repos","events_url":"https://api.github.com/users/MechCoder/events{/privacy}","received_events_url":"https://api.github.com/users/MechCoder/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-10-20T20:08:08Z","updated_at":"2015-10-21T14:43:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5497","html_url":"https://github.com/scikit-learn/scikit-learn/pull/5497","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/5497.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/5497.patch"},"body":"Partly fixes https://github.com/scikit-learn/scikit-learn/issues/4740\r\n\r\nSupply arbitrary residual metrics for 1-D targets was not possible.\r\n\r\n    from sklearn.linear_model import RANSACRegressor\r\n    from sklearn.datasets import make_regression\r\n    X, y = make_regression()\r\n    res_met = lambda dy: dy ** 2\r\n    ransac = RANSACRegressor(min_samples=5, residual_metric=res_met)\r\n    ransac.fit(X, y)\r\n    IndexError: too many indices for array\r\n\r\n\r\nThe workaround was to explicitly define res_met as accepting 2-D arrays, (since there is a reshape done) which is non-obvious.\r\n\r\n    res_met = lambda dy: np.sum(dy**2, axis=1)\r\n    ransac = RANSACRegressor(min_samples=5, residual_metric=res_met)\r\n    ransac.fit(X, y)\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/comments/149918471","html_url":"https://github.com/scikit-learn/scikit-learn/pull/5497#issuecomment-149918471","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5497","id":149918471,"user":{"login":"agramfort","id":161052,"avatar_url":"https://avatars.githubusercontent.com/u/161052?v=3","gravatar_id":"","url":"https://api.github.com/users/agramfort","html_url":"https://github.com/agramfort","followers_url":"https://api.github.com/users/agramfort/followers","following_url":"https://api.github.com/users/agramfort/following{/other_user}","gists_url":"https://api.github.com/users/agramfort/gists{/gist_id}","starred_url":"https://api.github.com/users/agramfort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agramfort/subscriptions","organizations_url":"https://api.github.com/users/agramfort/orgs","repos_url":"https://api.github.com/users/agramfort/repos","events_url":"https://api.github.com/users/agramfort/events{/privacy}","received_events_url":"https://api.github.com/users/agramfort/received_events","type":"User","site_admin":false},"created_at":"2015-10-21T14:43:44Z","updated_at":"2015-10-21T14:43:44Z","body":"no opinion ..."}}