Non hierarchical clustering: private API

PortfolioOptimisers.get_k_clusters_from_algFunction
get_k_clusters_from_alg(alg, D, k)

Partition the assets into k clusters with the given non-hierarchical algorithm.

The whole extension contract of AbstractNonHierarchicalClusteringAlgorithm: a new member is a struct and one method of this function.

Algorithm

The KMeansAlgorithm method runs these steps.

  1. Combine alg.rng and alg.seed with resolve_rng, giving rng. A stated seed copies alg.rng and seeds the copy, so alg.rng never advances and two calls of one estimator draw the same starts. A seed of nothing passes alg.rng itself through, so its state advances and the next call draws different starts.
  2. Call Clustering.kmeans(D, k; rng = rng, alg.kwargs...), giving the partition. Lloyd's algorithm runs inside that call, so the steps below kmeans belong to Clustering.jl.

Arguments

  • alg: Non-hierarchical clustering algorithm.
  • D: Distance matrix, assets x assets. Its columns are the points to cluster.
  • k: Number of clusters to produce.

Returns

Related

source