Skip to content

Commit

Permalink
Alias spark.mllib.{KMeans, KMeansModel}
Browse files Browse the repository at this point in the history
  • Loading branch information
yu-iskw committed Jul 1, 2015
1 parent f80319a commit badb481
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions mllib/src/main/scala/org/apache/spark/ml/clustering/KMeans.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import org.apache.spark.ml.param.shared.{HasFeaturesCol, HasMaxIter, HasPredicti
import org.apache.spark.ml.param.{Param, ParamMap, Params}
import org.apache.spark.ml.util.{Identifiable, SchemaUtils}
import org.apache.spark.ml.{Estimator, Model}
import org.apache.spark.mllib
import org.apache.spark.mllib.clustering.KMeans
import org.apache.spark.mllib.clustering.{KMeans => MLlibKMeans, KMeansModel => MLlibKMeansModel}
import org.apache.spark.mllib.linalg.{Vector, VectorUDT}
import org.apache.spark.sql.functions._
import org.apache.spark.sql.types._
Expand Down Expand Up @@ -105,7 +104,7 @@ private[clustering] trait KMeansParams
class KMeansModel private[ml] (
override val uid: String,
val paramMap: ParamMap,
val parentModel: mllib.clustering.KMeansModel
val parentModel: MLlibKMeansModel
) extends Model[KMeansModel] with KMeansParams {

override def copy(extra: ParamMap): KMeansModel = {
Expand Down Expand Up @@ -146,7 +145,7 @@ class KMeans(override val uid: String) extends Estimator[KMeansModel] with KMean
setK(2)
setMaxIter(20)
setRuns(1)
setInitializationMode(KMeans.K_MEANS_PARALLEL)
setInitializationMode(MLlibKMeans.K_MEANS_PARALLEL)
setInitializationSteps(5)
setEpsilon(1e-4)
setSeed(Utils.random.nextLong())
Expand All @@ -166,7 +165,7 @@ class KMeans(override val uid: String) extends Estimator[KMeansModel] with KMean

/** @group setParam */
def setInitializationMode(value: String): this.type = {
mllib.clustering.KMeans.validateInitializationMode(value)
MLlibKMeans.validateInitializationMode(value)
set(initializationMode, value)
}

Expand All @@ -193,7 +192,7 @@ class KMeans(override val uid: String) extends Estimator[KMeansModel] with KMean
val map = this.extractParamMap()
val rdd = dataset.select(col(map(featuresCol))).map { case Row(point: Vector) => point}

val algo = new mllib.clustering.KMeans()
val algo = new MLlibKMeans()
.setK(map(k))
.setMaxIterations(map(maxIter))
.setSeed(map(seed))
Expand Down

0 comments on commit badb481

Please sign in to comment.