{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/23887529","id":23887529,"diff_hunk":"@@ -0,0 +1,69 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one or more\n+ * contributor license agreements.  See the NOTICE file distributed with\n+ * this work for additional information regarding copyright ownership.\n+ * The ASF licenses this file to You under the Apache License, Version 2.0\n+ * (the \"License\"); you may not use this file except in compliance with\n+ * the License.  You may obtain a copy of the License at\n+ *\n+ *    http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.apache.spark.mllib.feature\n+\n+import org.scalatest.FunSuite\n+\n+import org.apache.spark.mllib.linalg.Vectors\n+import org.apache.spark.mllib.regression.LabeledPoint\n+import org.apache.spark.mllib.util.MLlibTestSparkContext\n+\n+class ChiSqSelectorSuite extends FunSuite with MLlibTestSparkContext {\n+\n+  /*\n+   *  Contingency tables\n+   *  feature0 = {8.0, 0.0}\n+   *  class  0 1 2\n+   *    8.0||1|0|1|\n+   *    0.0||0|2|0|\n+   *\n+   *  feature1 = {7.0, 9.0}\n+   *  class  0 1 2\n+   *    7.0||1|0|0|\n+   *    9.0||0|2|1|\n+   *\n+   *  feature2 = {0.0, 6.0, 8.0, 5.0}\n+   *  class  0 1 2\n+   *    0.0||1|0|0|\n+   *    6.0||0|1|0|\n+   *    8.0||0|1|0|\n+   *    5.0||0|0|1|\n+   *\n+   *  Use chi-squared calculator from Internet\n+   */\n+\n+  test(\"ChiSqSelector transform test (sparse & dense vector)\") {\n+    val labeledDiscreteData = sc.parallelize(\n+      Seq(new LabeledPoint(0.0, Vectors.sparse(3, Array((0, 8.0), (1, 7.0)))),","path":"mllib/src/test/scala/org/apache/spark/mllib/feature/ChiSqSelectorSuite.scala","position":52,"original_position":52,"commit_id":"a6ad82af0d81cfcba022fcaa1831153a1f2c36d9","original_commit_id":"a6ad82af0d81cfcba022fcaa1831153a1f2c36d9","user":{"login":"mengxr","id":829644,"avatar_url":"https://avatars.githubusercontent.com/u/829644?v=3","gravatar_id":"","url":"https://api.github.com/users/mengxr","html_url":"https://github.com/mengxr","followers_url":"https://api.github.com/users/mengxr/followers","following_url":"https://api.github.com/users/mengxr/following{/other_user}","gists_url":"https://api.github.com/users/mengxr/gists{/gist_id}","starred_url":"https://api.github.com/users/mengxr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mengxr/subscriptions","organizations_url":"https://api.github.com/users/mengxr/orgs","repos_url":"https://api.github.com/users/mengxr/repos","events_url":"https://api.github.com/users/mengxr/events{/privacy}","received_events_url":"https://api.github.com/users/mengxr/received_events","type":"User","site_admin":false},"body":"Remove `new`. `LabeledPoint` is a case class.","created_at":"2015-01-31T07:57:17Z","updated_at":"2015-01-31T07:57:17Z","html_url":"https://github.com/apache/spark/pull/1484#discussion_r23887529","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/1484","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/23887529"},"html":{"href":"https://github.com/apache/spark/pull/1484#discussion_r23887529"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/1484"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/1484","id":18580761,"html_url":"https://github.com/apache/spark/pull/1484","diff_url":"https://github.com/apache/spark/pull/1484.diff","patch_url":"https://github.com/apache/spark/pull/1484.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/1484","number":1484,"state":"open","locked":false,"title":"[MLLIB] SPARK-5491 (ex SPARK-1473): Chi-square feature selection","user":{"login":"avulanov","id":939524,"avatar_url":"https://avatars.githubusercontent.com/u/939524?v=3","gravatar_id":"","url":"https://api.github.com/users/avulanov","html_url":"https://github.com/avulanov","followers_url":"https://api.github.com/users/avulanov/followers","following_url":"https://api.github.com/users/avulanov/following{/other_user}","gists_url":"https://api.github.com/users/avulanov/gists{/gist_id}","starred_url":"https://api.github.com/users/avulanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avulanov/subscriptions","organizations_url":"https://api.github.com/users/avulanov/orgs","repos_url":"https://api.github.com/users/avulanov/repos","events_url":"https://api.github.com/users/avulanov/events{/privacy}","received_events_url":"https://api.github.com/users/avulanov/received_events","type":"User","site_admin":false},"body":"The following is implemented: \r\n1) generic traits for feature selection and filtering\r\n2) trait for feature selection of LabeledPoint with discrete data\r\n3) traits for calculation of contingency table and chi squared\r\n4) class for chi-squared feature selection\r\n5) tests for the above\r\n\r\nNeeds some optimization in matrix operations.\r\n\r\nThis request is a try to implement feature selection for MLLIB, the previous work by the issue author @izendejas was not finished (https://issues.apache.org/jira/browse/SPARK-1473). This request is also related to data discretization issues: https://issues.apache.org/jira/browse/SPARK-1303 and https://issues.apache.org/jira/browse/SPARK-1216 that weren't merged.","created_at":"2014-07-18T11:35:23Z","updated_at":"2015-01-31T07:57:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"44ee2ad02d31f098f32405342b3f99c97a928358","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/1484/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/1484/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments/{number}","comments_url":"https://api.github.com/repos/apache/spark/issues/1484/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/a6ad82af0d81cfcba022fcaa1831153a1f2c36d9","head":{"label":"avulanov:featureselection","ref":"featureselection","sha":"a6ad82af0d81cfcba022fcaa1831153a1f2c36d9","user":{"login":"avulanov","id":939524,"avatar_url":"https://avatars.githubusercontent.com/u/939524?v=3","gravatar_id":"","url":"https://api.github.com/users/avulanov","html_url":"https://github.com/avulanov","followers_url":"https://api.github.com/users/avulanov/followers","following_url":"https://api.github.com/users/avulanov/following{/other_user}","gists_url":"https://api.github.com/users/avulanov/gists{/gist_id}","starred_url":"https://api.github.com/users/avulanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avulanov/subscriptions","organizations_url":"https://api.github.com/users/avulanov/orgs","repos_url":"https://api.github.com/users/avulanov/repos","events_url":"https://api.github.com/users/avulanov/events{/privacy}","received_events_url":"https://api.github.com/users/avulanov/received_events","type":"User","site_admin":false},"repo":{"id":21005447,"name":"spark","full_name":"avulanov/spark","owner":{"login":"avulanov","id":939524,"avatar_url":"https://avatars.githubusercontent.com/u/939524?v=3","gravatar_id":"","url":"https://api.github.com/users/avulanov","html_url":"https://github.com/avulanov","followers_url":"https://api.github.com/users/avulanov/followers","following_url":"https://api.github.com/users/avulanov/following{/other_user}","gists_url":"https://api.github.com/users/avulanov/gists{/gist_id}","starred_url":"https://api.github.com/users/avulanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avulanov/subscriptions","organizations_url":"https://api.github.com/users/avulanov/orgs","repos_url":"https://api.github.com/users/avulanov/repos","events_url":"https://api.github.com/users/avulanov/events{/privacy}","received_events_url":"https://api.github.com/users/avulanov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/avulanov/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/avulanov/spark","forks_url":"https://api.github.com/repos/avulanov/spark/forks","keys_url":"https://api.github.com/repos/avulanov/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/avulanov/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/avulanov/spark/teams","hooks_url":"https://api.github.com/repos/avulanov/spark/hooks","issue_events_url":"https://api.github.com/repos/avulanov/spark/issues/events{/number}","events_url":"https://api.github.com/repos/avulanov/spark/events","assignees_url":"https://api.github.com/repos/avulanov/spark/assignees{/user}","branches_url":"https://api.github.com/repos/avulanov/spark/branches{/branch}","tags_url":"https://api.github.com/repos/avulanov/spark/tags","blobs_url":"https://api.github.com/repos/avulanov/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/avulanov/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/avulanov/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/avulanov/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/avulanov/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/avulanov/spark/languages","stargazers_url":"https://api.github.com/repos/avulanov/spark/stargazers","contributors_url":"https://api.github.com/repos/avulanov/spark/contributors","subscribers_url":"https://api.github.com/repos/avulanov/spark/subscribers","subscription_url":"https://api.github.com/repos/avulanov/spark/subscription","commits_url":"https://api.github.com/repos/avulanov/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/avulanov/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/avulanov/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/avulanov/spark/issues/comments/{number}","contents_url":"https://api.github.com/repos/avulanov/spark/contents/{+path}","compare_url":"https://api.github.com/repos/avulanov/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/avulanov/spark/merges","archive_url":"https://api.github.com/repos/avulanov/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/avulanov/spark/downloads","issues_url":"https://api.github.com/repos/avulanov/spark/issues{/number}","pulls_url":"https://api.github.com/repos/avulanov/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/avulanov/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/avulanov/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/avulanov/spark/labels{/name}","releases_url":"https://api.github.com/repos/avulanov/spark/releases{/id}","created_at":"2014-06-19T15:27:48Z","updated_at":"2014-06-27T11:14:48Z","pushed_at":"2015-01-31T00:36:46Z","git_url":"git://github.com/avulanov/spark.git","ssh_url":"git@github.com:avulanov/spark.git","clone_url":"https://github.com/avulanov/spark.git","svn_url":"https://github.com/avulanov/spark","homepage":null,"size":86769,"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":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"0a95085f09754c7b883f29a2babb17209c6541bd","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}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-01-31T07:19:23Z","pushed_at":"2015-01-31T07:19:23Z","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":1177549,"stargazers_count":2714,"watchers_count":2714,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2388,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":324,"forks":2388,"open_issues":324,"watchers":2714,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/1484"},"html":{"href":"https://github.com/apache/spark/pull/1484"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/1484"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/1484/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/1484/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/1484/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/a6ad82af0d81cfcba022fcaa1831153a1f2c36d9"}}}}