コード例 #1
0
def meanInClusterDistances(cluster):
  overlaps = []
  perms = list(permutations(cluster, 2))
  for (sdr1, sdr2) in perms:
    overlap = percentOverlap(sdr1, sdr2)
    overlaps.append(overlap)
  return sum(overlaps) / len(overlaps)
コード例 #2
0
def computeDistanceMat(sdrs):
  """
  Compute distance matrix between SDRs
  :param sdrs: (array of arrays) array of SDRs
  :return: distance matrix
  """
  numSDRs = len(sdrs)
  # calculate pairwise distance
  distanceMat = np.zeros((numSDRs, numSDRs), dtype=np.float64)
  for i in range(numSDRs):
    for j in range(numSDRs):
      distanceMat[i, j] = 1 - percentOverlap(sdrs[i], sdrs[j])
  return distanceMat
コード例 #3
0
def computeDistanceMat(sdrs):
    """
  Compute distance matrix between SDRs
  :param sdrs: (array of arrays) array of SDRs
  :return: distance matrix
  """
    numSDRs = len(sdrs)
    # calculate pairwise distance
    distanceMat = np.zeros((numSDRs, numSDRs), dtype=np.float64)
    for i in range(numSDRs):
        for j in range(numSDRs):
            distanceMat[i, j] = 1 - percentOverlap(sdrs[i], sdrs[j])
    return distanceMat