JuliaStats / MultivariateStats.jl

A Julia package for multivariate statistics and data analysis (e.g. dimension reduction)
Other
379 stars 86 forks source link

KernelPCA reconstruct problem #198

Open hzgzh opened 2 years ago

hzgzh commented 2 years ago

I try using KernelPCA to transform and reconstruct the data, but original data and reconstruct data is not approx.

using Plots,MultivariateStats
x = rand(10,100)
m = fit(KernelPCA,x;inverse =true
y=reconstruct(m, predict(m, x))
plot([x[1,:] y[1,:])

how to make the reconstruct data approximate the origin data

wildart commented 2 years ago

Kernel PCA reconstructions is always approximate, especially out-of-sample, as it generally requires solving a quadratic optimization problem. So, the reconstruction will be always off with respect to the original data. The package uses a heuristic for an approximate reconstruction, i.e. quadratic optimization, which produces even worst approximation. See https://github.com/JuliaStats/MultivariateStats.jl/issues/125 for references.