From d9e041c1ae8029dd2f8723b794c1ae3d707518ae Mon Sep 17 00:00:00 2001 From: joethei Date: Thu, 25 Apr 2019 16:19:23 +0200 Subject: [PATCH] + Dokumentation #SPM-13: add work documentation 20m Cluster fertig --- .../de/hsel/spm/baudas/analysis/Cluster.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/hsel/spm/baudas/analysis/Cluster.java b/src/main/java/de/hsel/spm/baudas/analysis/Cluster.java index d340747..10e25b1 100644 --- a/src/main/java/de/hsel/spm/baudas/analysis/Cluster.java +++ b/src/main/java/de/hsel/spm/baudas/analysis/Cluster.java @@ -10,7 +10,7 @@ import java.util.HashMap; import java.util.Map; /** - * Cluster Analysis + * Cluster Analysis. * * @author Johannes Theiner * @version 0.1 @@ -24,6 +24,11 @@ public class Cluster implements Analysis>> { instances = load(file); } + /** + * get result of cluster analysis. + * + * @return Result + */ @Override public Map> getResult() { if(result == null) { @@ -41,6 +46,7 @@ public class Cluster implements Analysis>> { e.printStackTrace(); } + //creating a single cluster to get average, weka has no way to get that from a bigger one. SimpleKMeans fullMeans = new SimpleKMeans(); Instances fullCentroids = null; try { @@ -54,6 +60,7 @@ public class Cluster implements Analysis>> { } assert fullCentroids != null; + //creating real cluster SimpleKMeans kMeans = new SimpleKMeans(); try { kMeans.setNumClusters(5); @@ -70,10 +77,16 @@ public class Cluster implements Analysis>> { ex.printStackTrace(); } } - return result; } + /** + * puts data into map. + * + * @param centroids cluster analysis result + * @param count current insert count + * @return count increment + */ private int putIntoMap(Instances centroids, int count) { for (int i = 0; i < centroids.numInstances(); i++) { Map map = new HashMap<>();