{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/69826097","id":69826097,"diff_hunk":"@@ -137,14 +137,47 @@ class RandomForestSuite extends SparkFunSuite with MLlibTestSparkContext {\n     {\n       val fakeMetadata = new DecisionTreeMetadata(1, 0, 0, 0,\n         Map(), Set(),\n-        Array(3), Gini, QuantileStrategy.Sort,\n+        Array(2), Gini, QuantileStrategy.Sort,\n         0, 0, 0.0, 0, 0\n       )\n       val featureSamples = Array(0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2).map(_.toDouble)\n       val splits = RandomForest.findSplitsForContinuousFeature(featureSamples, fakeMetadata, 0)\n       assert(splits.length === 1)\n       assert(splits(0) === 1.0)\n     }\n+\n+    // find splits for constant feature\n+    {\n+      val fakeMetadata = new DecisionTreeMetadata(1, 0, 0, 0,\n+        Map(), Set(),\n+        Array(3), Gini, QuantileStrategy.Sort,\n+        0, 0, 0.0, 0, 0\n+      )\n+      val featureSamples = Array(0, 0, 0).map(_.toDouble)\n+      val featureSamplesEmpty = Array.empty[Double]\n+      val splits = RandomForest.findSplitsForContinuousFeature(featureSamples, fakeMetadata, 0)\n+      assert(splits === Array[Double]())\n+      val splitsEmpty =\n+        RandomForest.findSplitsForContinuousFeature(featureSamplesEmpty, fakeMetadata, 0)\n+      assert(splitsEmpty === Array[Double]())\n+    }\n+  }\n+\n+  test(\"train with constant features\") {\n+    val lp = LabeledPoint(1.0, Vectors.dense(0.0, 0.0, 0.0))\n+    val data = Array.fill(5)(lp)\n+    val rdd = sc.parallelize(data)\n+    val strategy = new OldStrategy(\n+          OldAlgo.Classification,\n+          Gini,\n+          maxDepth = 2,\n+          numClasses = 100,","path":"mllib/src/test/scala/org/apache/spark/ml/tree/impl/RandomForestSuite.scala","position":48,"original_position":48,"commit_id":"1b7f826c3ee6512affbac6edb4e6ac32d1dfa9f2","original_commit_id":"1b7f826c3ee6512affbac6edb4e6ac32d1dfa9f2","user":{"login":"MechCoder","id":1867024,"avatar_url":"https://avatars.githubusercontent.com/u/1867024?v=3","gravatar_id":"","url":"https://api.github.com/users/MechCoder","html_url":"https://github.com/MechCoder","followers_url":"https://api.github.com/users/MechCoder/followers","following_url":"https://api.github.com/users/MechCoder/following{/other_user}","gists_url":"https://api.github.com/users/MechCoder/gists{/gist_id}","starred_url":"https://api.github.com/users/MechCoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MechCoder/subscriptions","organizations_url":"https://api.github.com/users/MechCoder/orgs","repos_url":"https://api.github.com/users/MechCoder/repos","events_url":"https://api.github.com/users/MechCoder/events{/privacy}","received_events_url":"https://api.github.com/users/MechCoder/received_events","type":"User","site_admin":false},"body":"`numClasses=100`?","created_at":"2016-07-06T22:52:44Z","updated_at":"2016-07-06T22:52:44Z","html_url":"https://github.com/apache/spark/pull/12374#discussion_r69826097","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/12374","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/69826097"},"html":{"href":"https://github.com/apache/spark/pull/12374#discussion_r69826097"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/12374"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/12374","id":66410412,"html_url":"https://github.com/apache/spark/pull/12374","diff_url":"https://github.com/apache/spark/pull/12374.diff","patch_url":"https://github.com/apache/spark/pull/12374.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/12374","number":12374,"state":"open","locked":false,"title":"[SPARK-14610][ML] Remove superfluous split for continuous features in decision tree training","user":{"login":"sethah","id":7275795,"avatar_url":"https://avatars.githubusercontent.com/u/7275795?v=3","gravatar_id":"","url":"https://api.github.com/users/sethah","html_url":"https://github.com/sethah","followers_url":"https://api.github.com/users/sethah/followers","following_url":"https://api.github.com/users/sethah/following{/other_user}","gists_url":"https://api.github.com/users/sethah/gists{/gist_id}","starred_url":"https://api.github.com/users/sethah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sethah/subscriptions","organizations_url":"https://api.github.com/users/sethah/orgs","repos_url":"https://api.github.com/users/sethah/repos","events_url":"https://api.github.com/users/sethah/events{/privacy}","received_events_url":"https://api.github.com/users/sethah/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\nA nonsensical split is produced from method `findSplitsForContinuousFeature` for decision trees. This PR removes the superfluous split and updates unit tests accordingly. Additionally, an assertion to check that the number of found splits is `> 0` is removed, and instead features with zero possible splits are ignored. \r\n\r\n## How was this patch tested?\r\n\r\nA unit test was added to check that finding splits for a constant feature produces an empty array.\r\n\r\n","created_at":"2016-04-13T23:54:25Z","updated_at":"2016-07-06T22:52:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9a659c2db3783a195c8e4c70bfd8217978a9d1e2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/12374/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/12374/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/12374/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/1b7f826c3ee6512affbac6edb4e6ac32d1dfa9f2","head":{"label":"sethah:SPARK-14610","ref":"SPARK-14610","sha":"1b7f826c3ee6512affbac6edb4e6ac32d1dfa9f2","user":{"login":"sethah","id":7275795,"avatar_url":"https://avatars.githubusercontent.com/u/7275795?v=3","gravatar_id":"","url":"https://api.github.com/users/sethah","html_url":"https://github.com/sethah","followers_url":"https://api.github.com/users/sethah/followers","following_url":"https://api.github.com/users/sethah/following{/other_user}","gists_url":"https://api.github.com/users/sethah/gists{/gist_id}","starred_url":"https://api.github.com/users/sethah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sethah/subscriptions","organizations_url":"https://api.github.com/users/sethah/orgs","repos_url":"https://api.github.com/users/sethah/repos","events_url":"https://api.github.com/users/sethah/events{/privacy}","received_events_url":"https://api.github.com/users/sethah/received_events","type":"User","site_admin":false},"repo":{"id":38016887,"name":"spark","full_name":"sethah/spark","owner":{"login":"sethah","id":7275795,"avatar_url":"https://avatars.githubusercontent.com/u/7275795?v=3","gravatar_id":"","url":"https://api.github.com/users/sethah","html_url":"https://github.com/sethah","followers_url":"https://api.github.com/users/sethah/followers","following_url":"https://api.github.com/users/sethah/following{/other_user}","gists_url":"https://api.github.com/users/sethah/gists{/gist_id}","starred_url":"https://api.github.com/users/sethah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sethah/subscriptions","organizations_url":"https://api.github.com/users/sethah/orgs","repos_url":"https://api.github.com/users/sethah/repos","events_url":"https://api.github.com/users/sethah/events{/privacy}","received_events_url":"https://api.github.com/users/sethah/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sethah/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/sethah/spark","forks_url":"https://api.github.com/repos/sethah/spark/forks","keys_url":"https://api.github.com/repos/sethah/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sethah/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sethah/spark/teams","hooks_url":"https://api.github.com/repos/sethah/spark/hooks","issue_events_url":"https://api.github.com/repos/sethah/spark/issues/events{/number}","events_url":"https://api.github.com/repos/sethah/spark/events","assignees_url":"https://api.github.com/repos/sethah/spark/assignees{/user}","branches_url":"https://api.github.com/repos/sethah/spark/branches{/branch}","tags_url":"https://api.github.com/repos/sethah/spark/tags","blobs_url":"https://api.github.com/repos/sethah/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sethah/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sethah/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/sethah/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sethah/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/sethah/spark/languages","stargazers_url":"https://api.github.com/repos/sethah/spark/stargazers","contributors_url":"https://api.github.com/repos/sethah/spark/contributors","subscribers_url":"https://api.github.com/repos/sethah/spark/subscribers","subscription_url":"https://api.github.com/repos/sethah/spark/subscription","commits_url":"https://api.github.com/repos/sethah/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/sethah/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/sethah/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/sethah/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/sethah/spark/contents/{+path}","compare_url":"https://api.github.com/repos/sethah/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sethah/spark/merges","archive_url":"https://api.github.com/repos/sethah/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sethah/spark/downloads","issues_url":"https://api.github.com/repos/sethah/spark/issues{/number}","pulls_url":"https://api.github.com/repos/sethah/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/sethah/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/sethah/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sethah/spark/labels{/name}","releases_url":"https://api.github.com/repos/sethah/spark/releases{/id}","deployments_url":"https://api.github.com/repos/sethah/spark/deployments","created_at":"2015-06-24T23:36:53Z","updated_at":"2016-01-14T16:52:52Z","pushed_at":"2016-06-23T22:09:57Z","git_url":"git://github.com/sethah/spark.git","ssh_url":"git@github.com:sethah/spark.git","clone_url":"https://github.com/sethah/spark.git","svn_url":"https://github.com/sethah/spark","homepage":null,"size":172676,"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":"9493b079a0050f0a6f4936c17622b96fb185b67f","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-07-06T17:01:16Z","pushed_at":"2016-07-06T22:41:58Z","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":507962,"stargazers_count":9211,"watchers_count":9211,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8533,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":412,"forks":8533,"open_issues":412,"watchers":9211,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/12374"},"html":{"href":"https://github.com/apache/spark/pull/12374"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/12374"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/12374/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/12374/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/12374/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/1b7f826c3ee6512affbac6edb4e6ac32d1dfa9f2"}}}}
{"actor":{"display_login":"MechCoder"}}