{"action":"created","comment":{"url":"https://api.github.com/repos/mlpack/mlpack/pulls/comments/70197483","id":70197483,"diff_hunk":"@@ -0,0 +1,108 @@\n+/**\n+ * @file imputer.hpp\n+ * @author Keon Kim\n+ *\n+ * Defines Imputer class a utility function to replace missing variables in a\n+ * dataset.\n+ */\n+#ifndef MLPACK_CORE_DATA_IMPUTER_HPP\n+#define MLPACK_CORE_DATA_IMPUTER_HPP\n+\n+#include <mlpack/core.hpp>\n+#include \"dataset_info.hpp\"\n+\n+namespace mlpack {\n+namespace data {\n+\n+/**\n+ * Given a dataset of a particular datatype, replace user-specified missing\n+ * value with a variable dependent on the StrategyType and MapperType.\n+ *\n+ * @tparam T Type of armadillo matrix used for imputation strategy.\n+ * @tparam MapperType DatasetMapper that is used to hold dataset information.\n+ * @tparam StrategyType Imputation strategy used.\n+ */\n+template<typename T, typename MapperType, typename StrategyType>\n+class Imputer\n+{\n+ public:\n+  Imputer(MapperType mapper, bool transpose = true):\n+    mapper(std::move(mapper)),\n+    transpose(transpose)\n+  {\n+    //static_assert(std::is_same<typename std::decay<MapperType>::type,\n+        //data::IncrementPolicy>::value, \"The type of MapperType must be \"\n+        //\"IncrementPolicy\");\n+  }\n+\n+  Imputer(MapperType mapper, StrategyType strategy, bool transpose = true):\n+    strategy(std::move(strategy)),\n+    mapper(std::move(mapper)),\n+    transpose(transpose)\n+  {\n+    //static_assert(std::is_same<typename std::decay<MapperType>::type,\n+        //data::IncrementPolicy>::value, \"The type of MapperType must be \"\n+        //\"IncrementPolicy\");\n+  }\n+\n+  /**\n+  * Given an input dataset, replace missing values with given imputation\n+  * strategy.\n+  *\n+  * @param input Input dataset to apply imputation.\n+  * @param output Armadillo matrix to save the results\n+  * @oaran missingValue User defined missing value; it can be anything.\n+  * @param dimension Dimension to apply the imputation.\n+  */\n+  void Impute(const arma::Mat<T>& input,\n+              arma::Mat<T>& output,\n+              const std::string& missingValue,\n+              const size_t dimension)\n+  {\n+    T mappedValue = static_cast<T>(mapper.UnmapValue(missingValue, dimension));\n+    strategy.Impute(input, output, mappedValue, dimension, transpose);\n+  }\n+\n+  /**\n+  * This overload of Impute() lets users to define custom value that can be\n+  * replaced with the target value.\n+  */\n+  void Impute(const arma::Mat<T>& input,\n+              arma::Mat<T>& output,\n+              const std::string& missingValue,\n+              const T& customValue,\n+              const size_t dimension)","path":"src/mlpack/core/data/imputer.hpp","position":null,"original_position":74,"commit_id":"fedc5e0ece901746ad15b9c13244713bb36d4f9e","original_commit_id":"a8818316a04506530e2269a2e0a32ba2f6a1c83b","user":{"login":"keonkim","id":10793962,"avatar_url":"https://avatars.githubusercontent.com/u/10793962?v=3","gravatar_id":"","url":"https://api.github.com/users/keonkim","html_url":"https://github.com/keonkim","followers_url":"https://api.github.com/users/keonkim/followers","following_url":"https://api.github.com/users/keonkim/following{/other_user}","gists_url":"https://api.github.com/users/keonkim/gists{/gist_id}","starred_url":"https://api.github.com/users/keonkim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keonkim/subscriptions","organizations_url":"https://api.github.com/users/keonkim/orgs","repos_url":"https://api.github.com/users/keonkim/repos","events_url":"https://api.github.com/users/keonkim/events{/privacy}","received_events_url":"https://api.github.com/users/keonkim/received_events","type":"User","site_admin":false},"body":"Updated","created_at":"2016-07-11T03:13:05Z","updated_at":"2016-07-11T03:13:05Z","html_url":"https://github.com/mlpack/mlpack/pull/694#discussion_r70197483","pull_request_url":"https://api.github.com/repos/mlpack/mlpack/pulls/694","_links":{"self":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/comments/70197483"},"html":{"href":"https://github.com/mlpack/mlpack/pull/694#discussion_r70197483"},"pull_request":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/694"}}},"pull_request":{"url":"https://api.github.com/repos/mlpack/mlpack/pulls/694","id":73674970,"html_url":"https://github.com/mlpack/mlpack/pull/694","diff_url":"https://github.com/mlpack/mlpack/pull/694.diff","patch_url":"https://github.com/mlpack/mlpack/pull/694.patch","issue_url":"https://api.github.com/repos/mlpack/mlpack/issues/694","number":694,"state":"open","locked":false,"title":"DatasetMapper & Imputer","user":{"login":"keonkim","id":10793962,"avatar_url":"https://avatars.githubusercontent.com/u/10793962?v=3","gravatar_id":"","url":"https://api.github.com/users/keonkim","html_url":"https://github.com/keonkim","followers_url":"https://api.github.com/users/keonkim/followers","following_url":"https://api.github.com/users/keonkim/following{/other_user}","gists_url":"https://api.github.com/users/keonkim/gists{/gist_id}","starred_url":"https://api.github.com/users/keonkim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keonkim/subscriptions","organizations_url":"https://api.github.com/users/keonkim/orgs","repos_url":"https://api.github.com/users/keonkim/repos","events_url":"https://api.github.com/users/keonkim/events{/privacy}","received_events_url":"https://api.github.com/users/keonkim/received_events","type":"User","site_admin":false},"body":"I finished implementing basic structure of Imputer class. So I wanted to get your opinion about it.\r\n\r\nI renamed DatasetInfo to DatasetMapper, which accepts template parameter of MapPolicy. ( can be used to store different kinds of maps.)\r\nDatasetMapper, however, still provides backward compatibility with typedef:\r\n`using DatasetInfo = DatasetMapper<IncrementPolicy>`. The IncrementPolicy denotes the original mapping policy used, which increments numbers for different categories, starting from 0.\r\n\r\nI believe what is left is to connect it with data::Load function so that it creates maps for missing values.\r\n\r\nImputer class is also added in this pull request. Imputer also accepts template parameters, so that different strategies can be applied. \r\n\r\nStrategies and tests are yet to be fully implemented.\r\n\r\nOverall flow of the DatasetMapper and Imputer can be derived from [preprocess_imputer_main.hpp](https://github.com/keonkim/mlpack/blob/5a517c25ef55de1f4814dc3605190d17f868ff82/src/mlpack/methods/preprocess/preprocess_imputer_main.cpp)","created_at":"2016-06-14T03:23:20Z","updated_at":"2016-07-11T03:13:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1f9c1d9b81771690e5ab5484918a4ac9a433fcdd","assignee":{"login":"keonkim","id":10793962,"avatar_url":"https://avatars.githubusercontent.com/u/10793962?v=3","gravatar_id":"","url":"https://api.github.com/users/keonkim","html_url":"https://github.com/keonkim","followers_url":"https://api.github.com/users/keonkim/followers","following_url":"https://api.github.com/users/keonkim/following{/other_user}","gists_url":"https://api.github.com/users/keonkim/gists{/gist_id}","starred_url":"https://api.github.com/users/keonkim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keonkim/subscriptions","organizations_url":"https://api.github.com/users/keonkim/orgs","repos_url":"https://api.github.com/users/keonkim/repos","events_url":"https://api.github.com/users/keonkim/events{/privacy}","received_events_url":"https://api.github.com/users/keonkim/received_events","type":"User","site_admin":false},"assignees":[{"login":"keonkim","id":10793962,"avatar_url":"https://avatars.githubusercontent.com/u/10793962?v=3","gravatar_id":"","url":"https://api.github.com/users/keonkim","html_url":"https://github.com/keonkim","followers_url":"https://api.github.com/users/keonkim/followers","following_url":"https://api.github.com/users/keonkim/following{/other_user}","gists_url":"https://api.github.com/users/keonkim/gists{/gist_id}","starred_url":"https://api.github.com/users/keonkim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keonkim/subscriptions","organizations_url":"https://api.github.com/users/keonkim/orgs","repos_url":"https://api.github.com/users/keonkim/repos","events_url":"https://api.github.com/users/keonkim/events{/privacy}","received_events_url":"https://api.github.com/users/keonkim/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/mlpack/mlpack/pulls/694/commits","review_comments_url":"https://api.github.com/repos/mlpack/mlpack/pulls/694/comments","review_comment_url":"https://api.github.com/repos/mlpack/mlpack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mlpack/mlpack/issues/694/comments","statuses_url":"https://api.github.com/repos/mlpack/mlpack/statuses/fedc5e0ece901746ad15b9c13244713bb36d4f9e","head":{"label":"keonkim:imputer","ref":"imputer","sha":"fedc5e0ece901746ad15b9c13244713bb36d4f9e","user":{"login":"keonkim","id":10793962,"avatar_url":"https://avatars.githubusercontent.com/u/10793962?v=3","gravatar_id":"","url":"https://api.github.com/users/keonkim","html_url":"https://github.com/keonkim","followers_url":"https://api.github.com/users/keonkim/followers","following_url":"https://api.github.com/users/keonkim/following{/other_user}","gists_url":"https://api.github.com/users/keonkim/gists{/gist_id}","starred_url":"https://api.github.com/users/keonkim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keonkim/subscriptions","organizations_url":"https://api.github.com/users/keonkim/orgs","repos_url":"https://api.github.com/users/keonkim/repos","events_url":"https://api.github.com/users/keonkim/events{/privacy}","received_events_url":"https://api.github.com/users/keonkim/received_events","type":"User","site_admin":false},"repo":{"id":59725655,"name":"mlpack","full_name":"keonkim/mlpack","owner":{"login":"keonkim","id":10793962,"avatar_url":"https://avatars.githubusercontent.com/u/10793962?v=3","gravatar_id":"","url":"https://api.github.com/users/keonkim","html_url":"https://github.com/keonkim","followers_url":"https://api.github.com/users/keonkim/followers","following_url":"https://api.github.com/users/keonkim/following{/other_user}","gists_url":"https://api.github.com/users/keonkim/gists{/gist_id}","starred_url":"https://api.github.com/users/keonkim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keonkim/subscriptions","organizations_url":"https://api.github.com/users/keonkim/orgs","repos_url":"https://api.github.com/users/keonkim/repos","events_url":"https://api.github.com/users/keonkim/events{/privacy}","received_events_url":"https://api.github.com/users/keonkim/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/keonkim/mlpack","description":"mlpack: a scalable C++ machine learning library","fork":true,"url":"https://api.github.com/repos/keonkim/mlpack","forks_url":"https://api.github.com/repos/keonkim/mlpack/forks","keys_url":"https://api.github.com/repos/keonkim/mlpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/keonkim/mlpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/keonkim/mlpack/teams","hooks_url":"https://api.github.com/repos/keonkim/mlpack/hooks","issue_events_url":"https://api.github.com/repos/keonkim/mlpack/issues/events{/number}","events_url":"https://api.github.com/repos/keonkim/mlpack/events","assignees_url":"https://api.github.com/repos/keonkim/mlpack/assignees{/user}","branches_url":"https://api.github.com/repos/keonkim/mlpack/branches{/branch}","tags_url":"https://api.github.com/repos/keonkim/mlpack/tags","blobs_url":"https://api.github.com/repos/keonkim/mlpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/keonkim/mlpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/keonkim/mlpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/keonkim/mlpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/keonkim/mlpack/statuses/{sha}","languages_url":"https://api.github.com/repos/keonkim/mlpack/languages","stargazers_url":"https://api.github.com/repos/keonkim/mlpack/stargazers","contributors_url":"https://api.github.com/repos/keonkim/mlpack/contributors","subscribers_url":"https://api.github.com/repos/keonkim/mlpack/subscribers","subscription_url":"https://api.github.com/repos/keonkim/mlpack/subscription","commits_url":"https://api.github.com/repos/keonkim/mlpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/keonkim/mlpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/keonkim/mlpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/keonkim/mlpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/keonkim/mlpack/contents/{+path}","compare_url":"https://api.github.com/repos/keonkim/mlpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/keonkim/mlpack/merges","archive_url":"https://api.github.com/repos/keonkim/mlpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/keonkim/mlpack/downloads","issues_url":"https://api.github.com/repos/keonkim/mlpack/issues{/number}","pulls_url":"https://api.github.com/repos/keonkim/mlpack/pulls{/number}","milestones_url":"https://api.github.com/repos/keonkim/mlpack/milestones{/number}","notifications_url":"https://api.github.com/repos/keonkim/mlpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/keonkim/mlpack/labels{/name}","releases_url":"https://api.github.com/repos/keonkim/mlpack/releases{/id}","deployments_url":"https://api.github.com/repos/keonkim/mlpack/deployments","created_at":"2016-05-26T06:29:12Z","updated_at":"2016-05-26T06:29:15Z","pushed_at":"2016-07-11T03:11:49Z","git_url":"git://github.com/keonkim/mlpack.git","ssh_url":"git@github.com:keonkim/mlpack.git","clone_url":"https://github.com/keonkim/mlpack.git","svn_url":"https://github.com/keonkim/mlpack","homepage":null,"size":146351,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"mlpack:master","ref":"master","sha":"f5e98dc5cea1ca36a528950c7aa5a382a8790111","user":{"login":"mlpack","id":10216045,"avatar_url":"https://avatars.githubusercontent.com/u/10216045?v=3","gravatar_id":"","url":"https://api.github.com/users/mlpack","html_url":"https://github.com/mlpack","followers_url":"https://api.github.com/users/mlpack/followers","following_url":"https://api.github.com/users/mlpack/following{/other_user}","gists_url":"https://api.github.com/users/mlpack/gists{/gist_id}","starred_url":"https://api.github.com/users/mlpack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlpack/subscriptions","organizations_url":"https://api.github.com/users/mlpack/orgs","repos_url":"https://api.github.com/users/mlpack/repos","events_url":"https://api.github.com/users/mlpack/events{/privacy}","received_events_url":"https://api.github.com/users/mlpack/received_events","type":"Organization","site_admin":false},"repo":{"id":28149409,"name":"mlpack","full_name":"mlpack/mlpack","owner":{"login":"mlpack","id":10216045,"avatar_url":"https://avatars.githubusercontent.com/u/10216045?v=3","gravatar_id":"","url":"https://api.github.com/users/mlpack","html_url":"https://github.com/mlpack","followers_url":"https://api.github.com/users/mlpack/followers","following_url":"https://api.github.com/users/mlpack/following{/other_user}","gists_url":"https://api.github.com/users/mlpack/gists{/gist_id}","starred_url":"https://api.github.com/users/mlpack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlpack/subscriptions","organizations_url":"https://api.github.com/users/mlpack/orgs","repos_url":"https://api.github.com/users/mlpack/repos","events_url":"https://api.github.com/users/mlpack/events{/privacy}","received_events_url":"https://api.github.com/users/mlpack/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mlpack/mlpack","description":"mlpack: a scalable C++ machine learning library","fork":false,"url":"https://api.github.com/repos/mlpack/mlpack","forks_url":"https://api.github.com/repos/mlpack/mlpack/forks","keys_url":"https://api.github.com/repos/mlpack/mlpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mlpack/mlpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mlpack/mlpack/teams","hooks_url":"https://api.github.com/repos/mlpack/mlpack/hooks","issue_events_url":"https://api.github.com/repos/mlpack/mlpack/issues/events{/number}","events_url":"https://api.github.com/repos/mlpack/mlpack/events","assignees_url":"https://api.github.com/repos/mlpack/mlpack/assignees{/user}","branches_url":"https://api.github.com/repos/mlpack/mlpack/branches{/branch}","tags_url":"https://api.github.com/repos/mlpack/mlpack/tags","blobs_url":"https://api.github.com/repos/mlpack/mlpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mlpack/mlpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mlpack/mlpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/mlpack/mlpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mlpack/mlpack/statuses/{sha}","languages_url":"https://api.github.com/repos/mlpack/mlpack/languages","stargazers_url":"https://api.github.com/repos/mlpack/mlpack/stargazers","contributors_url":"https://api.github.com/repos/mlpack/mlpack/contributors","subscribers_url":"https://api.github.com/repos/mlpack/mlpack/subscribers","subscription_url":"https://api.github.com/repos/mlpack/mlpack/subscription","commits_url":"https://api.github.com/repos/mlpack/mlpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/mlpack/mlpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/mlpack/mlpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/mlpack/mlpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/mlpack/mlpack/contents/{+path}","compare_url":"https://api.github.com/repos/mlpack/mlpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mlpack/mlpack/merges","archive_url":"https://api.github.com/repos/mlpack/mlpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mlpack/mlpack/downloads","issues_url":"https://api.github.com/repos/mlpack/mlpack/issues{/number}","pulls_url":"https://api.github.com/repos/mlpack/mlpack/pulls{/number}","milestones_url":"https://api.github.com/repos/mlpack/mlpack/milestones{/number}","notifications_url":"https://api.github.com/repos/mlpack/mlpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mlpack/mlpack/labels{/name}","releases_url":"https://api.github.com/repos/mlpack/mlpack/releases{/id}","deployments_url":"https://api.github.com/repos/mlpack/mlpack/deployments","created_at":"2014-12-17T18:16:59Z","updated_at":"2016-07-10T16:00:27Z","pushed_at":"2016-07-11T03:11:50Z","git_url":"git://github.com/mlpack/mlpack.git","ssh_url":"git@github.com:mlpack/mlpack.git","clone_url":"https://github.com/mlpack/mlpack.git","svn_url":"https://github.com/mlpack/mlpack","homepage":null,"size":167040,"stargazers_count":1063,"watchers_count":1063,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":371,"mirror_url":null,"open_issues_count":68,"forks":371,"open_issues":68,"watchers":1063,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/694"},"html":{"href":"https://github.com/mlpack/mlpack/pull/694"},"issue":{"href":"https://api.github.com/repos/mlpack/mlpack/issues/694"},"comments":{"href":"https://api.github.com/repos/mlpack/mlpack/issues/694/comments"},"review_comments":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/694/comments"},"review_comment":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mlpack/mlpack/pulls/694/commits"},"statuses":{"href":"https://api.github.com/repos/mlpack/mlpack/statuses/fedc5e0ece901746ad15b9c13244713bb36d4f9e"}}}}
{"actor":{"display_login":"keonkim"}}