{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/56946212","id":56946212,"diff_hunk":"@@ -505,7 +535,7 @@ def _validate_y_class_weight(self, y):\n \n         return y, expanded_class_weight\n \n-    def predict(self, X):\n+    def predict(self, X, missing_mask=None):","path":"sklearn/ensemble/forest.py","position":190,"original_position":190,"commit_id":"ad4e6d677ec7bdeb31f806e201f83ee831af0c9f","original_commit_id":"ad4e6d677ec7bdeb31f806e201f83ee831af0c9f","user":{"login":"glouppe","id":477771,"avatar_url":"https://avatars.githubusercontent.com/u/477771?v=3","gravatar_id":"","url":"https://api.github.com/users/glouppe","html_url":"https://github.com/glouppe","followers_url":"https://api.github.com/users/glouppe/followers","following_url":"https://api.github.com/users/glouppe/following{/other_user}","gists_url":"https://api.github.com/users/glouppe/gists{/gist_id}","starred_url":"https://api.github.com/users/glouppe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glouppe/subscriptions","organizations_url":"https://api.github.com/users/glouppe/orgs","repos_url":"https://api.github.com/users/glouppe/repos","events_url":"https://api.github.com/users/glouppe/events{/privacy}","received_events_url":"https://api.github.com/users/glouppe/received_events","type":"User","site_admin":false},"body":"same here","created_at":"2016-03-22T07:33:32Z","updated_at":"2016-03-22T07:33:32Z","html_url":"https://github.com/scikit-learn/scikit-learn/pull/5974#discussion_r56946212","pull_request_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5974","_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/56946212"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/5974#discussion_r56946212"},"pull_request":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5974"}}},"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5974","id":52876971,"html_url":"https://github.com/scikit-learn/scikit-learn/pull/5974","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/5974.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/5974.patch","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5974","number":5974,"state":"open","locked":false,"title":"[MRG] ENH Add support for missing values to Tree based Classifiers","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":"Fixes #5870 (Adds support to tree based classifiers, including ensemble methods)\r\n\r\nI'll send a subsequent PR for Regressors, once this is merged in...\r\n\r\n<hr> \r\n\r\nFor current status, notes, references - https://github.com/rvraghav93/miss_val_bench\r\n\r\n<hr>\r\nInitial reviews welcome! (This is still WIP though)\r\n\r\nKindly ignore the `# SELFNOTE` comments and scaffolding. I'll remove them after I am done with this PR.\r\n\r\n<hr>\r\n\r\n**TODO**\r\n- [ ] Modify the criterion to accept missing-offsetted pos (absolute `new_pos`, instead of pos only for available values)\r\n\r\n<hr>\r\n\r\n**PR Progress:**\r\n\r\n- [x] Support missing_values in `*TreeClassifier` (Make it work*)\r\n    - [x] Train with missing values\r\n        - [x] `DepthFirstTreeBuilder`\r\n        - [ ] `BestFirstTreeBuilder`\r\n        - [x] `ClassificationCriterion`\r\n        - [x] `BestSplitter`\r\n        - [ ] `RandomSplitter`\r\n        - [ ] `BestSparseSplitter`\r\n        - [ ] `RandomSparseSplitter`\r\n    - [x] Predict with missing values\r\n        - [x] Send randomly, if missing direction is undefined\r\n        - [x] `apply_dense`\r\n        - [ ] `apply_sparse_csc`\r\n- [x] Make this work with all the ensemble methods\r\n- [ ] Make it nice*\r\n- [ ] Benchmark, profile and improve performance for case when missing values do not exist.  (Make it fast 1*)\r\n- [ ] Benchmark, profile and improve performance for case when missing values exist (Make it fast 2*)\r\n- [ ] Update all the docstrings and documentation\r\n- [ ] Add 2 nice examples on real datasets\r\n    - [ ] One simply using the new functionality\r\n    - [ ] One to show how the method performs w.r.t to the missing rate\r\n\r\n*Taken from Alex's 3 golden strategies for success in a PR ;)\r\n\r\n**Additional:**\r\n\r\n- [ ] Can we make the missing mask sparse? (sparse boolean array)\r\n- [ ] Can any of the alternative 3 methods as described below be used instead?\r\n\r\n<hr>\r\n\r\n**NOTE:**\r\n\r\n* The 2 other promising alternative methods are\r\n    * [Use surrogates](http://www.salford-systems.com/videos/tutorials/tips-and-tricks/using-surrogates-to-improve-datasets-with-missing-values) to handle missing values as done in [`rpart`](https://cran.r-project.org/web/packages/rpart/rpart.pdf) - Seems promising with respect to the relative accuracy scores as reported by [Ding and Simonoff's paper](http://people.stern.nyu.edu/jsimonof/jmlr10.pdf) - Needs some refactoring to our API for this to work - Widely used - importantly this will work even if the training data had no missing values.\r\n    * Probabilistic split - This basically sends the the missing-valued samples to both right and left but sets the weights of the samples (in the child) to the number of non-missing samples in the right (or left) split, such that the total weight at the parent node is 1. This seems to be the most widely used method apart from imputation. Gilles feels this cannot be easily accomplished with our current API.\r\n\r\n<hr>\r\n\r\nCC: @agramfort @glouppe @jmschrei @arjoly @tguillemot \r\n\r\nThanks a lot to @glouppe, @agramfort, @TomDLT & @vighneshbirodkar for all the patience and help (in and out of github)!","created_at":"2015-12-07T17:46:18Z","updated_at":"2016-03-22T07:33:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b6c386798d2c95de9c96177a8f58bb4a81a2a51a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5974/commits","review_comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5974/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/5974/comments","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/ad4e6d677ec7bdeb31f806e201f83ee831af0c9f","head":{"label":"rvraghav93:missing_values_rf","ref":"missing_values_rf","sha":"ad4e6d677ec7bdeb31f806e201f83ee831af0c9f","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},"repo":{"id":26038110,"name":"scikit-learn","full_name":"rvraghav93/scikit-learn","owner":{"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},"private":false,"html_url":"https://github.com/rvraghav93/scikit-learn","description":"scikit-learn: machine learning in Python","fork":true,"url":"https://api.github.com/repos/rvraghav93/scikit-learn","forks_url":"https://api.github.com/repos/rvraghav93/scikit-learn/forks","keys_url":"https://api.github.com/repos/rvraghav93/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rvraghav93/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rvraghav93/scikit-learn/teams","hooks_url":"https://api.github.com/repos/rvraghav93/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/rvraghav93/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/rvraghav93/scikit-learn/events","assignees_url":"https://api.github.com/repos/rvraghav93/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/rvraghav93/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/rvraghav93/scikit-learn/tags","blobs_url":"https://api.github.com/repos/rvraghav93/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rvraghav93/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rvraghav93/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/rvraghav93/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rvraghav93/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/rvraghav93/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/rvraghav93/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/rvraghav93/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/rvraghav93/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/rvraghav93/scikit-learn/subscription","commits_url":"https://api.github.com/repos/rvraghav93/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/rvraghav93/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/rvraghav93/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/rvraghav93/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/rvraghav93/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/rvraghav93/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rvraghav93/scikit-learn/merges","archive_url":"https://api.github.com/repos/rvraghav93/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rvraghav93/scikit-learn/downloads","issues_url":"https://api.github.com/repos/rvraghav93/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/rvraghav93/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/rvraghav93/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/rvraghav93/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rvraghav93/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/rvraghav93/scikit-learn/releases{/id}","deployments_url":"https://api.github.com/repos/rvraghav93/scikit-learn/deployments","created_at":"2014-11-01T00:56:31Z","updated_at":"2016-01-17T18:48:08Z","pushed_at":"2016-03-21T12:34:21Z","git_url":"git://github.com/rvraghav93/scikit-learn.git","ssh_url":"git@github.com:rvraghav93/scikit-learn.git","clone_url":"https://github.com/rvraghav93/scikit-learn.git","svn_url":"https://github.com/rvraghav93/scikit-learn","homepage":"http://scikit-learn.org","size":85881,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"scikit-learn:master","ref":"master","sha":"e2285816a16f68df7542a31a8aa8bd4888c823e1","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-03-22T07:09:10Z","pushed_at":"2016-03-22T02:37:38Z","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":102949,"stargazers_count":10331,"watchers_count":10331,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6014,"mirror_url":null,"open_issues_count":1140,"forks":6014,"open_issues":1140,"watchers":10331,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5974"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/5974"},"issue":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5974"},"comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5974/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5974/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/5974/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/ad4e6d677ec7bdeb31f806e201f83ee831af0c9f"}}}}