coursera机器学习第8周的常见问题(原文翻译)

原文地址:https://www.coursera.org/learn/machine-learning/discussions/weeks/8/threads/XLl24URmEea1pw5frt5utw

The lecture slides are nowavailable in the "Review" section of each week's course materials.

Q1)How do we know which are the most significant features to retain? Why can wechoose just the first K of them? They aren't naturally ordered by significanceare they? Wouldn't it make more sense to select the K most influentialdimensions?

Prof Ng doesn't get into the details of how Singular ValueDecomposition (SVD) works, but it turns out that the output of SVD is exactlywhat we need for the purposes of PCA. It does "spectraldecomposition" of the input matrix and gives it back expressed in a formin which it is obvious which are the important dimensions. The output of SVD is:

[U,S,V] = svd(Sigma);

Where Sigma is the covariance matrix. The output values U and Vare unitary matrices and the columns of U are the eigenvectors of thetransformation. S is a diagonal matrix, containing the correspondingeigenvalues in decreasing order. In order words, the SVD has done the work tofigure out which dimensions are the most significant and gives us the resultsin that order. Prof Ng does discuss this in the video entitled "Choosingthe Number or Principal Components" around the 7:00 mark. There are anumber of good articles on the web that give more information about SVD:

http://mathworld.wolfram.com/SingularValueDecomposition.html

https://en.wikipedia.org/wiki/Singular_value_decomposition

Here's the MATLAB doc for SVD:

http://www.mathworks.com/help/matlab/ref/svd.html

Q2)Why don't we need to compute the matrix inverse of U in order to recover thedata in the original dimensions?

Please have a look at the references about Singular ValueDecomposition above. It turns out that the U matrix that is returned has thespecial property that it is a Unitary Matrix. One of the special properties ofa Unitary Matrix is:

U1=U∗ wherethe "*" means "conjugate transpose".

Since we are dealing with real numbers here, this is equivalentto:

U1=UT

So we could compute the inverse and use that, but it would be awaste of energy and compute cycles.

Q3)From the video "Advice for Applying PCA": Why do we only use PCA onthe training set?

If you apply PCA to the entire data set, and then split the setinto training, validation, and test sets, then the data in the original testset will have an impact on the reduced training set.

That causes overfitting.

Ex7Programming Assignment FAQ

Note: Tutorialsand additional Test Cases are available in the Resources menu.

Q1)When I run the image compression step in ex7.m, the image comes out as auniform grey or brown color.

This means that you neglected to fill in the random centroidinitialization code in kMeansInitCentroids. The ex7.pdf file actuallygives you the code to use, but the grader does not grade this routine whichmakes it easy to miss.

Q2)K-Means: For robustness, be sure the initial centroids are unique

(thanksto students Cameron Willden and Paul Nel for raising this issue)

Sometimes when running K-Means, you may get an error message dueto having an empty cluster. This can happen if any of the initial centroids areidentical.

This is most common if you are compressing an image that haslarge areas of a uniform background color.

You can avoid this issue by modifying your kMeanInitCentroids.mscript as follows (updated April 20, 2018):

8
% create a matrix of only the unique rows
X_unq = unique(X, 'rows');
% create a random permutation of the rows  
randidx = randperm(size(X_unq, 1));
% take the first K rows as centroids
centroids = X_unq(randidx(1:K), :);

This code creates a matrix of the unique rows of X, thenrandomly selects from this matrix for the initial centroids.

翻译:

Q1)我们如何知道哪些是最重要的功能要保留?为什么我们只能选择第一个K?他们不是自然地按照意义排序吗?选择K最有影响力的维度不是更有意义吗?

吴教授没有深入讨论奇异值分解(SVD)如何工作的细节,但事实证明,SVD的输出正是我们在PCA中所需要的。它对输入矩阵进行谱分解,并以一种明显的形式给出它,这些是重要的维度。SVD的输出是:

[USV] = svdSigma;

其中Sigma是协方差矩阵。输出值UV是酉矩阵,U的列是变换的特征向量。S是对角矩阵,包含降序的相应特征值。换句话说,SVD已经完成了确定哪些维度最重要的工作,并按照该顺序给出了结果。Ng教授在7点左右的标题为选择数量或主要部分的视频中进行了讨论。网络上有许多优秀的文章可以提供有关SVD的更多信息:

http://mathworld.wolfram.com/SingularValueDecomposition.html

https://en.wikipedia.org/wiki/Singular_value_decomposition

这里是SVDMATLAB文档:

http://www.mathworks.com/help/matlab/ref/svd.html

Q2)为什么我们不需要计算U的矩阵逆以恢复原始维度中的数据?

请看看上面有关奇异值分解的参考资料。事实证明,返回的U矩阵具有它是酉矩阵的特殊性质。酉矩阵的一个特殊性质是:

  其中“*”表示共轭转置

由于我们在这里处理实数,这相当于:

所以我们可以计算逆并使用它,但这会浪费能量和计算周期。

Q3)从视频应用PCA的建议:为什么我们只在训练集上使用PCA

如果将PCA应用于整个数据集,然后将该组分解为训练集,验证集和测试集,那么原始测试集中的数据将对缩减的训练集产生影响。

这会导致过度配合。

Ex7编程作业常见问题

注意: “资源菜单中提供了教程和其他测试用例。

Q1)当我在ex7.m中运行图像压缩步骤时,图像以均匀的灰色或棕色显示。

这意味着您忽略了在kMeansInitCentroids填充随机质心初始化代码。该ex7.pdf文件实际上是给你用的代码,但年级不分级这个程序,这使得它很容易错过。

Q2K-Means:为了鲁棒性,确保初始质心是唯一的

(感谢学生Cameron WilldenPaul Nel提出这个问题)

有时,在运行K-Means时,由于有空集群,可能会收到错误消息。如果任何初始质心都相同,则可能发生这种情况。

如果您压缩具有大面积统一背景色的图像,这是最常见的。

您可以通过修改您的kMeanInitCentroids.m脚本来避免此问题,如下所示2018420日更新)

8

%仅创建唯一行的矩阵

X_unq = uniqueX'rows';

%创建行的随机排列 

randidx randperm =(大小(X_unq1));

%以前K行为质心

centroids = X_unqrandidx1K),:);

此代码创建X的唯一行的矩阵,然后从该矩阵中随机选择初始质心。




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值