17
17
18
18
package org .apache .spark .mllib .clustering
19
19
20
+ import org .apache .log4j .Logger
20
21
import org .apache .spark .{SparkConf , SparkContext }
21
22
import org .apache .spark .graphx ._
22
23
import org .apache .spark .mllib .clustering .PICLinalg .DMatrix
@@ -27,6 +28,8 @@ import scala.util.Random
27
28
28
29
class PIClusteringSuite extends FunSuite with LocalSparkContext {
29
30
31
+ val logger = Logger .getLogger(getClass.getName)
32
+
30
33
import org .apache .spark .mllib .clustering .PIClusteringSuite ._
31
34
32
35
val PIC = PIClustering
@@ -38,6 +41,7 @@ class PIClusteringSuite extends FunSuite with LocalSparkContext {
38
41
concentricCirclesTest()
39
42
}
40
43
44
+
41
45
def concentricCirclesTest () = {
42
46
val sigma = 1.0
43
47
val nIterations = 10
@@ -63,33 +67,13 @@ class PIClusteringSuite extends FunSuite with LocalSparkContext {
63
67
val (ccenters, estCollected) = PIC .run(sc, vertices, nClusters, nIterations)
64
68
println(s " Cluster centers: ${ccenters.mkString(" ," )} " +
65
69
s " \n Estimates: ${estCollected.mkString(" [" , " ," , " ]" )}" )
66
- assert(ccenters.size == circleSpecs.length," Did not get correct number of centers" )
67
- val clustGroupsList = estCollected.groupBy{ case ((vid, eigenV), clustNum) =>
68
- clustNum
69
- }.mapValues{
70
- _.map{ case ((vid, eigenV), clustNum) =>
71
- (vid, clustNum)
72
- }}.toList.sortBy(_._1)
73
-
74
-
75
- val ccentersOrdered = ccenters.sortBy(- 1.0 * _._2(0 ))
76
-
77
- // val joinedGroups = ccentersOrdered.(clustGroupsList.toMap)
78
- //
79
- // val clustValids = clustGroupsList.map{ case (clustNum, vidEigensList) =>
80
- // (clustNum, vidEigensList.size, vidEigensList.map{ (_._1 / 1000).toLong }}
81
- // assert(clustGroups.map{_._2.size} == circleSpecs.map{ p => p.nPoints },
82
- // "Incorrect match on clusterGroupsSize")
83
- // val matchedCentersAndPoints = ccentersOrdered.map{ case (groupId, loc) => groupId}.zip(clustGroups)
84
- // assert(matchedCentersAndPoints.map{_._2.size} == circleSpecs.map{ p => p.nPoints },
85
- // "Incorrect match on clusterGroupsSize
86
- //
87
- // assert(estCollected == circleSpecs.length,"Did not get correct number of centers")
70
+ assert(ccenters.size == circleSpecs.length, " Did not get correct number of centers" )
71
+
88
72
}
89
73
}
90
74
91
- def join [T <: Comparable [T ]](a : Map [T ,_], b : Map [T ,_]) = {
92
- (a.toSeq++ b.toSeq).groupBy(_._1).mapValues(_.map(_._2).toList)
75
+ def join [T <: Comparable [T ]](a : Map [T , _], b : Map [T , _]) = {
76
+ (a.toSeq ++ b.toSeq).groupBy(_._1).mapValues(_.map(_._2).toList)
93
77
}
94
78
95
79
ignore(" irisData" ) {
0 commit comments