{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11337","repository_url":"https://api.github.com/repos/scikit-learn/scikit-learn","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11337/labels{/name}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11337/comments","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11337/events","html_url":"https://github.com/scikit-learn/scikit-learn/issues/11337","id":334497911,"node_id":"MDU6SXNzdWUzMzQ0OTc5MTE=","number":11337,"title":"IsolationForest is breaking backward compatibility","user":{"login":"glemaitre","id":7454015,"node_id":"MDQ6VXNlcjc0NTQwMTU=","avatar_url":"https://avatars2.githubusercontent.com/u/7454015?v=4","gravatar_id":"","url":"https://api.github.com/users/glemaitre","html_url":"https://github.com/glemaitre","followers_url":"https://api.github.com/users/glemaitre/followers","following_url":"https://api.github.com/users/glemaitre/following{/other_user}","gists_url":"https://api.github.com/users/glemaitre/gists{/gist_id}","starred_url":"https://api.github.com/users/glemaitre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glemaitre/subscriptions","organizations_url":"https://api.github.com/users/glemaitre/orgs","repos_url":"https://api.github.com/users/glemaitre/repos","events_url":"https://api.github.com/users/glemaitre/events{/privacy}","received_events_url":"https://api.github.com/users/glemaitre/received_events","type":"User","site_admin":false},"labels":[{"id":273400470,"node_id":"MDU6TGFiZWwyNzM0MDA0NzA=","url":"https://api.github.com/repos/scikit-learn/scikit-learn/labels/Blocker","name":"Blocker","color":"e11d21","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/milestones/24","html_url":"https://github.com/scikit-learn/scikit-learn/milestone/24","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/milestones/24/labels","id":2577444,"node_id":"MDk6TWlsZXN0b25lMjU3NzQ0NA==","number":24,"title":"0.20","description":"","creator":{"login":"jnothman","id":78827,"node_id":"MDQ6VXNlcjc4ODI3","avatar_url":"https://avatars2.githubusercontent.com/u/78827?v=4","gravatar_id":"","url":"https://api.github.com/users/jnothman","html_url":"https://github.com/jnothman","followers_url":"https://api.github.com/users/jnothman/followers","following_url":"https://api.github.com/users/jnothman/following{/other_user}","gists_url":"https://api.github.com/users/jnothman/gists{/gist_id}","starred_url":"https://api.github.com/users/jnothman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnothman/subscriptions","organizations_url":"https://api.github.com/users/jnothman/orgs","repos_url":"https://api.github.com/users/jnothman/repos","events_url":"https://api.github.com/users/jnothman/events{/privacy}","received_events_url":"https://api.github.com/users/jnothman/received_events","type":"User","site_admin":false},"open_issues":53,"closed_issues":35,"state":"open","created_at":"2017-06-12T11:07:06Z","updated_at":"2018-06-21T13:48:40Z","due_on":"2018-01-31T08:00:00Z","closed_at":null},"comments":2,"created_at":"2018-06-21T13:37:30Z","updated_at":"2018-06-21T14:24:59Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"By preparing the scipy tutorial, I stumbled into a backward-compatibility breakage. It was introduced when the outlier detection methods have been improved.\r\n\r\nThe issue is with the following code:\r\n\r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom sklearn.datasets import make_blobs\r\nfrom sklearn.ensemble import IsolationForest\r\n\r\nX, y = make_blobs(n_features=2, centers=3, n_samples=500,\r\n                  random_state=42)\r\n\r\nalpha_set = 0.95\r\nn_samples, n_features = X.shape\r\nX_range = np.zeros((n_features, 2))\r\nX_range[:, 0] = np.min(X, axis=0) - 1.\r\nX_range[:, 1] = np.max(X, axis=0) + 1.\r\n\r\nh = 0.1  # step size of the mesh\r\nx_min, x_max = X_range[0]\r\ny_min, y_max = X_range[1]\r\nxx, yy = np.meshgrid(np.arange(x_min, x_max, h),\r\n                     np.arange(y_min, y_max, h))\r\n\r\ngrid = np.c_[xx.ravel(), yy.ravel()]\r\n\r\niforest = IsolationForest(n_estimators=300, contamination=0.10)\r\niforest = iforest.fit(X)\r\nZ_iforest = iforest.decision_function(grid)\r\nZ_iforest = Z_iforest.reshape(xx.shape)\r\n\r\nplt.figure()\r\nc_0 = plt.contour(xx, yy, Z_iforest,\r\n                  levels=[iforest.threshold_],\r\n                  colors='red', linewidths=3)\r\nplt.clabel(c_0, inline=1, fontsize=15,\r\n           fmt={iforest.threshold_: str(alpha_set)})\r\nplt.scatter(X[:, 0], X[:, 1], s=1.)\r\nplt.show()\r\n```\r\n\r\nSo it seems that now we need to had the `threshold_` (or later on the `offset_`) to the score given by the decision function.\r\n\r\n### Results in 0.19\r\n\r\n![019](https://user-images.githubusercontent.com/7454015/41721763-1a206de6-7567-11e8-8c9e-2e0a4b19e2b3.png)\r\n\r\n\r\n### Results in master\r\n\r\n![master](https://user-images.githubusercontent.com/7454015/41721808-351df5dc-7567-11e8-8dc6-b4a8ac071002.png)\r\n\r\n\r\nWhere we are of this breakage? I could not find it in the What's New.\r\nping @jnothman @ngoix @albertcthomas "},"comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/comments/399122100","html_url":"https://github.com/scikit-learn/scikit-learn/issues/11337#issuecomment-399122100","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11337","id":399122100,"node_id":"MDEyOklzc3VlQ29tbWVudDM5OTEyMjEwMA==","user":{"login":"albertcthomas","id":15966638,"node_id":"MDQ6VXNlcjE1OTY2NjM4","avatar_url":"https://avatars3.githubusercontent.com/u/15966638?v=4","gravatar_id":"","url":"https://api.github.com/users/albertcthomas","html_url":"https://github.com/albertcthomas","followers_url":"https://api.github.com/users/albertcthomas/followers","following_url":"https://api.github.com/users/albertcthomas/following{/other_user}","gists_url":"https://api.github.com/users/albertcthomas/gists{/gist_id}","starred_url":"https://api.github.com/users/albertcthomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertcthomas/subscriptions","organizations_url":"https://api.github.com/users/albertcthomas/orgs","repos_url":"https://api.github.com/users/albertcthomas/repos","events_url":"https://api.github.com/users/albertcthomas/events{/privacy}","received_events_url":"https://api.github.com/users/albertcthomas/received_events","type":"User","site_admin":false},"created_at":"2018-06-21T14:24:59Z","updated_at":"2018-06-21T14:24:59Z","author_association":"CONTRIBUTOR","body":"Using `levels = [0] on master should give the expected result. And I think this is an intended change as when you use decision_function you should use `levels = [0]` to be consistent with the other outlier detection estimators. "}}
{"actor":{"display_login":"albertcthomas"}}