Skip to content
13

Non hierarchical clustering

PortfolioOptimisers.KMeansAlgorithm Type
julia
struct KMeansAlgorithm{__T_rng, __T_seed, __T_kwargs} <: AbstractNonHierarchicalClusteringAlgorithm

K-means clustering algorithm configuration for non-hierarchical clustering in PortfolioOptimisers.jl.

KMeansAlgorithm is a composable clustering algorithm type that specifies the use of the k-means algorithm (via Clustering.kmeans) for constructing non-hierarchical clusterings from a distance matrix.

Fields

  • rng: Random number generator.

  • seed: Seed for the random number generator.

  • kwargs: Keyword arguments for Clustering.kmeans.

Constructors

julia
KMeansAlgorithm(;
    rng::Random.AbstractRNG = Random.default_rng(),
    seed::Option{<:Integer} = nothing,
    kwargs::NamedTuple = (;)
) -> KMeansAlgorithm

Keywords correspond to the struct's fields.

Validation

  • If kwargs contains weights, it must be a non-empty AbstractVector.

Examples

julia
julia> KMeansAlgorithm()
KMeansAlgorithm
     rng ┼ Random.TaskLocalRNG: Random.TaskLocalRNG()
    seed ┼ nothing
  kwargs ┴ @NamedTuple{}: NamedTuple()

Related

source