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

    https://github.com/apache/spark/pull/17117#discussion_r104819439
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala 
---
    @@ -335,17 +369,70 @@ class KMeans @Since("1.5.0") (
         model
       }
     
    +  /**
    +   * Check validity for interactions between parameters.
    +   */
    +  private def assertInitialModelValid(): Unit = {
    +    if ($(initMode) == MLlibKMeans.K_MEANS_INITIAL_MODEL) {
    +      if (isSet(initialModel)) {
    +        val initialModelK = $(initialModel).parentModel.k
    +        if (initialModelK != $(k)) {
    +          throw new IllegalArgumentException("The initial model's cluster 
count = " +
    +            s"$initialModelK, mismatched with k = $k.")
    +        }
    +      } else {
    +        throw new IllegalArgumentException("Users must set param 
initialModel if you choose " +
    +          "'initialModel' as the initialization algorithm.")
    +      }
    +    } else {
    +      if (isSet(initialModel)) {
    +        logWarning(s"Param initialModel will take no effect when initMode 
is $initMode.")
    +      }
    +    }
    +  }
    +
       @Since("1.5.0")
       override def transformSchema(schema: StructType): StructType = {
    +    assertInitialModelValid()
    --- End diff --
    
    Why this is not checked in `fit`?


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