K-affine-spaces (KAS)

Theory / Background

Todo

Write up mathematical background here

Syntax

The following function runs KAS:

SubspaceClustering.kasFunction
kas(X::AbstractMatrix{<:Number}, d::AbstractVector{<:Integer};
    maxiters = 100,
    rng = default_rng(),
    init = [(randsubspace(rng, float(eltype(X)), size(X, 1), di), zeros(float(eltype(X)), size(X, 1))) for di in d],
    showprogress = false)

Cluster the N data points in the D×N data matrix X into K clusters via the K-affine-spaces (KAS) algorithm with corresponding affine space dimensions d[1],...,d[K]. Output is a KASResult containing the resulting cluster assignments c[1],...,c[N], affine space basis matrices U[1],...,U[K], bias vectors b[1],...,b[K], and metadata about the algorithm run.

KAS seeks to cluster data points by their affine space by minimizing the following total cost

\[\sum_{i=1}^N \| X[:, i] - (U[c[i]] U[c[i]]' (X[:, i] - b[c[i]]) + b[c[i]]) \|_2^2\]

with respect to the cluster assignments c[1],...,c[N], affine space basis matrices U[1],...,U[K], and bias vectors b[1],...,b[K].

Keyword arguments

  • maxiters::Integer = 100: maximum number of iterations
  • rng::AbstractRNG = default_rng(): random number generator (used when reinitializing the affine space for an empty cluster)
  • init::AbstractVector{<:Tuple{<:AbstractMatrix{TUb},<:AbstractVector{TUb}}} = [(randsubspace(rng, float(eltype(X)), size(X, 1), di), zeros(float(eltype(X)), size(X, 1))) for di in d]: vector of K initial pair of affine space basis matrices containing U[1],...,U[K] and bias vectors containing b[1],...,b[K] where TUb is a floating point type.
  • showprogress::Bool = false: whether to log progress during the algorithm run

See also KASResult.

source

The output has the following type:

SubspaceClustering.KASResultType
KASResult{
    TUb<:Union{AbstractFloat,Complex{<:AbstractFloat}},
    TU<:AbstractVector{<:AbstractMatrix{TUb}},
    Tb<:AbstractVector{<:AbstractVector{TUb}},
    Tc<:AbstractVector{<:Integer},
    T<:Real}

The output of kas.

Fields

  • U::TU: vector of affine space basis matrices U[1],...,U[K]
  • b::Tb: vector of bias vectors b[1],...,b[K]
  • c::Tc: vector of cluster assignments c[1],...,c[N]
  • iterations::Int: number of iterations performed
  • totalcost::T: final value of total cost function
  • counts::Vector{Int}: vector of cluster sizes counts[1],...,counts[K]
  • converged::Bool: final convergence status
source

Examples

KAS with equal subspace dimensions

Todo

Write up example here

KAS with different subspace dimensions

Todo

Write up example here

KAS with reproducible random number generation

Todo

Write up example here

KAS with custom initialization

Todo

Write up example here

KAS with custom initialization coming from clusters

Todo

Write up example here where the subspace initialization is estimated from clusters