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

    https://github.com/apache/spark/pull/19208#discussion_r148859381
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/tuning/CrossValidator.scala ---
    @@ -252,19 +252,29 @@ object CrossValidator extends 
MLReadable[CrossValidator] {
     class CrossValidatorModel private[ml] (
         @Since("1.4.0") override val uid: String,
         @Since("1.2.0") val bestModel: Model[_],
    -    @Since("1.5.0") val avgMetrics: Array[Double],
    -    @Since("2.3.0") val subModels: Option[Array[Array[Model[_]]]])
    +    @Since("1.5.0") val avgMetrics: Array[Double])
       extends Model[CrossValidatorModel] with CrossValidatorParams with 
MLWritable {
     
       /** A Python-friendly auxiliary constructor. */
       private[ml] def this(uid: String, bestModel: Model[_], avgMetrics: 
JList[Double]) = {
    -    this(uid, bestModel, avgMetrics.asScala.toArray, null)
    +    this(uid, bestModel, avgMetrics.asScala.toArray)
       }
     
    -  private[ml] def this(uid: String, bestModel: Model[_], avgMetrics: 
Array[Double]) = {
    -    this(uid, bestModel, avgMetrics, null)
    +  private var _subModels: Option[Array[Array[Model[_]]]] = None
    +
    +  @Since("2.3.0")
    +  private[tuning] def setSubModels(subModels: 
Option[Array[Array[Model[_]]]])
    +    : CrossValidatorModel = {
    +    _subModels = subModels
    +    this
       }
     
    +  @Since("2.3.0")
    +  def subModels: Array[Array[Model[_]]] = _subModels.get
    --- End diff --
    
    Also, can you please add a better Exception message?  If submodels are not 
available, then we should tell users to set the collectSubModels Param before 
fitting.


---

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

Reply via email to