File Exchange

image thumbnail

Kernel PCA and Pre-Image Reconstruction

version 1.4.0.0 (6.9 MB) by Quan Wang
standard PCA, Gaussian kernel PCA, polynomial kernel PCA, pre-image reconstruction

12 Downloads

Updated 02 Sep 2014

View Version History

View License

In this package, we implement standard PCA, kernel PCA, and pre-image reconstruction of Gaussian kernel PCA. We also provide three demos: (1) Two concentric spheres embedding; (2) Face classification with PCA/kPCA; (3) Active shape models with kPCA.
Standard PCA is not optimized for very high dimensional data. But our kernel PCA implementation is very efficient, and has been used in many research projects.

Cite As

Quan Wang (2020). Kernel PCA and Pre-Image Reconstruction (https://www.mathworks.com/matlabcentral/fileexchange/39715-kernel-pca-and-pre-image-reconstruction), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (29)

Maria Hernandez

Dear Wang:
I am trying your marvelous code on a project: I am treating images to detect outliers after that I need to reconstruct the original image to see the quality lost but the kPCA_PreImage function returns something completely different. I also tried erasing the eigenvalues ordering sentences but it did not work. ¿Could you please help me? Thanks in advance

Steffy Benny

GOUGAM Fawzi

hi, i have a matrix of (5,5), i want to reduced the dimensionality with your algorithm, is it possible ?? Thank you

xiaoming yin

Sadia Zaman Mishu

Hello. I am trying to implement this code for my dataset. I am using Indian Pine dataset (AVIRIS 92AV3C) which is a 3 dimensional dataset size of 145x145x220. There are 145x145 pixels and 220 bandsor features and there are 16 classes. I have converted the dataset into 2 dimensional dataset. Code is given below.
load Indian_pines.mat;
d=16;
[nr,nc,band]=size(indian_pines);% Size of the input data
totalpix=nr*nc; % total number of pixel
tddata=reshape(indian_pines,nr*nc,band); %converting from 3D to 2D data
DIST=distanceMatrix(tddata); %calculating distance matrix

when I am executing this line to calculate distance matrix it shows error something like this:
Error using repmat
Out of memory. Type HELP MEMORY for your options.

Error in distanceMatrix (line 15)
XX2=repmat(XX',N,1);
Can you please help me to sort out this problem?

Bran Sun

Hariprasad Kannan

Hi, the pre-image is not looking correct when I try to run demo1. Please, try to run it at your end and check.

Vladimir Cordeiro

Hi Wang, I have a small doubt. How do we define our own kernel here? I want to use an rbf kernel.

chen

Mohammed Baydoun

Mohammed Baydoun

kumud arora

Why the test data kernel is not centralized??

user06

which type of data should be used to execute this code?

danhe

ait mohamed linda

what is the form of the database to use

phil

Hi, Wang!
For several reasons, I need to do the KNN classifier after reducing the dimension of training and sampling data. When the type is guassian, it seems that the eigenvector will be complex number so that KNN is invaild. How can I solve this problem? Thanks so much.

Phil

Yan wang

mania

please help us to do fault detection in nonlinear systems with kernel pca. because i'm a starter in this field.

Quan Wang

Hi Cheung,

If you compute ||a-b||, you will have to use loops. MATLAB loops are slow, and distanceMatrix avoids using loops, thus is very fast.

如果用||a-b||,就需要是用MATLAB循环,而MATLAB循环非常慢。我的distanceMatrix就是一个巧妙避免使用循环的方法,因此很快。

Cheung

您好,请问在distanceMatrix函数中D=XX1+XX2-2*(X*X')起什么作用?如果使用gaussian的话,distance不应该直接就是||a-b||吗?请赐教,非常感谢!

Quan Wang

Dear all,

We have updated the code and the document. The code now generates exactly the same results as shown in the document. I am sorry for the confusion in previous versions of this package. The current version has lots of significant improvements.

Pradeesh

When running demo file why the 3rd fig is in 2d but not in 3d as plot3() is used to plot variable in 3d

Yan Ou

Siqi

So Good!

Siqi

Quan Wang

Beside, I myself am using this code package (v2.0) for a number of research projects. I am pretty sure the code works well and has been well optimized.

Quan Wang

Hi Kris. The "paper" (actually a course project report) was using unordered eigenvalues, while in the updated code I have decreasingly ordered eigenvalues. So the code is more "correct" in a scientific sense. If you want to generate the same results as the report, you can uncomment
"% eigValue=eigValue(1:min(size(X)));"
in kPCA.m.

Hope this helps!

Kris Villez

Dear Quan Wang,

Thanks for sharing your code. However, I am not able to reproduce the results displayed in Figure 3 and 4 of your paper.

For Figure 3, it is not clear what the order of the applied polynomial is.

For Figure 4, the two features are highly correlated while the should in fact be uncorrelated. I wondered if this is a mistake in the paper or in the code.

Thanks for your comments,
Kris

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!