{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/59520715","id":59520715,"diff_hunk":"@@ -49,41 +49,42 @@\n classifiers = {\n     \"One-Class SVM\": svm.OneClassSVM(nu=0.95 * outliers_fraction + 0.05,\n                                      kernel=\"rbf\", gamma=0.1),\n-    \"robust covariance estimator\": EllipticEnvelope(contamination=.1),\n-    \"Isolation Forest\": IsolationForest(max_samples=n_samples, random_state=rng)}\n+    \"Robust covariance\": EllipticEnvelope(contamination=outliers_fraction),\n+    \"Isolation Forest\": IsolationForest(max_samples=n_samples,\n+                                        contamination=outliers_fraction,\n+                                        random_state=rng)}\n \n # Compare given classifiers under given settings\n xx, yy = np.meshgrid(np.linspace(-7, 7, 500), np.linspace(-7, 7, 500))\n n_inliers = int((1. - outliers_fraction) * n_samples)\n n_outliers = int(outliers_fraction * n_samples)\n ground_truth = np.ones(n_samples, dtype=int)\n-ground_truth[-n_outliers:] = 0\n+ground_truth[-n_outliers:] = -1\n \n # Fit the problem with varying cluster separation\n for i, offset in enumerate(clusters_separation):\n     np.random.seed(42)\n     # Data generation\n-    X1 = 0.3 * np.random.randn(0.5 * n_inliers, 2) - offset\n-    X2 = 0.3 * np.random.randn(0.5 * n_inliers, 2) + offset\n+    X1 = 0.3 * np.random.randn(n_inliers // 2, 2) - offset\n+    X2 = 0.3 * np.random.randn(n_inliers // 2, 2) + offset","path":"examples/covariance/plot_outlier_detection.py","position":37,"original_position":37,"commit_id":"e55c26bc3d65ad383f5c201216e31e9e9850d8bc","original_commit_id":"e55c26bc3d65ad383f5c201216e31e9e9850d8bc","user":{"login":"rvraghav93","id":9487348,"avatar_url":"https://avatars.githubusercontent.com/u/9487348?v=3","gravatar_id":"","url":"https://api.github.com/users/rvraghav93","html_url":"https://github.com/rvraghav93","followers_url":"https://api.github.com/users/rvraghav93/followers","following_url":"https://api.github.com/users/rvraghav93/following{/other_user}","gists_url":"https://api.github.com/users/rvraghav93/gists{/gist_id}","starred_url":"https://api.github.com/users/rvraghav93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rvraghav93/subscriptions","organizations_url":"https://api.github.com/users/rvraghav93/orgs","repos_url":"https://api.github.com/users/rvraghav93/repos","events_url":"https://api.github.com/users/rvraghav93/events{/privacy}","received_events_url":"https://api.github.com/users/rvraghav93/received_events","type":"User","site_admin":false},"body":"Why this change? (sorry if it is obvious)","created_at":"2016-04-13T09:46:13Z","updated_at":"2016-04-13T09:46:13Z","html_url":"https://github.com/scikit-learn/scikit-learn/pull/5638#discussion_r59520715","pull_request_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5638","_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/59520715"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/5638#discussion_r59520715"},"pull_request":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5638"}}},"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5638","id":49305477,"html_url":"https://github.com/scikit-learn/scikit-learn/pull/5638","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/5638.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/5638.patch","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5638","number":5638,"state":"open","locked":false,"title":"[MRG+1]: binary predict in IsolationForest","user":{"login":"ngoix","id":5682433,"avatar_url":"https://avatars.githubusercontent.com/u/5682433?v=3","gravatar_id":"","url":"https://api.github.com/users/ngoix","html_url":"https://github.com/ngoix","followers_url":"https://api.github.com/users/ngoix/followers","following_url":"https://api.github.com/users/ngoix/following{/other_user}","gists_url":"https://api.github.com/users/ngoix/gists{/gist_id}","starred_url":"https://api.github.com/users/ngoix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngoix/subscriptions","organizations_url":"https://api.github.com/users/ngoix/orgs","repos_url":"https://api.github.com/users/ngoix/repos","events_url":"https://api.github.com/users/ngoix/events{/privacy}","received_events_url":"https://api.github.com/users/ngoix/received_events","type":"User","site_admin":false},"body":"As noticed by @ogrisel and @amueller we have to find a threshold on the decision function of IsolationForest in order to return a binary predict.\r\n\r\nFor now on this PR, there is just a benchmark which plots an histogram of the decision_function on classical anomaly detection datasets.\r\n\r\nI think a default threshold of `0` may work in most of cases, while the user should also be allowed to choose a contamination parameter `c` (like in EllipticEnvelope). In that case, the threshold would the `c`th lowest scoring value. What do you think?\r\n\r\nIn the future, it would also be a good idea to have an `auto` threshold value which would fit a more sophisticated model (like a gmm) to estimate the best threshold. \r\nPing @agramfort.\r\n\r\n![decision_function_http_10percent](https://cloud.githubusercontent.com/assets/5682433/10853848/adfc0318-7f38-11e5-9992-2657419293f1.png)\r\n\r\n![decision_function_forestcover_10percent](https://cloud.githubusercontent.com/assets/5682433/10853844/ab7c837e-7f38-11e5-96e8-b1e8cd8c3274.png)\r\n\r\n![decision_function_sa_10percent](https://cloud.githubusercontent.com/assets/5682433/10853849/b01a0f5a-7f38-11e5-9a96-7a1c1016b6da.png)\r\n\r\n![decision_function_sf_10percent](https://cloud.githubusercontent.com/assets/5682433/10853852/b3c60b18-7f38-11e5-8452-979e353883fd.png)\r\n\r\n![decision_function_shuttle_10percent](https://cloud.githubusercontent.com/assets/5682433/10853853/b566b5a8-7f38-11e5-8f96-beff193c60f9.png)\r\n\r\n![decision_function_smtp_10percent](https://cloud.githubusercontent.com/assets/5682433/10853855/b75058ce-7f38-11e5-9c6c-8f1cab870db4.png)\r\n","created_at":"2015-10-30T18:26:58Z","updated_at":"2016-04-13T09:46:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3590229c1779c4818938dc1aa6f27cbf75896886","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5638/commits","review_comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5638/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/5638/comments","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/e55c26bc3d65ad383f5c201216e31e9e9850d8bc","head":{"label":"ngoix:binary-predict-iforest","ref":"binary-predict-iforest","sha":"e55c26bc3d65ad383f5c201216e31e9e9850d8bc","user":{"login":"ngoix","id":5682433,"avatar_url":"https://avatars.githubusercontent.com/u/5682433?v=3","gravatar_id":"","url":"https://api.github.com/users/ngoix","html_url":"https://github.com/ngoix","followers_url":"https://api.github.com/users/ngoix/followers","following_url":"https://api.github.com/users/ngoix/following{/other_user}","gists_url":"https://api.github.com/users/ngoix/gists{/gist_id}","starred_url":"https://api.github.com/users/ngoix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngoix/subscriptions","organizations_url":"https://api.github.com/users/ngoix/orgs","repos_url":"https://api.github.com/users/ngoix/repos","events_url":"https://api.github.com/users/ngoix/events{/privacy}","received_events_url":"https://api.github.com/users/ngoix/received_events","type":"User","site_admin":false},"repo":{"id":20621109,"name":"scikit-learn","full_name":"ngoix/scikit-learn","owner":{"login":"ngoix","id":5682433,"avatar_url":"https://avatars.githubusercontent.com/u/5682433?v=3","gravatar_id":"","url":"https://api.github.com/users/ngoix","html_url":"https://github.com/ngoix","followers_url":"https://api.github.com/users/ngoix/followers","following_url":"https://api.github.com/users/ngoix/following{/other_user}","gists_url":"https://api.github.com/users/ngoix/gists{/gist_id}","starred_url":"https://api.github.com/users/ngoix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngoix/subscriptions","organizations_url":"https://api.github.com/users/ngoix/orgs","repos_url":"https://api.github.com/users/ngoix/repos","events_url":"https://api.github.com/users/ngoix/events{/privacy}","received_events_url":"https://api.github.com/users/ngoix/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ngoix/scikit-learn","description":"scikit-learn: machine learning in Python","fork":true,"url":"https://api.github.com/repos/ngoix/scikit-learn","forks_url":"https://api.github.com/repos/ngoix/scikit-learn/forks","keys_url":"https://api.github.com/repos/ngoix/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ngoix/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ngoix/scikit-learn/teams","hooks_url":"https://api.github.com/repos/ngoix/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/ngoix/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/ngoix/scikit-learn/events","assignees_url":"https://api.github.com/repos/ngoix/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/ngoix/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/ngoix/scikit-learn/tags","blobs_url":"https://api.github.com/repos/ngoix/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ngoix/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ngoix/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/ngoix/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ngoix/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/ngoix/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/ngoix/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/ngoix/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/ngoix/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/ngoix/scikit-learn/subscription","commits_url":"https://api.github.com/repos/ngoix/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/ngoix/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/ngoix/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/ngoix/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/ngoix/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/ngoix/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ngoix/scikit-learn/merges","archive_url":"https://api.github.com/repos/ngoix/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ngoix/scikit-learn/downloads","issues_url":"https://api.github.com/repos/ngoix/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/ngoix/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/ngoix/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/ngoix/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ngoix/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/ngoix/scikit-learn/releases{/id}","deployments_url":"https://api.github.com/repos/ngoix/scikit-learn/deployments","created_at":"2014-06-08T16:42:05Z","updated_at":"2016-01-16T16:08:28Z","pushed_at":"2016-04-06T13:06:00Z","git_url":"git://github.com/ngoix/scikit-learn.git","ssh_url":"git@github.com:ngoix/scikit-learn.git","clone_url":"https://github.com/ngoix/scikit-learn.git","svn_url":"https://github.com/ngoix/scikit-learn","homepage":"http://scikit-learn.org","size":67616,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":0,"forks":5,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"scikit-learn:master","ref":"master","sha":"195a5eb412590f895226304d506a38c258c202ac","user":{"login":"scikit-learn","id":365630,"avatar_url":"https://avatars.githubusercontent.com/u/365630?v=3","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,"name":"scikit-learn","full_name":"scikit-learn/scikit-learn","owner":{"login":"scikit-learn","id":365630,"avatar_url":"https://avatars.githubusercontent.com/u/365630?v=3","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":"2016-04-13T09:16:06Z","pushed_at":"2016-04-13T02:55:24Z","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":103806,"stargazers_count":10720,"watchers_count":10720,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6244,"mirror_url":null,"open_issues_count":1150,"forks":6244,"open_issues":1150,"watchers":10720,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5638"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/5638"},"issue":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5638"},"comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5638/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5638/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/5638/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/e55c26bc3d65ad383f5c201216e31e9e9850d8bc"}}}}