{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/196745639","pull_request_review_id":130356022,"id":196745639,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5Njc0NTYzOQ==","diff_hunk":"@@ -115,16 +141,53 @@ class SimpleImputer(BaseEstimator, TransformerMixin):\n     Notes\n     -----\n     Columns which only contained missing values at `fit` are discarded upon\n-    `transform`.\n+    `transform` if strategy is not \"constant\".\n \n     \"\"\"\n-    def __init__(self, missing_values=\"NaN\", strategy=\"mean\",\n-                 verbose=0, copy=True):\n+    def __init__(self, missing_values=np.nan, strategy=\"mean\",\n+                 fill_value=None, verbose=0, copy=True):\n         self.missing_values = missing_values\n         self.strategy = strategy\n+        self.fill_value = fill_value\n         self.verbose = verbose\n         self.copy = copy\n \n+    def _validate_input(self, X):\n+        allowed_strategies = [\"mean\", \"median\", \"most_frequent\", \"constant\"]\n+        if self.strategy not in allowed_strategies:\n+            raise ValueError(\"Can only use these strategies: {0} \"\n+                             \" got strategy={1}\".format(allowed_strategies,\n+                                                        self.strategy))\n+\n+        if self.strategy in (\"most_frequent\", \"constant\"):\n+            dtype = None\n+        else:\n+            dtype = FLOAT_DTYPES\n+\n+        if not is_scalar_nan(self.missing_values):\n+            force_all_finite = True\n+        else:\n+            force_all_finite = \"allow-nan\"\n+\n+        try:\n+            X = check_array(X, accept_sparse='csc', dtype=dtype,\n+                            force_all_finite=force_all_finite, copy=self.copy)\n+        except ValueError as ve:\n+            if \"could not convert\" in str(ve):\n+                raise TypeError(\"Cannot use {0} strategy with non-numeric \"\n+                                \"data. Received datatype :{1}.\"\n+                                \"\".format(self.strategy, X.dtype.kind))\n+            else:\n+                raise ve\n+\n+        if X.dtype.kind not in (\"i\", \"u\", \"f\", \"O\"):\n+            raise TypeError(\"The SimpleImputer does not support this datatype\"\n+                            \" ({0}). Please provide either numeric data or\"\n+                            \" categorical data represented by integer or \"\n+                            \"object datatypes.\".format(X.dtype))","path":"sklearn/impute.py","position":null,"original_position":140,"commit_id":"fb1a4e9f4adde5ea5221ef3519034107ca387548","original_commit_id":"972668b750a4378cbc771fdc7c18d95f21397481","user":{"login":"ogrisel","id":89061,"node_id":"MDQ6VXNlcjg5MDYx","avatar_url":"https://avatars0.githubusercontent.com/u/89061?v=4","gravatar_id":"","url":"https://api.github.com/users/ogrisel","html_url":"https://github.com/ogrisel","followers_url":"https://api.github.com/users/ogrisel/followers","following_url":"https://api.github.com/users/ogrisel/following{/other_user}","gists_url":"https://api.github.com/users/ogrisel/gists{/gist_id}","starred_url":"https://api.github.com/users/ogrisel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ogrisel/subscriptions","organizations_url":"https://api.github.com/users/ogrisel/orgs","repos_url":"https://api.github.com/users/ogrisel/repos","events_url":"https://api.github.com/users/ogrisel/events{/privacy}","received_events_url":"https://api.github.com/users/ogrisel/received_events","type":"User","site_admin":false},"body":"numpy is not very consistent:\r\n\r\n```python\r\n>>> np.array(['a', 'b'], dtype=object).astype(np.uint8)\r\nTraceback (most recent call last):\r\n  File \"<ipython-input-6-3200a6709d46>\", line 1, in <module>\r\n    np.array(['a', 'b'], dtype=object).astype(np.uint8)\r\nValueError: invalid literal for int() with base 10: 'a'\r\n```\r\n\r\nIt's true that if you consider the individual scalar operation the TypeError raised by a ufunc might make sense. If you consider that the array as a whole is invalid, then ValueError makes more sense. I think both are fine in this case.","created_at":"2018-06-20T11:55:19Z","updated_at":"2018-06-20T11:55:19Z","html_url":"https://github.com/scikit-learn/scikit-learn/pull/11211#discussion_r196745639","pull_request_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11211","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/196745639"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/11211#discussion_r196745639"},"pull_request":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11211"}},"in_reply_to_id":196344968},"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11211","id":192981609,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkyOTgxNjA5","html_url":"https://github.com/scikit-learn/scikit-learn/pull/11211","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/11211.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/11211.patch","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11211","number":11211,"state":"open","locked":false,"title":"[MRG+1] SimpleImputer(strategy=\"constant\")","user":{"login":"jeremiedbb","id":34657725,"node_id":"MDQ6VXNlcjM0NjU3NzI1","avatar_url":"https://avatars2.githubusercontent.com/u/34657725?v=4","gravatar_id":"","url":"https://api.github.com/users/jeremiedbb","html_url":"https://github.com/jeremiedbb","followers_url":"https://api.github.com/users/jeremiedbb/followers","following_url":"https://api.github.com/users/jeremiedbb/following{/other_user}","gists_url":"https://api.github.com/users/jeremiedbb/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremiedbb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremiedbb/subscriptions","organizations_url":"https://api.github.com/users/jeremiedbb/orgs","repos_url":"https://api.github.com/users/jeremiedbb/repos","events_url":"https://api.github.com/users/jeremiedbb/events{/privacy}","received_events_url":"https://api.github.com/users/jeremiedbb/received_events","type":"User","site_admin":false},"body":"This is WIP to implement the constant strategy for the SimpleImputer as described in #11208.","created_at":"2018-06-06T11:25:15Z","updated_at":"2018-06-20T11:55:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9bfb1851ddcba1d6ff5530cad6ede692ab62e283","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"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":32,"state":"open","created_at":"2017-06-12T11:07:06Z","updated_at":"2018-06-20T10:50:02Z","due_on":"2018-01-31T08:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11211/commits","review_comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11211/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/11211/comments","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/fb1a4e9f4adde5ea5221ef3519034107ca387548","head":{"label":"jeremiedbb:constant-imputer","ref":"constant-imputer","sha":"fb1a4e9f4adde5ea5221ef3519034107ca387548","user":{"login":"jeremiedbb","id":34657725,"node_id":"MDQ6VXNlcjM0NjU3NzI1","avatar_url":"https://avatars2.githubusercontent.com/u/34657725?v=4","gravatar_id":"","url":"https://api.github.com/users/jeremiedbb","html_url":"https://github.com/jeremiedbb","followers_url":"https://api.github.com/users/jeremiedbb/followers","following_url":"https://api.github.com/users/jeremiedbb/following{/other_user}","gists_url":"https://api.github.com/users/jeremiedbb/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremiedbb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremiedbb/subscriptions","organizations_url":"https://api.github.com/users/jeremiedbb/orgs","repos_url":"https://api.github.com/users/jeremiedbb/repos","events_url":"https://api.github.com/users/jeremiedbb/events{/privacy}","received_events_url":"https://api.github.com/users/jeremiedbb/received_events","type":"User","site_admin":false},"repo":{"id":135716742,"node_id":"MDEwOlJlcG9zaXRvcnkxMzU3MTY3NDI=","name":"scikit-learn","full_name":"jeremiedbb/scikit-learn","owner":{"login":"jeremiedbb","id":34657725,"node_id":"MDQ6VXNlcjM0NjU3NzI1","avatar_url":"https://avatars2.githubusercontent.com/u/34657725?v=4","gravatar_id":"","url":"https://api.github.com/users/jeremiedbb","html_url":"https://github.com/jeremiedbb","followers_url":"https://api.github.com/users/jeremiedbb/followers","following_url":"https://api.github.com/users/jeremiedbb/following{/other_user}","gists_url":"https://api.github.com/users/jeremiedbb/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremiedbb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremiedbb/subscriptions","organizations_url":"https://api.github.com/users/jeremiedbb/orgs","repos_url":"https://api.github.com/users/jeremiedbb/repos","events_url":"https://api.github.com/users/jeremiedbb/events{/privacy}","received_events_url":"https://api.github.com/users/jeremiedbb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jeremiedbb/scikit-learn","description":"scikit-learn: machine learning in Python","fork":true,"url":"https://api.github.com/repos/jeremiedbb/scikit-learn","forks_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/forks","keys_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/teams","hooks_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/events","assignees_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/tags","blobs_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/subscription","commits_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/merges","archive_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/downloads","issues_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/releases{/id}","deployments_url":"https://api.github.com/repos/jeremiedbb/scikit-learn/deployments","created_at":"2018-06-01T12:46:27Z","updated_at":"2018-06-01T12:46:35Z","pushed_at":"2018-06-20T08:48:46Z","git_url":"git://github.com/jeremiedbb/scikit-learn.git","ssh_url":"git@github.com:jeremiedbb/scikit-learn.git","clone_url":"https://github.com/jeremiedbb/scikit-learn.git","svn_url":"https://github.com/jeremiedbb/scikit-learn","homepage":"http://scikit-learn.org","size":90373,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"scikit-learn:master","ref":"master","sha":"4143356c3c51831300789e4fdf795d83716dbab6","user":{"login":"scikit-learn","id":365630,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2NTYzMA==","avatar_url":"https://avatars2.githubusercontent.com/u/365630?v=4","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,"node_id":"MDEwOlJlcG9zaXRvcnk4NDMyMjI=","name":"scikit-learn","full_name":"scikit-learn/scikit-learn","owner":{"login":"scikit-learn","id":365630,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2NTYzMA==","avatar_url":"https://avatars2.githubusercontent.com/u/365630?v=4","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":"2018-06-20T11:54:51Z","pushed_at":"2018-06-20T11:51: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":90955,"stargazers_count":28877,"watchers_count":28877,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14332,"mirror_url":null,"archived":false,"open_issues_count":1639,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":14332,"open_issues":1639,"watchers":28877,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11211"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/11211"},"issue":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11211"},"comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/11211/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/11211/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/11211/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/fb1a4e9f4adde5ea5221ef3519034107ca387548"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ogrisel"}}