{"action":"created","comment":{"url":"https://api.github.com/repos/airbnb/aerosolve/pulls/comments/39779266","id":39779266,"diff_hunk":"@@ -0,0 +1,214 @@\n+package com.airbnb.aerosolve.training\n+\n+import java.util\n+\n+import com.airbnb.aerosolve.core.models.BoostedStumpsModel\n+import com.airbnb.aerosolve.core.models.DecisionTreeModel\n+import com.airbnb.aerosolve.core.models.ForestModel\n+import com.airbnb.aerosolve.core.Example\n+import com.airbnb.aerosolve.core.ModelRecord\n+import com.airbnb.aerosolve.core.util.Util\n+import com.typesafe.config.Config\n+import org.apache.spark.SparkContext\n+import org.apache.spark.SparkContext._\n+import org.apache.spark.rdd.RDD\n+import org.slf4j.{Logger, LoggerFactory}\n+\n+import scala.util.Random\n+import scala.util.Try\n+import scala.collection.JavaConversions._\n+import scala.collection.JavaConverters._\n+\n+// A boosted tree forest trainer.\n+// Alternates between fitting a tree and building one on the importance\n+// sampled outliers of previous trees.\n+object BoostedForestTrainer {\n+  private final val log: Logger = LoggerFactory.getLogger(\"BoostedForestTrainer\")\n+  \n+  case class BoostedForestTrainerOptions(candidateSize : Int,\n+                                         rankKey : String,\n+                                         rankThreshold : Double,\n+                                         maxDepth : Int,\n+                                         minLeafCount : Int,\n+                                         numTries : Int,\n+                                         splitCriteria : String,\n+                                         numTrees :Int,\n+                                         subsample : Double,\n+                                         iterations : Int,\n+                                         learningRate : Double)\n+                                         \n+  case class ForestResponse(tree : Int, leaf : Int, weight : Double)\n+  case class ForestResult(label : Double, sum : Double, response : Array[ForestResponse])\n+\n+  def train(sc : SparkContext,\n+            input : RDD[Example],\n+            config : Config,\n+            key : String) : ForestModel = {\n+    val candidateSize : Int = config.getInt(key + \".num_candidates\")\n+    val rankKey : String = config.getString(key + \".rank_key\")\n+    val rankThreshold : Double = config.getDouble(key + \".rank_threshold\")\n+    val maxDepth : Int = config.getInt(key + \".max_depth\")\n+    val minLeafCount : Int = config.getInt(key + \".min_leaf_items\")\n+    val numTries : Int = config.getInt(key + \".num_tries\")\n+    val splitCriteria : String = Try(config.getString(key + \".split_criteria\")).getOrElse(\"gini\")","path":"training/src/main/scala/com/airbnb/aerosolve/training/BoostedForestTrainer.scala","position":53,"original_position":53,"commit_id":"de0c103e18607f06cad34abfae8da59ab4c7d564","original_commit_id":"de0c103e18607f06cad34abfae8da59ab4c7d564","user":{"login":"deerzq","id":2186009,"avatar_url":"https://avatars.githubusercontent.com/u/2186009?v=3","gravatar_id":"","url":"https://api.github.com/users/deerzq","html_url":"https://github.com/deerzq","followers_url":"https://api.github.com/users/deerzq/followers","following_url":"https://api.github.com/users/deerzq/following{/other_user}","gists_url":"https://api.github.com/users/deerzq/gists{/gist_id}","starred_url":"https://api.github.com/users/deerzq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deerzq/subscriptions","organizations_url":"https://api.github.com/users/deerzq/orgs","repos_url":"https://api.github.com/users/deerzq/repos","events_url":"https://api.github.com/users/deerzq/events{/privacy}","received_events_url":"https://api.github.com/users/deerzq/received_events","type":"User","site_admin":false},"body":"A general comment not for this specific PR: we should refactor the config loading part to something like taskConfig = config.getConfig(key) then, param = taskConfig.getString(param_name). ","created_at":"2015-09-17T18:12:08Z","updated_at":"2015-09-17T18:12:08Z","html_url":"https://github.com/airbnb/aerosolve/pull/44#discussion_r39779266","pull_request_url":"https://api.github.com/repos/airbnb/aerosolve/pulls/44","_links":{"self":{"href":"https://api.github.com/repos/airbnb/aerosolve/pulls/comments/39779266"},"html":{"href":"https://github.com/airbnb/aerosolve/pull/44#discussion_r39779266"},"pull_request":{"href":"https://api.github.com/repos/airbnb/aerosolve/pulls/44"}}},"pull_request":{"url":"https://api.github.com/repos/airbnb/aerosolve/pulls/44","id":45242139,"html_url":"https://github.com/airbnb/aerosolve/pull/44","diff_url":"https://github.com/airbnb/aerosolve/pull/44.diff","patch_url":"https://github.com/airbnb/aerosolve/pull/44.patch","issue_url":"https://api.github.com/repos/airbnb/aerosolve/issues/44","number":44,"state":"open","locked":false,"title":"Boosted forest","user":{"login":"hectorgon","id":790997,"avatar_url":"https://avatars.githubusercontent.com/u/790997?v=3","gravatar_id":"","url":"https://api.github.com/users/hectorgon","html_url":"https://github.com/hectorgon","followers_url":"https://api.github.com/users/hectorgon/followers","following_url":"https://api.github.com/users/hectorgon/following{/other_user}","gists_url":"https://api.github.com/users/hectorgon/gists{/gist_id}","starred_url":"https://api.github.com/users/hectorgon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hectorgon/subscriptions","organizations_url":"https://api.github.com/users/hectorgon/orgs","repos_url":"https://api.github.com/users/hectorgon/repos","events_url":"https://api.github.com/users/hectorgon/events{/privacy}","received_events_url":"https://api.github.com/users/hectorgon/received_events","type":"User","site_admin":false},"body":"Boosted decision trees made scalable by importance sampling from the data set while building trees\r\nthen mini batch gradient descent in between.\r\n\r\n@deerzq @tension7 @sdemars ","created_at":"2015-09-17T01:07:45Z","updated_at":"2015-09-17T18:12:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8918145c1d538629d591eab69415d7a8814f7063","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/airbnb/aerosolve/pulls/44/commits","review_comments_url":"https://api.github.com/repos/airbnb/aerosolve/pulls/44/comments","review_comment_url":"https://api.github.com/repos/airbnb/aerosolve/pulls/comments{/number}","comments_url":"https://api.github.com/repos/airbnb/aerosolve/issues/44/comments","statuses_url":"https://api.github.com/repos/airbnb/aerosolve/statuses/de0c103e18607f06cad34abfae8da59ab4c7d564","head":{"label":"airbnb:hector_boost","ref":"hector_boost","sha":"de0c103e18607f06cad34abfae8da59ab4c7d564","user":{"login":"airbnb","id":698437,"avatar_url":"https://avatars.githubusercontent.com/u/698437?v=3","gravatar_id":"","url":"https://api.github.com/users/airbnb","html_url":"https://github.com/airbnb","followers_url":"https://api.github.com/users/airbnb/followers","following_url":"https://api.github.com/users/airbnb/following{/other_user}","gists_url":"https://api.github.com/users/airbnb/gists{/gist_id}","starred_url":"https://api.github.com/users/airbnb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/airbnb/subscriptions","organizations_url":"https://api.github.com/users/airbnb/orgs","repos_url":"https://api.github.com/users/airbnb/repos","events_url":"https://api.github.com/users/airbnb/events{/privacy}","received_events_url":"https://api.github.com/users/airbnb/received_events","type":"Organization","site_admin":false},"repo":{"id":35507603,"name":"aerosolve","full_name":"airbnb/aerosolve","owner":{"login":"airbnb","id":698437,"avatar_url":"https://avatars.githubusercontent.com/u/698437?v=3","gravatar_id":"","url":"https://api.github.com/users/airbnb","html_url":"https://github.com/airbnb","followers_url":"https://api.github.com/users/airbnb/followers","following_url":"https://api.github.com/users/airbnb/following{/other_user}","gists_url":"https://api.github.com/users/airbnb/gists{/gist_id}","starred_url":"https://api.github.com/users/airbnb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/airbnb/subscriptions","organizations_url":"https://api.github.com/users/airbnb/orgs","repos_url":"https://api.github.com/users/airbnb/repos","events_url":"https://api.github.com/users/airbnb/events{/privacy}","received_events_url":"https://api.github.com/users/airbnb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/airbnb/aerosolve","description":"A machine learning package built for humans.","fork":false,"url":"https://api.github.com/repos/airbnb/aerosolve","forks_url":"https://api.github.com/repos/airbnb/aerosolve/forks","keys_url":"https://api.github.com/repos/airbnb/aerosolve/keys{/key_id}","collaborators_url":"https://api.github.com/repos/airbnb/aerosolve/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/airbnb/aerosolve/teams","hooks_url":"https://api.github.com/repos/airbnb/aerosolve/hooks","issue_events_url":"https://api.github.com/repos/airbnb/aerosolve/issues/events{/number}","events_url":"https://api.github.com/repos/airbnb/aerosolve/events","assignees_url":"https://api.github.com/repos/airbnb/aerosolve/assignees{/user}","branches_url":"https://api.github.com/repos/airbnb/aerosolve/branches{/branch}","tags_url":"https://api.github.com/repos/airbnb/aerosolve/tags","blobs_url":"https://api.github.com/repos/airbnb/aerosolve/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/airbnb/aerosolve/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/airbnb/aerosolve/git/refs{/sha}","trees_url":"https://api.github.com/repos/airbnb/aerosolve/git/trees{/sha}","statuses_url":"https://api.github.com/repos/airbnb/aerosolve/statuses/{sha}","languages_url":"https://api.github.com/repos/airbnb/aerosolve/languages","stargazers_url":"https://api.github.com/repos/airbnb/aerosolve/stargazers","contributors_url":"https://api.github.com/repos/airbnb/aerosolve/contributors","subscribers_url":"https://api.github.com/repos/airbnb/aerosolve/subscribers","subscription_url":"https://api.github.com/repos/airbnb/aerosolve/subscription","commits_url":"https://api.github.com/repos/airbnb/aerosolve/commits{/sha}","git_commits_url":"https://api.github.com/repos/airbnb/aerosolve/git/commits{/sha}","comments_url":"https://api.github.com/repos/airbnb/aerosolve/comments{/number}","issue_comment_url":"https://api.github.com/repos/airbnb/aerosolve/issues/comments{/number}","contents_url":"https://api.github.com/repos/airbnb/aerosolve/contents/{+path}","compare_url":"https://api.github.com/repos/airbnb/aerosolve/compare/{base}...{head}","merges_url":"https://api.github.com/repos/airbnb/aerosolve/merges","archive_url":"https://api.github.com/repos/airbnb/aerosolve/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/airbnb/aerosolve/downloads","issues_url":"https://api.github.com/repos/airbnb/aerosolve/issues{/number}","pulls_url":"https://api.github.com/repos/airbnb/aerosolve/pulls{/number}","milestones_url":"https://api.github.com/repos/airbnb/aerosolve/milestones{/number}","notifications_url":"https://api.github.com/repos/airbnb/aerosolve/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/airbnb/aerosolve/labels{/name}","releases_url":"https://api.github.com/repos/airbnb/aerosolve/releases{/id}","created_at":"2015-05-12T19:11:57Z","updated_at":"2015-09-16T15:00:28Z","pushed_at":"2015-09-17T01:39:16Z","git_url":"git://github.com/airbnb/aerosolve.git","ssh_url":"git@github.com:airbnb/aerosolve.git","clone_url":"https://github.com/airbnb/aerosolve.git","svn_url":"https://github.com/airbnb/aerosolve","homepage":"http://airbnb.github.io/aerosolve/","size":4844,"stargazers_count":2183,"watchers_count":2183,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":190,"mirror_url":null,"open_issues_count":1,"forks":190,"open_issues":1,"watchers":2183,"default_branch":"master"}},"base":{"label":"airbnb:master","ref":"master","sha":"6e558604249899b4aecea57b5c56e3c5759f1a67","user":{"login":"airbnb","id":698437,"avatar_url":"https://avatars.githubusercontent.com/u/698437?v=3","gravatar_id":"","url":"https://api.github.com/users/airbnb","html_url":"https://github.com/airbnb","followers_url":"https://api.github.com/users/airbnb/followers","following_url":"https://api.github.com/users/airbnb/following{/other_user}","gists_url":"https://api.github.com/users/airbnb/gists{/gist_id}","starred_url":"https://api.github.com/users/airbnb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/airbnb/subscriptions","organizations_url":"https://api.github.com/users/airbnb/orgs","repos_url":"https://api.github.com/users/airbnb/repos","events_url":"https://api.github.com/users/airbnb/events{/privacy}","received_events_url":"https://api.github.com/users/airbnb/received_events","type":"Organization","site_admin":false},"repo":{"id":35507603,"name":"aerosolve","full_name":"airbnb/aerosolve","owner":{"login":"airbnb","id":698437,"avatar_url":"https://avatars.githubusercontent.com/u/698437?v=3","gravatar_id":"","url":"https://api.github.com/users/airbnb","html_url":"https://github.com/airbnb","followers_url":"https://api.github.com/users/airbnb/followers","following_url":"https://api.github.com/users/airbnb/following{/other_user}","gists_url":"https://api.github.com/users/airbnb/gists{/gist_id}","starred_url":"https://api.github.com/users/airbnb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/airbnb/subscriptions","organizations_url":"https://api.github.com/users/airbnb/orgs","repos_url":"https://api.github.com/users/airbnb/repos","events_url":"https://api.github.com/users/airbnb/events{/privacy}","received_events_url":"https://api.github.com/users/airbnb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/airbnb/aerosolve","description":"A machine learning package built for humans.","fork":false,"url":"https://api.github.com/repos/airbnb/aerosolve","forks_url":"https://api.github.com/repos/airbnb/aerosolve/forks","keys_url":"https://api.github.com/repos/airbnb/aerosolve/keys{/key_id}","collaborators_url":"https://api.github.com/repos/airbnb/aerosolve/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/airbnb/aerosolve/teams","hooks_url":"https://api.github.com/repos/airbnb/aerosolve/hooks","issue_events_url":"https://api.github.com/repos/airbnb/aerosolve/issues/events{/number}","events_url":"https://api.github.com/repos/airbnb/aerosolve/events","assignees_url":"https://api.github.com/repos/airbnb/aerosolve/assignees{/user}","branches_url":"https://api.github.com/repos/airbnb/aerosolve/branches{/branch}","tags_url":"https://api.github.com/repos/airbnb/aerosolve/tags","blobs_url":"https://api.github.com/repos/airbnb/aerosolve/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/airbnb/aerosolve/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/airbnb/aerosolve/git/refs{/sha}","trees_url":"https://api.github.com/repos/airbnb/aerosolve/git/trees{/sha}","statuses_url":"https://api.github.com/repos/airbnb/aerosolve/statuses/{sha}","languages_url":"https://api.github.com/repos/airbnb/aerosolve/languages","stargazers_url":"https://api.github.com/repos/airbnb/aerosolve/stargazers","contributors_url":"https://api.github.com/repos/airbnb/aerosolve/contributors","subscribers_url":"https://api.github.com/repos/airbnb/aerosolve/subscribers","subscription_url":"https://api.github.com/repos/airbnb/aerosolve/subscription","commits_url":"https://api.github.com/repos/airbnb/aerosolve/commits{/sha}","git_commits_url":"https://api.github.com/repos/airbnb/aerosolve/git/commits{/sha}","comments_url":"https://api.github.com/repos/airbnb/aerosolve/comments{/number}","issue_comment_url":"https://api.github.com/repos/airbnb/aerosolve/issues/comments{/number}","contents_url":"https://api.github.com/repos/airbnb/aerosolve/contents/{+path}","compare_url":"https://api.github.com/repos/airbnb/aerosolve/compare/{base}...{head}","merges_url":"https://api.github.com/repos/airbnb/aerosolve/merges","archive_url":"https://api.github.com/repos/airbnb/aerosolve/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/airbnb/aerosolve/downloads","issues_url":"https://api.github.com/repos/airbnb/aerosolve/issues{/number}","pulls_url":"https://api.github.com/repos/airbnb/aerosolve/pulls{/number}","milestones_url":"https://api.github.com/repos/airbnb/aerosolve/milestones{/number}","notifications_url":"https://api.github.com/repos/airbnb/aerosolve/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/airbnb/aerosolve/labels{/name}","releases_url":"https://api.github.com/repos/airbnb/aerosolve/releases{/id}","created_at":"2015-05-12T19:11:57Z","updated_at":"2015-09-16T15:00:28Z","pushed_at":"2015-09-17T01:39:16Z","git_url":"git://github.com/airbnb/aerosolve.git","ssh_url":"git@github.com:airbnb/aerosolve.git","clone_url":"https://github.com/airbnb/aerosolve.git","svn_url":"https://github.com/airbnb/aerosolve","homepage":"http://airbnb.github.io/aerosolve/","size":4844,"stargazers_count":2183,"watchers_count":2183,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":190,"mirror_url":null,"open_issues_count":1,"forks":190,"open_issues":1,"watchers":2183,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/airbnb/aerosolve/pulls/44"},"html":{"href":"https://github.com/airbnb/aerosolve/pull/44"},"issue":{"href":"https://api.github.com/repos/airbnb/aerosolve/issues/44"},"comments":{"href":"https://api.github.com/repos/airbnb/aerosolve/issues/44/comments"},"review_comments":{"href":"https://api.github.com/repos/airbnb/aerosolve/pulls/44/comments"},"review_comment":{"href":"https://api.github.com/repos/airbnb/aerosolve/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/airbnb/aerosolve/pulls/44/commits"},"statuses":{"href":"https://api.github.com/repos/airbnb/aerosolve/statuses/de0c103e18607f06cad34abfae8da59ab4c7d564"}}}}