{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/93081339","pull_request_review_id":13602955,"id":93081339,"diff_hunk":"@@ -947,6 +947,13 @@ def check_class_weights(name):\n     clf2.fit(iris.data, iris.target, sample_weight)\n     assert_almost_equal(clf1.feature_importances_, clf2.feature_importances_)\n \n+    # When sample_weights is an unsupported array type, it checks if it raises\n+    # an exception. With Python 2.x lists it complains there is no copy()","path":"sklearn/ensemble/tests/test_forest.py","position":5,"original_position":5,"commit_id":"dd2c3e3d01a5d48cd9670ea610ee11b4cee9a109","original_commit_id":"dd2c3e3d01a5d48cd9670ea610ee11b4cee9a109","user":{"login":"amueller","id":449558,"avatar_url":"https://avatars.githubusercontent.com/u/449558?v=3","gravatar_id":"","url":"https://api.github.com/users/amueller","html_url":"https://github.com/amueller","followers_url":"https://api.github.com/users/amueller/followers","following_url":"https://api.github.com/users/amueller/following{/other_user}","gists_url":"https://api.github.com/users/amueller/gists{/gist_id}","starred_url":"https://api.github.com/users/amueller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amueller/subscriptions","organizations_url":"https://api.github.com/users/amueller/orgs","repos_url":"https://api.github.com/users/amueller/repos","events_url":"https://api.github.com/users/amueller/events{/privacy}","received_events_url":"https://api.github.com/users/amueller/received_events","type":"User","site_admin":false},"body":"This comment is a bit odd as not it doesn't fail. Maybe say \"used to fail on python2 for lists\" or something. This checks if it passes, not if it raises.","created_at":"2016-12-19T17:41:12Z","updated_at":"2016-12-19T17:41:12Z","html_url":"https://github.com/scikit-learn/scikit-learn/pull/8068#discussion_r93081339","pull_request_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/8068","_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/93081339"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/8068#discussion_r93081339"},"pull_request":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/8068"}}},"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/8068","id":98431967,"html_url":"https://github.com/scikit-learn/scikit-learn/pull/8068","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/8068.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/8068.patch","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/8068","number":8068,"state":"open","locked":false,"title":"[MRG + 1] Issue#8062: JoblibException thrown when passing \"fit_params={'sample_…","user":{"login":"xor","id":12541375,"avatar_url":"https://avatars.githubusercontent.com/u/12541375?v=3","gravatar_id":"","url":"https://api.github.com/users/xor","html_url":"https://github.com/xor","followers_url":"https://api.github.com/users/xor/followers","following_url":"https://api.github.com/users/xor/following{/other_user}","gists_url":"https://api.github.com/users/xor/gists{/gist_id}","starred_url":"https://api.github.com/users/xor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xor/subscriptions","organizations_url":"https://api.github.com/users/xor/orgs","repos_url":"https://api.github.com/users/xor/repos","events_url":"https://api.github.com/users/xor/events{/privacy}","received_events_url":"https://api.github.com/users/xor/received_events","type":"User","site_admin":false},"body":"…weights': weights}\" to RandomizedSearchCV with RandomForestClassifier\r\n\r\n<!--\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#Contributing-Pull-Requests\r\n-->\r\n#### Reference Issue\r\n<!-- Example: Fixes #1234 -->\r\nFixes #8062 #8064\r\n\r\n#### What does this implement/fix? Explain your changes.\r\nWhen the _sample_weight_ parameter of the _fit()_ method of a RandomForestClassifier is a python 2.x list, it raises an exception, because on a later call to \\__parallel_build_trees()_, the _copy()_ method is used, which it exists in python 3.x lists, panda series and nparrays, it doesn't exist however on python 2.x lists. To be clear, a python 3.x list here would also be inappropriate because even though operations like multiplication on it would succeed, the results would be different from the ones obtained from an nparray. It does explain however how the exception only happened with python 2.x lists. Another detail from the bug report was that the exception didn't happen when using a _ExtraTreesClassifier_. This was so because the bootstrap parameter on the _ExtraTreeClassifier_ is _False_ by default, which later in the __parallel_build_trees()_ call will divert the logic flow away from the _copy()_ method call. If we set the bootstrap parameter on the _ExtraTreesClassigier_ constructor, the behavior becomes the same, and the same exception is raised.\r\n\r\nAs suggested by @jnothman, I used the _check_array_ utility to transform the original _sample_weight_ array into a nparray, on the _BaseForest_ class. With a little pre-check to see if the _sample_weight_ parameter is _None_, since _check_array_ raises an exception otherwise. And an additional parameter to make sure the array created isn't 2d.\r\n\r\n~~I added no tests to check for this issue.~~\r\nA test was added.\r\n\r\nI tried the full make rebuild with no changes to the source, and it failed several tests. So I ran the full make again with my changes and just corrected what was different. So I'm not sure if all relevant tests were done.\r\n\r\npyflakes and pep8 showed no irregularities.\r\ncoverage for the module changed was at 65%, I'm not sure how relevant this is for such a small change, but there you have it.\r\n\r\n<!-- #### Any other comments? -->\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-->\r\n","created_at":"2016-12-17T03:47:30Z","updated_at":"2016-12-19T17:41:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3d477b0dddc3730dad034ac5927e315f9c48b2d2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/8068/commits","review_comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/8068/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/8068/comments","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/dd2c3e3d01a5d48cd9670ea610ee11b4cee9a109","head":{"label":"xor:issue#8062","ref":"issue#8062","sha":"dd2c3e3d01a5d48cd9670ea610ee11b4cee9a109","user":{"login":"xor","id":12541375,"avatar_url":"https://avatars.githubusercontent.com/u/12541375?v=3","gravatar_id":"","url":"https://api.github.com/users/xor","html_url":"https://github.com/xor","followers_url":"https://api.github.com/users/xor/followers","following_url":"https://api.github.com/users/xor/following{/other_user}","gists_url":"https://api.github.com/users/xor/gists{/gist_id}","starred_url":"https://api.github.com/users/xor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xor/subscriptions","organizations_url":"https://api.github.com/users/xor/orgs","repos_url":"https://api.github.com/users/xor/repos","events_url":"https://api.github.com/users/xor/events{/privacy}","received_events_url":"https://api.github.com/users/xor/received_events","type":"User","site_admin":false},"repo":{"id":76694944,"name":"scikit-learn","full_name":"xor/scikit-learn","owner":{"login":"xor","id":12541375,"avatar_url":"https://avatars.githubusercontent.com/u/12541375?v=3","gravatar_id":"","url":"https://api.github.com/users/xor","html_url":"https://github.com/xor","followers_url":"https://api.github.com/users/xor/followers","following_url":"https://api.github.com/users/xor/following{/other_user}","gists_url":"https://api.github.com/users/xor/gists{/gist_id}","starred_url":"https://api.github.com/users/xor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xor/subscriptions","organizations_url":"https://api.github.com/users/xor/orgs","repos_url":"https://api.github.com/users/xor/repos","events_url":"https://api.github.com/users/xor/events{/privacy}","received_events_url":"https://api.github.com/users/xor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xor/scikit-learn","description":"scikit-learn: machine learning in Python","fork":true,"url":"https://api.github.com/repos/xor/scikit-learn","forks_url":"https://api.github.com/repos/xor/scikit-learn/forks","keys_url":"https://api.github.com/repos/xor/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xor/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xor/scikit-learn/teams","hooks_url":"https://api.github.com/repos/xor/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/xor/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/xor/scikit-learn/events","assignees_url":"https://api.github.com/repos/xor/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/xor/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/xor/scikit-learn/tags","blobs_url":"https://api.github.com/repos/xor/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xor/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xor/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/xor/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xor/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/xor/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/xor/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/xor/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/xor/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/xor/scikit-learn/subscription","commits_url":"https://api.github.com/repos/xor/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/xor/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/xor/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/xor/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/xor/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/xor/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xor/scikit-learn/merges","archive_url":"https://api.github.com/repos/xor/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xor/scikit-learn/downloads","issues_url":"https://api.github.com/repos/xor/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/xor/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/xor/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/xor/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xor/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/xor/scikit-learn/releases{/id}","deployments_url":"https://api.github.com/repos/xor/scikit-learn/deployments","created_at":"2016-12-17T00:31:23Z","updated_at":"2016-12-17T00:31:34Z","pushed_at":"2016-12-18T07:17:24Z","git_url":"git://github.com/xor/scikit-learn.git","ssh_url":"git@github.com:xor/scikit-learn.git","clone_url":"https://github.com/xor/scikit-learn.git","svn_url":"https://github.com/xor/scikit-learn","homepage":"http://scikit-learn.org","size":77883,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"scikit-learn:master","ref":"master","sha":"726c8d999a0485a3319cb32aecd0cac25dd3cc53","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-12-19T17:16:03Z","pushed_at":"2016-12-19T17:22:03Z","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":78516,"stargazers_count":15398,"watchers_count":15398,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8660,"mirror_url":null,"open_issues_count":1169,"forks":8660,"open_issues":1169,"watchers":15398,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/8068"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/8068"},"issue":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/8068"},"comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/8068/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/8068/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/8068/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/dd2c3e3d01a5d48cd9670ea610ee11b4cee9a109"}}}}
{"actor":{"display_login":"amueller"}}