K-affine-spaces (KAS)
Theory / Background
Syntax
The following function runs KAS:
SubspaceClustering.kas — Function
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 iterationsrng::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 ofKinitial pair of affine space basis matrices containingU[1],...,U[K]and bias vectors containingb[1],...,b[K]whereTUbis a floating point type.showprogress::Bool = false: whether to log progress during the algorithm run
See also KASResult.
The output has the following type:
SubspaceClustering.KASResult — Type
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 matricesU[1],...,U[K]b::Tb: vector of bias vectorsb[1],...,b[K]c::Tc: vector of cluster assignmentsc[1],...,c[N]iterations::Int: number of iterations performedtotalcost::T: final value of total cost functioncounts::Vector{Int}: vector of cluster sizescounts[1],...,counts[K]converged::Bool: final convergence status