def findKMeansPerLabel(activations, k, labelCount, targetPath, indexLabelMapping):
   labels = None
   if indexLabelMapping != None:
      labels = utility.getLabelStrings(indexLabelMapping)
      
   # split activations by label
   activationsByLabel = []
   counter = 0
   while counter < labelCount:
      currentLabelIndex = activations.shape[1] - labelCount + counter
      logger.debug(currentLabelIndex)
      currentSelection = activations[activations[:, currentLabelIndex] == 1]
      activationsByLabel.append(currentSelection)
      counter += 1

   counter = 0
   clusters = []
   iterations = []
   for batch in activationsByLabel:
      if labels != None:
         logger.info('Running KMeans for label ' + labels[counter] + '.')
      else:
         logger.info('Running KMeans for label ' + str(counter))
      logger.debug("Batch shape: " + str(batch.shape))
      [c, i] = kMeans_core.runKMeans(batch, labelCount, k, MAX_ITERATIONS)
      clusters.extend(c)
      iterations.append(i)
      counter += 1

   kMeans_core.saveResults(clusters, iterations, targetPath)

   return [clusters, iterations]
def findKMeans(activations, k, labelCount, targetPath):
    logger.info("Running mixed KMeans, please wait...")
    [clusters, iterations] = kMeans_core.runKMeans(activations, labelCount, k,
                                                   MAX_ITERATIONS)
    kMeans_core.saveResults(clusters, iterations, targetPath)
    return [clusters, iterations]
def findKMeans(activations, k, labelCount, targetPath):
   logger.info("Running mixed KMeans, please wait...")
   [clusters, iterations] = kMeans_core.runKMeans(activations, labelCount, k, MAX_ITERATIONS)
   kMeans_core.saveResults(clusters, iterations, targetPath)
   return [clusters, iterations]