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

    https://github.com/apache/spark/pull/7337#discussion_r34328160
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/tuning/TrainValidationSplit.scala ---
    @@ -0,0 +1,178 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.ml.tuning
    +
    +import scala.reflect.ClassTag
    +
    +import org.apache.spark.Logging
    +import org.apache.spark.annotation.Experimental
    +import org.apache.spark.ml.evaluation.Evaluator
    +import org.apache.spark.ml.{Estimator, Model}
    +import org.apache.spark.ml.param.{DoubleParam, ParamMap, ParamValidators}
    +import org.apache.spark.ml.util.Identifiable
    +import org.apache.spark.rdd.{RDD, PartitionwiseSampledRDD}
    +import org.apache.spark.sql.DataFrame
    +import org.apache.spark.sql.types.StructType
    +import org.apache.spark.util.Utils
    +import org.apache.spark.util.random.BernoulliCellSampler
    +
    +/**
    + * Params for [[TrainValidatorSplit]] and [[TrainValidatorSplitModel]].
    + */
    +private[ml] trait TrainValidatorSplitParams extends ValidatorParams {
    +  /**
    +   * Param for ratio between train and validation data. Must be between 0 
and 1.
    +   * Default: 0.75
    +   * @group param
    +   */
    +  val trainRatio: DoubleParam = new DoubleParam(this, "trainRatio",
    +    "ratio between training set and validation set (>= 0 && <= 1)", 
ParamValidators.inRange(0, 1))
    +
    +  /** @group getParam */
    +  def getTrainRatio: Double = $(trainRatio)
    +
    +  setDefault(trainRatio -> 0.75)
    +}
    +
    +/**
    + * :: Experimental ::
    + * Validation for hyper-parameter tuning.
    + * Randomly splits the input dataset into train and validation sets.
    + * And uses evaluation metric on the validation set to select the best 
model.
    + * Similar to CrossValidator, but only splits the set once.
    + */
    +@Experimental
    +class TrainValidatorSplit(override val uid: String) extends 
Estimator[TrainValidatorSplitModel]
    +  with TrainValidatorSplitParams with Logging {
    +
    +  def this() = this(Identifiable.randomUID("cv"))
    +
    +  /** @group setParam */
    +  def setEstimator(value: Estimator[_]): this.type = set(estimator, value)
    +
    +  /** @group setParam */
    +  def setEstimatorParamMaps(value: Array[ParamMap]): this.type = 
set(estimatorParamMaps, value)
    +
    +  /** @group setParam */
    +  def setEvaluator(value: Evaluator): this.type = set(evaluator, value)
    +
    +  /** @group setParam */
    +  def setTrainRatio(value: Double): this.type = set(trainRatio, value)
    +
    +  private[this] def sample[T: ClassTag](
    --- End diff --
    
    Ignore that comment, tried running the code and saw that 
`PartitionwiseSampledRDD`needs it


---
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