Skip to content

Commit

Permalink
Renamce validateInitializationMode to validateInitMode and
Browse files Browse the repository at this point in the history
remove throwing exception
  • Loading branch information
yu-iskw committed Jul 16, 2015
1 parent 97cfae3 commit 5a7d574
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private[clustering] trait KMeansParams
* @group expertParam
*/
final val initMode = new Param[String](this, "initMode", "initialization algorithm",
(value: String) => MLlibKMeans.validateInitializationMode(value))
(value: String) => MLlibKMeans.validateInitMode(value))

/** @group getExpertParam */
def getInitMode: String = $(initMode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class KMeans private (
* (Bahmani et al., Scalable K-Means++, VLDB 2012). Default: k-means||.
*/
def setInitializationMode(initializationMode: String): this.type = {
KMeans.validateInitializationMode(initializationMode)
KMeans.validateInitMode(initializationMode)
this.initializationMode = initializationMode
this
}
Expand Down Expand Up @@ -520,11 +520,12 @@ object KMeans {
MLUtils.fastSquaredDistance(v1.vector, v1.norm, v2.vector, v2.norm)
}

private[spark] def validateInitializationMode(initializationMode: String): Boolean = {
if (initializationMode != KMeans.RANDOM && initializationMode != KMeans.K_MEANS_PARALLEL) {
throw new IllegalArgumentException("Invalid initialization mode: " + initializationMode)
private[spark] def validateInitMode(initMode: String): Boolean = {
initMode match {
case KMeans.RANDOM => true
case KMeans.K_MEANS_PARALLEL => true
case _ => false
}
true
}
}

Expand Down

0 comments on commit 5a7d574

Please sign in to comment.