Skip to content

Commit

Permalink
Change how to set the default values with setDefault
Browse files Browse the repository at this point in the history
  • Loading branch information
yu-iskw committed Jul 1, 2015
1 parent 11c2a12 commit 20a795a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ import org.apache.spark.util.Utils
*/
private[clustering] trait KMeansParams
extends Params with HasMaxIter with HasFeaturesCol with HasSeed with HasPredictionCol {

setDefault(k, 2)
setDefault(maxIter, 20)
setDefault(runs, 1)
setDefault(initializationMode, MLlibKMeans.K_MEANS_PARALLEL)
setDefault(initializationSteps, 5)
setDefault(epsilon, 1e-4)
setDefault(seed, Utils.random.nextLong())

/**
* Param for the column name for the number of clusters to create.
* @group param
Expand Down Expand Up @@ -142,13 +151,6 @@ class KMeansModel private[ml] (
*/
@Experimental
class KMeans(override val uid: String) extends Estimator[KMeansModel] with KMeansParams {
setK(2)
setMaxIter(20)
setRuns(1)
setInitializationMode(MLlibKMeans.K_MEANS_PARALLEL)
setInitializationSteps(5)
setEpsilon(1e-4)
setSeed(Utils.random.nextLong())

override def copy(extra: ParamMap): Estimator[KMeansModel] = defaultCopy(extra)

Expand Down

0 comments on commit 20a795a

Please sign in to comment.