{"action":"closed","issue":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7244","repository_url":"https://api.github.com/repos/scikit-learn/scikit-learn","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7244/labels{/name}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7244/comments","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7244/events","html_url":"https://github.com/scikit-learn/scikit-learn/issues/7244","id":173229297,"number":7244,"title":"Inconsistent behaviour of decision trees with equal weights of samples","user":{"login":"avdeevvadim","id":13047840,"avatar_url":"https://avatars.githubusercontent.com/u/13047840?v=3","gravatar_id":"","url":"https://api.github.com/users/avdeevvadim","html_url":"https://github.com/avdeevvadim","followers_url":"https://api.github.com/users/avdeevvadim/followers","following_url":"https://api.github.com/users/avdeevvadim/following{/other_user}","gists_url":"https://api.github.com/users/avdeevvadim/gists{/gist_id}","starred_url":"https://api.github.com/users/avdeevvadim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avdeevvadim/subscriptions","organizations_url":"https://api.github.com/users/avdeevvadim/orgs","repos_url":"https://api.github.com/users/avdeevvadim/repos","events_url":"https://api.github.com/users/avdeevvadim/events{/privacy}","received_events_url":"https://api.github.com/users/avdeevvadim/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2016-08-25T15:07:51Z","updated_at":"2016-09-14T16:37:25Z","closed_at":"2016-09-14T16:37:25Z","body":"It seems to me the structure of trees shouldn`t change after multiplying the weights of all samples by some constant, but I get different results.\r\n\r\n#### Example\r\n```python\r\nfrom sklearn.tree import DecisionTreeClassifier\r\n\r\nX = [[1, 0], [1, 2], [1, 1], [0, 3]]\r\ny = [False, False, False, True]\r\n\r\nfor w in [1., 0.1, 0.01, 0.001, 0.0001]:\r\n    model = DecisionTreeClassifier(random_state=0, class_weight={False: w, True: w})\r\n    model.fit(X, y)\r\n    print(w, model.tree_.threshold, model.tree_.feature)\r\n```\r\nResults:\r\n```python\r\n1.0 [ 2.5 -2.  -2. ] [ 1 -2 -2]\r\n0.1 [ 2.5 -2.  -2. ] [ 1 -2 -2]\r\n0.01 [ 0.5 -2.  -2. ] [ 0 -2 -2]\r\n0.001 [ 2.5 -2.  -2. ] [ 1 -2 -2]\r\n0.0001 [ 2.5 -2.  -2. ] [ 1 -2 -2]\r\n```\r\n\r\nThe same problem with ```w = 0.01``` also occurs with ```DecisionTreeRegressor```, when the weights passed through the fit method.\r\n\r\nInterestingly, the problem disappears in this example with ```np.float32(w)``` instead of ```w```, but still appears in different situations.\r\n\r\nVersions: Scikit-Learn 0.17.1, NumPy 1.11.1, SciPy 0.17.1, Python 3.5.2, Windows 10."}}
{"actor":{"display_login":"amueller"}}