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

    https://github.com/apache/spark/pull/6996#discussion_r33264586
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/tuning/Validation.scala 
---
    @@ -0,0 +1,190 @@
    +/*
    + * 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 org.apache.spark.Logging
    +import org.apache.spark.annotation.DeveloperApi
    +import org.apache.spark.ml.evaluation.Evaluator
    +import org.apache.spark.ml.param._
    +import org.apache.spark.ml.util.Identifiable
    +import org.apache.spark.ml.{Model, Estimator}
    +import org.apache.spark.sql.DataFrame
    +import org.apache.spark.sql.types.StructType
    +
    +import scala.reflect.ClassTag
    +
    +/**
    + * :: DeveloperApi ::
    + * Common params for [[TrainValidationSplitParams]] and 
[[CrossValidatorParams]].
    + */
    +@DeveloperApi
    +private[ml] trait ValidationParams extends Params {
    +
    +  /**
    +   * param for the estimator to be validated
    +   * @group param
    +   */
    +  val estimator: Param[Estimator[_]] = new Param(this, "estimator", 
"estimator for selection")
    +
    +  /** @group getParam */
    +  def getEstimator: Estimator[_] = $(estimator)
    +
    +  /**
    +   * param for estimator param maps
    +   * @group param
    +   */
    +  val estimatorParamMaps: Param[Array[ParamMap]] =
    +    new Param(this, "estimatorParamMaps", "param maps for the estimator")
    +
    +  /** @group getParam */
    +  def getEstimatorParamMaps: Array[ParamMap] = $(estimatorParamMaps)
    +
    +  /**
    +   * param for the evaluator used to select hyper-parameters that maximize 
the validated metric
    +   * @group param
    +   */
    +  val evaluator: Param[Evaluator] = new Param(this, "evaluator",
    +    "evaluator used to select hyper-parameters that maximize the validated 
metric")
    +
    +  /** @group getParam */
    +  def getEvaluator: Evaluator = $(evaluator)
    +}
    +
    +/**
    + * :: DeveloperApi ::
    + * Abstract class for validation approaches for hyper-parameter tuning.
    + */
    +@DeveloperApi
    +private[ml] abstract class Validation[M <: Model[M], V <: Validation[M, _] 
: ClassTag]
    +  (override val uid: String)
    +  extends Estimator[M]
    +  with Logging with ValidationParams {
    +
    +  def this() = this(Identifiable.randomUID("cv"))
    +
    +  /** @group setParam */
    +  def setEstimator(value: Estimator[_]): V = set(estimator, 
value).asInstanceOf[V]
    +
    +  /** @group setParam */
    +  def setEstimatorParamMaps(value: Array[ParamMap]): V =
    +    set(estimatorParamMaps, value).asInstanceOf[V]
    +
    +  /** @group setParam */
    +  def setEvaluator(value: Evaluator): V = set(evaluator, 
value).asInstanceOf[V]
    +
    +  override def fit(dataset: DataFrame): M = {
    +    val sqlCtx = dataset.sqlContext
    +    val est = $(estimator)
    +    val eval = $(evaluator)
    +    val epm = $(estimatorParamMaps)
    +    val numModels = epm.length
    +
    +    val metrics = validationLogic(dataset, est, eval, epm, numModels)
    +
    +    logInfo(s"Average validation metrics: ${metrics.toSeq}")
    --- End diff --
    
    why average? isn't this dumping all the validation metrics?


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