{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/74437070","id":74437070,"diff_hunk":"@@ -197,3 +197,28 @@ class ChiSqSelector @Since(\"1.3.0\") (\n     new ChiSqSelectorModel(indices)\n   }\n }\n+\n+/**\n+ * Creates a ChiSquared feature selector by False Positive Rate (FPR) test.\n+ * @param alpha the highest p-value for features to be kept\n+ */\n+@Since(\"2.1.0\")\n+class ChiSqSelectorByFpr @Since(\"2.1.0\") (\n+  @Since(\"2.1.0\") val alpha: Double) extends Serializable {\n+\n+  /**\n+   * Returns a ChiSquared feature selector by FPR.\n+   *\n+   * @param data an `RDD[LabeledPoint]` containing the labeled dataset with categorical features.\n+   *             Real-valued features will be treated as categorical for each distinct value.\n+   *             Apply feature discretizer before using this function.\n+   */\n+  @Since(\"2.1.0\")\n+  def fit(data: RDD[LabeledPoint]): ChiSqSelectorModel = {\n+    val indices = Statistics.chiSqTest(data)\n+      .zipWithIndex.filter { case (res, _) => res.pValue < alpha }","path":"mllib/src/main/scala/org/apache/spark/mllib/feature/ChiSqSelector.scala","position":23,"original_position":23,"commit_id":"04053ca207ef4aa955eddc3e65d09a4e03db6292","original_commit_id":"04053ca207ef4aa955eddc3e65d09a4e03db6292","user":{"login":"srowen","id":822522,"avatar_url":"https://avatars.githubusercontent.com/u/822522?v=3","gravatar_id":"","url":"https://api.github.com/users/srowen","html_url":"https://github.com/srowen","followers_url":"https://api.github.com/users/srowen/followers","following_url":"https://api.github.com/users/srowen/following{/other_user}","gists_url":"https://api.github.com/users/srowen/gists{/gist_id}","starred_url":"https://api.github.com/users/srowen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srowen/subscriptions","organizations_url":"https://api.github.com/users/srowen/orgs","repos_url":"https://api.github.com/users/srowen/repos","events_url":"https://api.github.com/users/srowen/events{/privacy}","received_events_url":"https://api.github.com/users/srowen/received_events","type":"User","site_admin":false},"body":"Yes I was thinking the model itself would get `ChiSqTestResult` and then could be configured to perform different types of selection in `transform` by a parameter to the model instance.","created_at":"2016-08-11T14:52:38Z","updated_at":"2016-08-11T14:52:38Z","html_url":"https://github.com/apache/spark/pull/14597#discussion_r74437070","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/14597","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/74437070"},"html":{"href":"https://github.com/apache/spark/pull/14597#discussion_r74437070"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/14597"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/14597","id":80913258,"html_url":"https://github.com/apache/spark/pull/14597","diff_url":"https://github.com/apache/spark/pull/14597.diff","patch_url":"https://github.com/apache/spark/pull/14597.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/14597","number":14597,"state":"open","locked":false,"title":"[SPARK-17017][MLLIB] add a chiSquare Selector based on False Positive Rate (FPR) test","user":{"login":"mpjlu","id":13826327,"avatar_url":"https://avatars.githubusercontent.com/u/13826327?v=3","gravatar_id":"","url":"https://api.github.com/users/mpjlu","html_url":"https://github.com/mpjlu","followers_url":"https://api.github.com/users/mpjlu/followers","following_url":"https://api.github.com/users/mpjlu/following{/other_user}","gists_url":"https://api.github.com/users/mpjlu/gists{/gist_id}","starred_url":"https://api.github.com/users/mpjlu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpjlu/subscriptions","organizations_url":"https://api.github.com/users/mpjlu/orgs","repos_url":"https://api.github.com/users/mpjlu/repos","events_url":"https://api.github.com/users/mpjlu/events{/privacy}","received_events_url":"https://api.github.com/users/mpjlu/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\nUnivariate feature selection works by selecting the best features based on univariate statistical tests. False Positive Rate (FPR) is a popular univariate statistical test for feature selection. We add a chiSquare Selector based on False Positive Rate (FPR) test in this PR, like it is implemented in scikit-learn. \r\nhttp://scikit-learn.org/stable/modules/feature_selection.html#univariate-feature-selection\r\n\r\n\r\n## How was this patch tested?\r\n\r\nAdd Scala ut\r\n\r\n","created_at":"2016-08-11T07:21:14Z","updated_at":"2016-08-11T14:52:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a48897dd872fd2e7313dc7a341c03d20625a5a31","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/14597/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/14597/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/14597/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/04053ca207ef4aa955eddc3e65d09a4e03db6292","head":{"label":"mpjlu:fprChiSquare","ref":"fprChiSquare","sha":"04053ca207ef4aa955eddc3e65d09a4e03db6292","user":{"login":"mpjlu","id":13826327,"avatar_url":"https://avatars.githubusercontent.com/u/13826327?v=3","gravatar_id":"","url":"https://api.github.com/users/mpjlu","html_url":"https://github.com/mpjlu","followers_url":"https://api.github.com/users/mpjlu/followers","following_url":"https://api.github.com/users/mpjlu/following{/other_user}","gists_url":"https://api.github.com/users/mpjlu/gists{/gist_id}","starred_url":"https://api.github.com/users/mpjlu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpjlu/subscriptions","organizations_url":"https://api.github.com/users/mpjlu/orgs","repos_url":"https://api.github.com/users/mpjlu/repos","events_url":"https://api.github.com/users/mpjlu/events{/privacy}","received_events_url":"https://api.github.com/users/mpjlu/received_events","type":"User","site_admin":false},"repo":{"id":64218821,"name":"spark","full_name":"mpjlu/spark","owner":{"login":"mpjlu","id":13826327,"avatar_url":"https://avatars.githubusercontent.com/u/13826327?v=3","gravatar_id":"","url":"https://api.github.com/users/mpjlu","html_url":"https://github.com/mpjlu","followers_url":"https://api.github.com/users/mpjlu/followers","following_url":"https://api.github.com/users/mpjlu/following{/other_user}","gists_url":"https://api.github.com/users/mpjlu/gists{/gist_id}","starred_url":"https://api.github.com/users/mpjlu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpjlu/subscriptions","organizations_url":"https://api.github.com/users/mpjlu/orgs","repos_url":"https://api.github.com/users/mpjlu/repos","events_url":"https://api.github.com/users/mpjlu/events{/privacy}","received_events_url":"https://api.github.com/users/mpjlu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mpjlu/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/mpjlu/spark","forks_url":"https://api.github.com/repos/mpjlu/spark/forks","keys_url":"https://api.github.com/repos/mpjlu/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mpjlu/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mpjlu/spark/teams","hooks_url":"https://api.github.com/repos/mpjlu/spark/hooks","issue_events_url":"https://api.github.com/repos/mpjlu/spark/issues/events{/number}","events_url":"https://api.github.com/repos/mpjlu/spark/events","assignees_url":"https://api.github.com/repos/mpjlu/spark/assignees{/user}","branches_url":"https://api.github.com/repos/mpjlu/spark/branches{/branch}","tags_url":"https://api.github.com/repos/mpjlu/spark/tags","blobs_url":"https://api.github.com/repos/mpjlu/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mpjlu/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mpjlu/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/mpjlu/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mpjlu/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/mpjlu/spark/languages","stargazers_url":"https://api.github.com/repos/mpjlu/spark/stargazers","contributors_url":"https://api.github.com/repos/mpjlu/spark/contributors","subscribers_url":"https://api.github.com/repos/mpjlu/spark/subscribers","subscription_url":"https://api.github.com/repos/mpjlu/spark/subscription","commits_url":"https://api.github.com/repos/mpjlu/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/mpjlu/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/mpjlu/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/mpjlu/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/mpjlu/spark/contents/{+path}","compare_url":"https://api.github.com/repos/mpjlu/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mpjlu/spark/merges","archive_url":"https://api.github.com/repos/mpjlu/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mpjlu/spark/downloads","issues_url":"https://api.github.com/repos/mpjlu/spark/issues{/number}","pulls_url":"https://api.github.com/repos/mpjlu/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/mpjlu/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/mpjlu/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mpjlu/spark/labels{/name}","releases_url":"https://api.github.com/repos/mpjlu/spark/releases{/id}","deployments_url":"https://api.github.com/repos/mpjlu/spark/deployments","created_at":"2016-07-26T12:17:42Z","updated_at":"2016-07-26T12:18:08Z","pushed_at":"2016-08-11T07:11:16Z","git_url":"git://github.com/mpjlu/spark.git","ssh_url":"git@github.com:mpjlu/spark.git","clone_url":"https://github.com/mpjlu/spark.git","svn_url":"https://github.com/mpjlu/spark","homepage":null,"size":179050,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"apache:master","ref":"master","sha":"0db373aaf87991207a7a8a09853b6fa602f0f45b","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","deployments_url":"https://api.github.com/repos/apache/spark/deployments","created_at":"2014-02-25T08:00:08Z","updated_at":"2016-08-11T13:23:59Z","pushed_at":"2016-08-11T14:50:45Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":509855,"stargazers_count":9629,"watchers_count":9629,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8954,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":456,"forks":8954,"open_issues":456,"watchers":9629,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/14597"},"html":{"href":"https://github.com/apache/spark/pull/14597"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/14597"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/14597/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/14597/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/14597/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/04053ca207ef4aa955eddc3e65d09a4e03db6292"}}}}
{"actor":{"display_login":"srowen"}}