File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
mllib/src/main/scala/org/apache/spark/mllib/clustering Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -210,9 +210,11 @@ class KMeans private (
210210
211211 val initStartTime = System .nanoTime()
212212
213+ val numRuns = if (initialModel.nonEmpty) runs else 1
214+
213215 val centers = initialModel match {
214216 case Some (kMeansCenters) => {
215- Array .tabulate(runs )(r => kMeansCenters.clusterCenters
217+ Array .tabulate(numRuns )(r => kMeansCenters.clusterCenters
216218 .map(s => new VectorWithNorm (s, Vectors .norm(s, 2.0 ))))
217219 }
218220 case None => {
@@ -227,10 +229,10 @@ class KMeans private (
227229 logInfo(s " Initialization with $initializationMode took " + " %.3f" .format(initTimeInSeconds) +
228230 " seconds." )
229231
230- val active = Array .fill(runs )(true )
231- val costs = Array .fill(runs )(0.0 )
232+ val active = Array .fill(numRuns )(true )
233+ val costs = Array .fill(numRuns )(0.0 )
232234
233- var activeRuns = new ArrayBuffer [Int ] ++ (0 until runs )
235+ var activeRuns = new ArrayBuffer [Int ] ++ (0 until numRuns )
234236 var iteration = 0
235237
236238 val iterationStartTime = System .nanoTime()
You can’t perform that action at this time.
0 commit comments