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

    https://github.com/apache/spark/pull/18313#discussion_r128886371
  
    --- 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 --
    
    so you want to keep all the trained models in CrossValidatorModel?


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