Cluster linkage - CyrilB1531/lodestar GitHub Wiki
Development build. This page describes
main, not a released package. The latest published Lodestar.Cluster is 0.1.0 โ read its documentation.
Home โบ Cluster โบ Partitioning
Linkage
How the distance between two clusters is measured when deciding which two to merge next.
public enum Linkage { Ward, Complete, Average, Single }
Members โ Ward merges the pair that least increases the within-cluster variance, and is the
default. Complete measures the largest distance between a member of one cluster and a member of
the other, Average the mean of those distances, and Single the smallest.
Example โ the same five points under the two extremes, where only the height of the last merge differs.
using Lodestar.Cluster;
double[] samples = [0.0, 1.0, 5.0, 6.0, 20.0];
AgglomerativeClustering single = AgglomerativeClustering.Fit(samples, 1, 2, Linkage.Single);
AgglomerativeClustering complete = AgglomerativeClustering.Fit(samples, 1, 2, Linkage.Complete);
double nearest = single.Distances[3]; // => 14
double farthest = complete.Distances[3]; // => 20
Remarks โ the choice changes the algorithm, not just the arithmetic. Single runs a
minimum spanning tree and never holds a distance matrix; the other three run the nearest-neighbour
chain over one, n(n โ 1)/2 doubles. The two paths are the reference's own, and they break ties
differently, which is why both are written rather than one generic loop.
Ward's height is a distance, not a variance: โ(2ยทnโnโ/(nโ+nโ)) times the distance between
the two centroids, so two samples three apart merge at 3. A library that reports the increase in
the sum of squares instead reports dยฒ/2 for the same tree, and its threshold does not carry across.
Applies to โ net10.0, netstandard2.0.
See also โ AgglomerativeClustering,
AgglomerativeClustering.Fit.
Members
| Member | What it does |
|---|