这是将训练集投影到特征空间的正确方法吗?MATLAB [英] Is this the right way of projecting the training set into the eigespace? MATLAB

查看:24
本文介绍了这是将训练集投影到特征空间的正确方法吗?MATLAB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下方法计算了 PCA:

I have computed PCA using the following :

function [signals,V] = pca2(data) 
[M,N] = size(data); 
data = reshape(data, M*N,1);
% subtract off the mean for each dimension 
mn = mean(data,2); 
data = bsxfun(@minus, data, mean(data,1));     
% construct the matrix Y 
Y = data'*data / (M*N-1); 
[V D] = eigs(Y, 10);   % reduce to 10 dimension
% project the original data 
signals = data * V;

我的问题是:

信号"是训练集到特征空间的投影吗?

Is "signals" is the projection of the training set into the eigenspace?

我在Amir Hossein"代码中看到,上述代码中作为数据"的居中图像向量"需要通过乘以特征空间基来投影到面部空间"中.我真的不明白为什么使用居中的图像向量进行投影?信号"还不够分类吗?

I saw in "Amir Hossein" code that "centered image vectors" that is "data" in the above code needs to be projected into the "facespace" by multiplying in the eigenspace basis's. I don't really understand why is the projection done using centered image vectors? Isn't "signals" enough for classification??

推荐答案

通过信号,我假设你的意思是问我们为什么要从图像的原始矢量形式中减去平均值.

By signals, I assume you mean to ask why are we subtracting the mean from raw vector form of image.

如果您考虑 PCA;它试图在数据变化最大的地方为您提供最佳方向.但是,由于您的图像可能仅包含正值,因此这些像素将始终为正值,这会误导,尤其是您的第一个也是最重要的特征向量.您可以搜索有关二阶矩矩阵的更多信息.但我会分享一个糟糕的油漆图像来解释它.对不起我的画.

If you think about PCA; it is trying to give you best direction where the data varies most. However, as your images contain pixel probably only positive values those pixels will always be on positive which will mislead, especially, your first and most important eigenvector. You can search more about second moment matrix. But I will share a bad paint image that explains it. Sorry about my drawing.

请忽略星星的大小;

星星:您的数据

红线:特征向量;

正如您在 2D 中很容易看到的那样,将数据居中可以为您的主成分提供更好的方向.如果您跳过这一步,您的第一个特征向量将偏向均值并导致较差的结果.

As you can easily see in 2D, centering the data can give better direction for your principal component. If you skip this step, your first eigenvector will bias on mean and cause poorer results.

这篇关于这是将训练集投影到特征空间的正确方法吗?MATLAB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆