MultivariateStats.jl
MultivariateStats.jl copied to clipboard
fitting `SubspaceLDA models fails.
The existing code for SubspaceLDA fails if for a given input matrix and target, the rank of the between-class covariance matrix is less than the number of classes minus one(i.e rank(Hw) < ncnz-1 ). This is shown by the code below:
julia> import MultivariateStats
julia> X1 = rand(5, 5);
julia> y1 = [1,2,3,2, 4];
julia> f = MultivariateStats.fit(MultivariateStats.SubspaceLDA, X1, y1)
ERROR: BoundsError: attempt to access 1×1 adjoint(::Matrix{Float64}) with eltype Float64 at index [1:1, 1:3]
Stacktrace:
[1] throw_boundserror(A::Adjoint{Float64, Matrix{Float64}}, I::Tuple{Base.Slice{Base.OneTo{Int64}}, UnitRange{Int64}})
@ Base .\abstractarray.jl:691
[2] checkbounds
@ .\abstractarray.jl:656 [inlined]
[3] _getindex
@ .\multidimensional.jl:838 [inlined]
[4] getindex
@ .\abstractarray.jl:1218 [inlined]
[5] lda_gsvd(Hb::Matrix{Float64}, Hw::Matrix{Float64}, cweights::Vector{Int64})