File tree Expand file tree Collapse file tree 3 files changed +6
-7
lines changed Expand file tree Collapse file tree 3 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -50,10 +50,10 @@ public static void main(String[] args) {
50
50
KMeans <Album > kmeans = new KMeans <>(2 , albums );
51
51
List <KMeans <Album >.Cluster > clusters = kmeans .run (100 );
52
52
for (int clusterIndex = 0 ; clusterIndex < clusters .size (); clusterIndex ++) {
53
- System .out .println ("Cluster " + clusterIndex + " Avg Length " +
54
- clusters .get (clusterIndex ).centroid .dimensions .get (0 ) +
55
- " Avg Tracks " + clusters .get (clusterIndex ).centroid .dimensions .get (1 )
56
- + ": " + clusters .get (clusterIndex ).points );
53
+ System .out .printf ("Cluster %d Avg Length %f Avg Tracks %f: %s%n" ,
54
+ clusterIndex , clusters .get (clusterIndex ).centroid .dimensions .get (0 ),
55
+ clusters .get (clusterIndex ).centroid .dimensions .get (1 ),
56
+ clusters .get (clusterIndex ).points );
57
57
}
58
58
}
59
59
Original file line number Diff line number Diff line change @@ -92,8 +92,7 @@ public static void main(String[] args) {
92
92
KMeans <Governor > kmeans = new KMeans <>(2 , governors );
93
93
List <KMeans <Governor >.Cluster > govClusters = kmeans .run (100 );
94
94
for (int clusterIndex = 0 ; clusterIndex < govClusters .size (); clusterIndex ++) {
95
- System .out .println ("Cluster " + clusterIndex + ": "
96
- + govClusters .get (clusterIndex ).points );
95
+ System .out .printf ("Cluster %d: %s%n" , clusterIndex , govClusters .get (clusterIndex ).points );
97
96
}
98
97
}
99
98
Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ private void generateCentroids() {
117
117
}
118
118
List <Double > means = new ArrayList <>();
119
119
for (int i = 0 ; i < cluster .points .get (0 ).numDimensions ; i ++) {
120
- final int dimension = i ; // needed to use in scope of closure
120
+ int dimension = i ; // needed to use in scope of closure
121
121
Double dimensionMean = cluster .points .stream ()
122
122
.mapToDouble (x -> x .dimensions .get (dimension )).average ().getAsDouble ();
123
123
means .add (dimensionMean );
You can’t perform that action at this time.
0 commit comments