-
Notifications
You must be signed in to change notification settings - Fork 22
rw
normalization non-negotiable for DiffusionMap
?
#33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I don't think the normalization below is correct, anyway. normalize!(L, α=α, norm=:sym) # Lᵅ = D⁻ᵅ*L*D⁻ᵅ
normalize!(L, α=α, norm=:rw) # M =(Dᵅ)⁻¹*Lᵅ see Wikipedia.
|
another bug I found:
here is my code, which does not assume # source https://www.crcv.ucf.edu/gauss/info/project/ccs/diffusion-maps-finite.pdf
function cory_diffusion_map((X)::Matrix{Float64}, kernel::Function, d::Int; t::Int=1)
# n_features = size(X)[1]
# for f = 1:n_features
# X[f, :] = (X[f, :] .- mean(X[f, :]))/ std(X[f, :])
# end
# compute Laplacian matrix
K = pairwise(kernel, eachcol(X), symmetric=true)
# normalize, to be a Markov chain transition matrix
D = diagm(vec(sum(K, dims=1)))
D⁻¹ = diagm(1 ./ diag(D))
L = D⁻¹ * K
@assert all(sum.(eachrow(L)) .≈ 1.0)
# eigen-decomposition
decomp = eigen(L)
# skip first (1.0) eigenvalue. sort highest to lowest otherwise.
idx = sortperm(decomp.values, rev=true)[2:end]
λs = decomp.values[idx][1:d]
Vs = decomp.vectors[:, idx][:, 1:d] * diagm(λs .^ t)
return Vs
end |
I now see that the current setup of anyway, is a PR welcome with three changes:
# normalize it
if α > 0
normalize!(L, α=α, norm=:sym) # L̃ = D⁻ᵅ*L*D⁻ᵅ
end
# random walk
normalize!(L, norm=:rw) # M =(D̃)⁻¹ * L̃
I'm reasonably confident the current set-up is broken since it cannot even handle the 2D S-shaped curve. my diffusion map code is able to beautifully recover the S-shaped curve. thanks. |
Just ran into the same issue and came to check if someone noticed the |
here is our implementation of diffusion maps we're using for a project. |
for the diffusion map, by default
α::Real=0.0
and this code here to normalize the kernel matrix is not called.I'm pretty sure the
normalize!(L, α=α, norm=:rw)
line is non-negotiable. otherwise, the kernel matrix will not have columns sum to one, breaking the theory behind the diffusion map. pretty sure this needs to happen to turn the matrix into a Markov transition matrix. see Sec. 2.1 here. agree? disagree?The text was updated successfully, but these errors were encountered: