Is there a name for the following (extremely simple) threshold-based clustering algorithm?
It does a pass over the data and creates a new cluster when no previous cluster is within a given distance threshold. Otherwise it assigns the point to the first close-enough cluster.
It's good enough if the data is already very well grouped and the within-cluster distances are only due to some tiny noise.
def cluster(data_points, threshold):
cluster_prototypes = []
labels = []
for p in data_points:
label = None
for i, c in enumerate(cluster_prototypes):
if distance(p, c) < threshold:
label = i
break
if label is None:
label = len(cluster_prototypes)
cluster_prototypes.append(p)
labels.append(label)
return labels