Skip to content

Commit

Permalink
Updated PR per comments from mengxr
Browse files Browse the repository at this point in the history
  • Loading branch information
jkbradley committed Jul 17, 2014
1 parent 6c7a2ec commit 4e9bd1e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ private[mllib] object LocalKMeans extends Logging {
if (j == 0) {
logWarning("kMeansPlusPlus initialization ran out of distinct points for centers." +
s" Using duplicate point for center k = $i.")
j = 1
centers(i) = points(0).toDense
} else {
centers(i) = points(j - 1).toDense
}
centers(i) = points(j-1).toDense
}

// Run up to maxIterations iterations of Lloyd's algorithm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ class KMeansSuite extends FunSuite with LocalSparkContext {
}

test("no distinct points") {
val data = sc.parallelize(Array(
Vectors.dense(1.0, 2.0, 3.0),
Vectors.dense(1.0, 2.0, 3.0),
Vectors.dense(1.0, 2.0, 3.0)
))
val data = sc.parallelize(
Array(
Vectors.dense(1.0, 2.0, 3.0),
Vectors.dense(1.0, 2.0, 3.0),
Vectors.dense(1.0, 2.0, 3.0)),
2)
val center = Vectors.dense(1.0, 2.0, 3.0)

// Make sure code runs.
Expand All @@ -75,10 +76,11 @@ class KMeansSuite extends FunSuite with LocalSparkContext {
}

test("more clusters than points") {
val data = sc.parallelize(Array(
Vectors.dense(1.0, 2.0, 3.0),
Vectors.dense(1.0, 3.0, 4.0)
))
val data = sc.parallelize(
Array(
Vectors.dense(1.0, 2.0, 3.0),
Vectors.dense(1.0, 3.0, 4.0)),
2)

// Make sure code runs.
var model = KMeans.train(data, k=3, maxIterations=1)
Expand Down

0 comments on commit 4e9bd1e

Please sign in to comment.