liveBook · Manning

Agglomerative clustering

As explained in Build a Robo-Advisor with Python (From Scratch)

Agglomerative clustering is a bottom-up clustering technique in which each object starts as a singleton cluster and clusters are successively combined.

Agglomerative clustering builds a hierarchy from the bottom up: every asset begins alone, then the closest pair of current clusters is merged repeatedly until one cluster contains all assets. In hierarchical risk parity, the resulting linkage matrix records each merge and supports later asset ordering. section 11.2.4

For correlated assets, first derive a distance matrix from correlations, then compute distances between the resulting asset-distance profiles. At each iteration, select the smallest remaining distance, create a combined cluster, update its distances, and record the two children, merge distance, and cluster size. section 11.2.4

Eight-asset linkage

With VV, VB, AGG, VEA, BNDX, VWO, EMB, and DJP, the first recorded merge joins assets 0 and 1 at distance 0.2951. Later merges incorporate additional assets and clusters; the final row joins clusters 11 and 13 into an eight-asset cluster. section 11.2.4

How Build a Robo-Advisor with Python (From Scratch) covers it

How deep it goes
Works through iterative linkage-matrix construction and notes that a simpler implementation is inefficient for large asset sets.
Examples
Uses eight ETFs and assets—VV, VB, AGG, VEA, BNDX, VWO, EMB, and DJP—to produce a linkage matrix.
What you can do after
Apply it via SciPy or an explicit Python loop to construct an asset linkage matrix for hierarchical risk parity.
How it connects
Connects correlation matrices, distance matrices, linkage matrices, seriation, quasi-diagonalization, covariance matrices, and recursive bisection.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Robo-Advisor with Python (From Scratch). The section links point to the parts of the book it draws on.