wildart/ManifoldLearning.jl

Update examples?

Closed this issue · 1 comments

The docs say to use transform(DiffMap, X; d=2, t=1, ɛ=1.0) but I get the error

UndefVarError: k not defined

Stacktrace:
 [1] (::getfield(MultivariateStats, Symbol("#kw##transform")))(::NamedTuple{(:d, :t, :ε),Tuple{Int64,Int64,Float64}}, ::typeof(transform), ::Type, ::Array{Float64,2}) at ./none:0
 [2] top-level scope at In[66]:4

Should the docs/readme be updated or is the api still in flux? I got this example working if you want to use it. Not sure how to get diffmap to return a circle like wikipedia claims (any ideas?). Isomap looks good though :)

# Create winding curve
t = collect(1:500) / 500 * 2π
X = zeros(3,500)
X[1,:] = cos.(t).*(.5cos.(6t).+1)
X[2,:] = sin.(t).*(.4cos.(6t).+1)
X[3,:] = 0.4sin.(6t)

# Isomap
Y = transform(fit(Isomap, X))
scatter(Y[1,:], Y[2,:], zcolor=t, legend=nothing, title="isomap")

# Diffmap
M = fit(DiffMap, X, ε=0.3 , t=8, maxoutdim=2)
Y = transform(M)
scatter(Y[1,:], Y[2,:], zcolor=t, legend=nothing, title="diffusion map")

windingcurve

isomap

diffmap

I fixed diffusion map, now it should work properly. Here is an example:

using ManifoldLearning, Plots, LinearAlgebra, StatsBase
X, _ = ManifoldLearning.spirals(1000, 0.02);
c = standardize(UnitRangeTransform, mapslices(norm, X, dims=1) |> vec, dims=1)
scatter3d(X[1,:], X[2,:], X[3,:], zcolor=c, legend=:none, ms=3., camera=(15.,15.))

spirals3D

R = transform(fit(DiffMap, X, α=0.5, t=5, ε=0.002))
scatter(R[1,:], R[2,:], zcolor=c, legend=:none, ms=3.)

spirals2D