Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4677#discussion_r25140124
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/tree/GradientBoostedTrees.scala ---
    @@ -76,8 +77,44 @@ class GradientBoostedTrees(private val boostingStrategy: 
BoostingStrategy)
       def run(input: JavaRDD[LabeledPoint]): GradientBoostedTreesModel = {
         run(input.rdd)
       }
    -}
     
    +  /**
    +   * Method to validate a gradient boosting model
    +   * @param trainInput Training dataset: RDD of 
[[org.apache.spark.mllib.regression.LabeledPoint]].
    +   * @param validateInput Validation dataset:
    +                          RDD of 
[[org.apache.spark.mllib.regression.LabeledPoint]].
    +                          Should follow same distribution as trainInput.
    +   * @return a gradient boosted trees model that can be used for prediction
    +   */
    +  def runWithValidation(
    +      trainInput: RDD[LabeledPoint],
    +      validateInput: RDD[LabeledPoint]): GradientBoostedTreesModel = {
    +    val algo = boostingStrategy.treeStrategy.algo
    +    algo match {
    +      case Regression => GradientBoostedTrees.boost(
    +        trainInput, validateInput, boostingStrategy, validate=true)
    +      case Classification =>
    +        // Map labels to -1, +1 so binary classification can be treated as 
regression.
    +        val remappedTrainInput = trainInput.map(
    +          x => new LabeledPoint((x.label * 2) - 1, x.features))
    +        val remappedValidateInput = trainInput.map(
    --- End diff --
    
    "trainInput" --> "validateInput"


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to