Hi, I am a newbie to Julia. I am looking for a package for KPCA please. I tried using MultivariateStats, unfortunately, ran into the below issue
https://github.com/JuliaStats/MultivariateStats.jl/issues/164
I couldn’t find any other packages which would offer similar functionality - any ideas?
thanks
Rohit
jbrea
2
Hi
I can’t reproduce your issue with julia 1.7.1.
Can you run the following in a fresh julia session and report the full error you get?
using Pkg; Pkg.activate(temp = true); Pkg.add.(["MultivariateStats", "RDatasets"])
using MultivariateStats, RDatasets
# load iris dataset
iris = dataset("datasets", "iris")
Xtr = Matrix(iris[!,1:4])'
Xtr_labels = convert(Array, iris[!,5])
model = fit(
KernelPCA,
Xtr;
kernel = (x, y) -> x'y,
maxoutdim = 3,
inverse = true,
)
1 Like
@jbrea : Thanks mate. it works fine now. I should have tried with Julia 1.7.1.
ta!
1 Like
matnbo
4
You may also try package Jchemo.jl
using Jchemo, JchemoData,
using JLD2, CairoMakie, StatsBase
path_jdat = dirname(dirname(pathof(JchemoData)))
db = joinpath(path_jdat, "data/iris.jld2")
@load db dat
pnames(dat)
summ(dat.X)
X = dat.X[:, 1:4]
n = nro(X)
ntrain = 120
s = sample(1:n, ntrain; replace = false)
Xtrain = X[s, :]
Xtest = rmrow(X, s)
nlv = 3 ; gamma = 1e-2
fm = kpca(Xtrain; nlv = nlv, gamma = gamma) ;
pnames(fm)
fm.T # Scores
fm.P # Loadings
fm.T' * fm.T
fm.P' * fm.P
group = recodcat2int(dat.X.species[s])
plotxy(fm.T[:, 1], fm.T[:, 2], group).f
Jchemo.transform(fm, Xtest) # projection of new samples
res = Base.summary(fm) ;
pnames(res)
res.explvarx
Other kernel methods are available, for instance for kernel PLS.
1 Like