+ Dokumentation

#SPM-13: add work documentation 20m Cluster fertig
This commit is contained in:
Johannes Theiner 2019-04-25 16:19:23 +02:00
parent 368af15fd8
commit d9e041c1ae

View File

@ -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<Map<Integer, Map<String, String>>> {
instances = load(file);
}
/**
* get result of cluster analysis.
*
* @return Result
*/
@Override
public Map<Integer, Map<String, String>> getResult() {
if(result == null) {
@ -41,6 +46,7 @@ public class Cluster implements Analysis<Map<Integer, Map<String, String>>> {
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<Map<Integer, Map<String, String>>> {
}
assert fullCentroids != null;
//creating real cluster
SimpleKMeans kMeans = new SimpleKMeans();
try {
kMeans.setNumClusters(5);
@ -70,10 +77,16 @@ public class Cluster implements Analysis<Map<Integer, Map<String, String>>> {
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<String, String> map = new HashMap<>();