{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/199521673","pull_request_review_id":133655656,"id":199521673,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5OTUyMTY3Mw==","diff_hunk":"@@ -641,6 +641,69 @@ def test_refit():\n     clf.fit(X, y)\n \n \n+def test_refit_callable():\n+    \"\"\"\n+    Test refit=callable, which adds flexibility in identifying the\n+    \"best\" estimator.\n+    \"\"\"\n+    def refit_callable(cv_results):\n+        \"\"\"\n+        A dummy function tests `refit=callable` interface.\n+        Return the index of a model that has the least\n+        `mean_test_score`.\n+        \"\"\"\n+        # Fit a dummy clf with `refit=True` to get a list of keys in\n+        # clf.cv_results_.\n+        X, y = make_classification(n_samples=100, n_features=4,\n+                                   random_state=42)\n+        clf = GridSearchCV(LinearSVC(random_state=42), {'C': [0.01, 0.1, 1]},\n+                           scoring='precision', refit=True)\n+        clf.fit(X, y)\n+        # Ensure that `best_index_ != 0` for this dummy clf\n+        assert clf.best_index_ != 0","path":"sklearn/model_selection/tests/test_search.py","position":23,"original_position":23,"commit_id":"0ad01a2cdd438f384bab9118edffc2f51e333aaf","original_commit_id":"0ad01a2cdd438f384bab9118edffc2f51e333aaf","user":{"login":"janvanrijn","id":2292730,"node_id":"MDQ6VXNlcjIyOTI3MzA=","avatar_url":"https://avatars1.githubusercontent.com/u/2292730?v=4","gravatar_id":"","url":"https://api.github.com/users/janvanrijn","html_url":"https://github.com/janvanrijn","followers_url":"https://api.github.com/users/janvanrijn/followers","following_url":"https://api.github.com/users/janvanrijn/following{/other_user}","gists_url":"https://api.github.com/users/janvanrijn/gists{/gist_id}","starred_url":"https://api.github.com/users/janvanrijn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janvanrijn/subscriptions","organizations_url":"https://api.github.com/users/janvanrijn/orgs","repos_url":"https://api.github.com/users/janvanrijn/repos","events_url":"https://api.github.com/users/janvanrijn/events{/privacy}","received_events_url":"https://api.github.com/users/janvanrijn/received_events","type":"User","site_admin":false},"body":"Why can't best_index not be 0? What if the first option in the hyperparameter grid is in fact the best option? ","created_at":"2018-07-02T14:45:39Z","updated_at":"2018-07-02T14:52:54Z","html_url":"https://github.com/scikit-learn/scikit-learn/pull/11354#discussion_r199521673","pull_request_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11354","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/199521673"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/11354#discussion_r199521673"},"pull_request":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11354"}}},"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11354","id":197199466,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk3MTk5NDY2","html_url":"https://github.com/scikit-learn/scikit-learn/pull/11354","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/11354.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/11354.patch","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11354","number":11354,"state":"open","locked":false,"title":"[MRG] Allow for refit=callable in *SearchCV to balance score and model complexity #11269","user":{"login":"jiaowoshabi","id":8967481,"node_id":"MDQ6VXNlcjg5Njc0ODE=","avatar_url":"https://avatars1.githubusercontent.com/u/8967481?v=4","gravatar_id":"","url":"https://api.github.com/users/jiaowoshabi","html_url":"https://github.com/jiaowoshabi","followers_url":"https://api.github.com/users/jiaowoshabi/followers","following_url":"https://api.github.com/users/jiaowoshabi/following{/other_user}","gists_url":"https://api.github.com/users/jiaowoshabi/gists{/gist_id}","starred_url":"https://api.github.com/users/jiaowoshabi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiaowoshabi/subscriptions","organizations_url":"https://api.github.com/users/jiaowoshabi/orgs","repos_url":"https://api.github.com/users/jiaowoshabi/repos","events_url":"https://api.github.com/users/jiaowoshabi/events{/privacy}","received_events_url":"https://api.github.com/users/jiaowoshabi/received_events","type":"User","site_admin":false},"body":"<!--\r\nThanks for contributing a pull request! Please ensure you have taken a look at\r\nthe contribution guidelines: https://github.com/scikit-learn/scikit-learn/blob/master/CONTRIBUTING.md#pull-request-checklist\r\n-->\r\n\r\n#### Reference Issues/PRs\r\n<!--\r\nExample: Fixes #1234. See also #3456.\r\nPlease use keywords (e.g., Fixes) to create link to the issues or pull requests\r\nyou resolved, so that they will automatically be closed when your pull request\r\nis merged. See https://github.com/blog/1506-closing-issues-via-pull-requests\r\n-->\r\nFixes #11269. See also #9499 \r\n\r\n#### What does this implement/fix? Explain your changes.\r\nAllow a callable to be passed to refit in *SearchCV to balance score and model complexity. This interface adds flexibility in identifying the \"best\" estimator. The function passed to parameter `refit`\r\nincorporate of which metric to optimise. Hence users can use multi-metric evaluation with this interface.\r\n\r\n#### Any other comments?\r\n\r\n1. 2 test cases added:\r\n\r\n- test_refit_callable()\r\n   - add an example of choosing the mode with the least `mean_test_score`\r\n- test_refit_callable_multi_metric()\r\n   - test the same example in a multi-metric evaluation setting\r\n\r\n2. Added documentation describing this feature to users(see additions in `_search.py under model_selection directory`)\r\n3. Added a example(`plot_grid_search_refit_callable.py`) of demonstrating the usage of this interface under `examples/model_selection/`\r\n4. This implementation passes all test suites by running `make`\r\n\r\nChecklist:\r\n- [x] Rewrite test case for `refit=callable` using simple dummy refit function. \r\n- [x] Rewrite test case for `refit=callable` using similar example in multi-metric eval settings\r\n- [x] Add functions in `_search.py` to pass the above tests\r\n- [x] Documentation\r\n- [x] Polishing\r\n\r\n<!--\r\nPlease be aware that we are a loose team of volunteers so patience is\r\nnecessary; assistance handling other issues is very welcome. We value\r\nall user contributions, no matter how minor they are. If we are slow to\r\nreview, either the pull request needs some benchmarking, tinkering,\r\nconvincing, etc. or more likely the reviewers are simply busy. In either\r\ncase, we ask for your understanding during the review process.\r\nFor more information, see our FAQ on this topic:\r\nhttp://scikit-learn.org/dev/faq.html#why-is-my-pull-request-not-getting-any-attention.\r\n\r\nThanks for contributing!\r\n-->","created_at":"2018-06-25T18:34:31Z","updated_at":"2018-07-02T14:52:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"156a0d4d6a72a73bba0bc959164844d7d3ffe642","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11354/commits","review_comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11354/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/11354/comments","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/0ad01a2cdd438f384bab9118edffc2f51e333aaf","head":{"label":"jiaowoshabi:master","ref":"master","sha":"0ad01a2cdd438f384bab9118edffc2f51e333aaf","user":{"login":"jiaowoshabi","id":8967481,"node_id":"MDQ6VXNlcjg5Njc0ODE=","avatar_url":"https://avatars1.githubusercontent.com/u/8967481?v=4","gravatar_id":"","url":"https://api.github.com/users/jiaowoshabi","html_url":"https://github.com/jiaowoshabi","followers_url":"https://api.github.com/users/jiaowoshabi/followers","following_url":"https://api.github.com/users/jiaowoshabi/following{/other_user}","gists_url":"https://api.github.com/users/jiaowoshabi/gists{/gist_id}","starred_url":"https://api.github.com/users/jiaowoshabi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiaowoshabi/subscriptions","organizations_url":"https://api.github.com/users/jiaowoshabi/orgs","repos_url":"https://api.github.com/users/jiaowoshabi/repos","events_url":"https://api.github.com/users/jiaowoshabi/events{/privacy}","received_events_url":"https://api.github.com/users/jiaowoshabi/received_events","type":"User","site_admin":false},"repo":{"id":138365479,"node_id":"MDEwOlJlcG9zaXRvcnkxMzgzNjU0Nzk=","name":"scikit-learn","full_name":"jiaowoshabi/scikit-learn","owner":{"login":"jiaowoshabi","id":8967481,"node_id":"MDQ6VXNlcjg5Njc0ODE=","avatar_url":"https://avatars1.githubusercontent.com/u/8967481?v=4","gravatar_id":"","url":"https://api.github.com/users/jiaowoshabi","html_url":"https://github.com/jiaowoshabi","followers_url":"https://api.github.com/users/jiaowoshabi/followers","following_url":"https://api.github.com/users/jiaowoshabi/following{/other_user}","gists_url":"https://api.github.com/users/jiaowoshabi/gists{/gist_id}","starred_url":"https://api.github.com/users/jiaowoshabi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiaowoshabi/subscriptions","organizations_url":"https://api.github.com/users/jiaowoshabi/orgs","repos_url":"https://api.github.com/users/jiaowoshabi/repos","events_url":"https://api.github.com/users/jiaowoshabi/events{/privacy}","received_events_url":"https://api.github.com/users/jiaowoshabi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jiaowoshabi/scikit-learn","description":"scikit-learn: machine learning in Python","fork":true,"url":"https://api.github.com/repos/jiaowoshabi/scikit-learn","forks_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/forks","keys_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/teams","hooks_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/events","assignees_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/tags","blobs_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/subscription","commits_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/merges","archive_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/downloads","issues_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/releases{/id}","deployments_url":"https://api.github.com/repos/jiaowoshabi/scikit-learn/deployments","created_at":"2018-06-23T02:37:13Z","updated_at":"2018-06-30T22:20:49Z","pushed_at":"2018-06-30T22:20:46Z","git_url":"git://github.com/jiaowoshabi/scikit-learn.git","ssh_url":"git@github.com:jiaowoshabi/scikit-learn.git","clone_url":"https://github.com/jiaowoshabi/scikit-learn.git","svn_url":"https://github.com/jiaowoshabi/scikit-learn","homepage":"http://scikit-learn.org","size":90509,"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":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"scikit-learn:master","ref":"master","sha":"a7e17117bb15eb3f51ebccc1bd53e42fcb4e6cd8","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-02T14:33:37Z","pushed_at":"2018-07-02T14:31: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":91314,"stargazers_count":29103,"watchers_count":29103,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14421,"mirror_url":null,"archived":false,"open_issues_count":1633,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":14421,"open_issues":1633,"watchers":29103,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11354"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/11354"},"issue":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11354"},"comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11354/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11354/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/11354/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/0ad01a2cdd438f384bab9118edffc2f51e333aaf"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"janvanrijn"}}