예제 #1
0
  public void calculate() {
    final int partitionCount = getPartitionsCount(documents);
    if (partitionCount == 0) {
      return;
    }

    int weightSum = 0;
    double contaminationSum = 0;

    for (Cluster cluster : clusters) {
      if (cluster.isOtherTopics()) {
        continue;
      }
      final double contamination = calculate(cluster, partitionCount);
      cluster.setAttribute(CONTAMINATION, contamination);

      contaminationSum += contamination * cluster.size();
      weightSum += cluster.size();
    }

    weightedAverageContamination = contaminationSum / weightSum;
  }
예제 #2
0
 public Integer apply(Cluster cluster) {
   return cluster.size();
 }