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

    https://github.com/apache/spark/pull/8377#discussion_r38117652
  
    --- Diff: docs/ml-guide.md ---
    @@ -868,6 +868,132 @@ jsc.stop();
     
     </div>
     
    +## Example: Model Selection via Train Validation Split
    +In addition to  `CrossValidator` Spark also offers
    
+[`TrainValidationSplit`](api/scala/index.html#org.apache.spark.ml.tuning.TrainValidationSplit)
 for hyper-parameter tuning.
    +`TrainValidationSplit` only evaluates each combination of parameters once 
as opposed to k times in
    + case of `CrossValidator`. It is therefore less expensive, but will not 
produce as reliable results.
    +
    +`TrainValidationSplit` takes an `Estimator`, a set of `ParamMap`s provided 
in the `estimatorParamMaps` parameter, and an
    +[`Evaluator`](api/scala/index.html#org.apache.spark.ml.Evaluator).
    +It begins by splitting the dataset into two parts using `trainRatio` 
parameter
    +which are used as separate training and test datasets. For example with 
`$trainRatio=0.75$` (default),
    +`TrainValidationSplit` will generate a training and test dataset pair 
where 75% of the data is used for training and 25% for validation.
    +Similar to `CrossValidator`, `TrainValidationSplit` also iterates through 
the set of `ParamMap`s.
    +For each combination of parameters, it trains the given `Estimator` and 
evaluates it using the given `Evaluator`.
    +The `ParamMap` which produces the best evaluation metric is selected as 
the best option.
    +`TrainValidationSplit` finally fits the `Estimator` using the best 
`ParamMap` and the entire dataset.
    +
    +<div class="codetabs">
    +
    +<div data-lang="scala" markdown="1">
    +{% highlight scala %}
    +import org.apache.spark.ml.evaluation.RegressionEvaluator
    +import org.apache.spark.ml.regression.LinearRegression
    +import org.apache.spark.ml.tuning.{ParamGridBuilder, TrainValidationSplit}
    +import org.apache.spark.mllib.util.MLUtils
    +import org.apache.spark.sql.SQLContext
    +import org.apache.spark.{SparkConf, SparkContext}
    --- End diff --
    
    No need for importing `SQLContext`, `SparkConf`, and `SparkContext` anymore


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to