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

    https://github.com/apache/spark/pull/18313#discussion_r129122995
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/tuning/CrossValidator.scala ---
    @@ -113,15 +122,28 @@ class CrossValidator @Since("1.2.0") (@Since("1.4.0") 
override val uid: String)
           // multi-model training
           logDebug(s"Train split $splitIndex with multiple sets of 
parameters.")
           val models = est.fit(trainingDataset, 
epm).asInstanceOf[Seq[Model[_]]]
    -      trainingDataset.unpersist()
    +
           var i = 0
           while (i < numModels) {
             // TODO: duplicate evaluator to take extra params from input
             val metric = eval.evaluate(models(i).transform(validationDataset, 
epm(i)))
             logDebug(s"Got metric $metric for model trained with ${epm(i)}.")
    +        if (isDefined(modelPreservePath)) {
    +          models(i) match {
    +            case w: MLWritable =>
    +              // e.g. maxIter-5-regParam-0.001-split0-0.859
    +              val fileName = epm(i).toSeq.map(p => p.param.name + "-" + 
p.value).sorted
    +                .mkString("-") + s"-split$splitIndex-${math.rint(metric * 
1000) / 1000}"
    +              w.save(new Path($(modelPreservePath), fileName).toString)
    +            case _ =>
    +              // for third-party algorithms
    +              logWarning(models(i).uid + " did not implement MLWritable. 
Serialization omitted.")
    +          }
    +        }
             metrics(i) += metric
    --- End diff --
    
    @hhbyyh So I we need to set parameter default value `false`, only when user 
really need this they turn on this feature... I will discuss with @jkbradley 
later.


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