|
|
Line 8: |
Line 8: |
| | | |
| | | |
- | == Introduction 引言 == | + | == 引言 == |
| + | 主成分分析(PCA)是一种能够极大提升无监督特征学习速度的数据降维算法。更重要的是,理解PCA算法,对实现'''白化'''算法有很大的帮助,很多算法都先用白化算法作预处理步骤。 |
| | | |
- | 【原文】:Principal Components Analysis (PCA) is a dimensionality reduction algorithm
| + | 假设你使用图像来训练算法,因为图像中相邻的像素高度相关,输入数据是有一定冗余的。具体来说,假如我们正在训练的16x16灰度值图像,记为一个256维向量 <math>\textstyle x \in \Re^{256}</math> ,其中特征值 <math>\textstyle x_j</math> 对应每个像素的亮度值。由于相邻像素间的相关性,PCA算法可以将输入向量转换为一个维数低很多的近似向量,而且误差非常小。 |
- | that can be used to significantly speed up your unsupervised feature learning
| + | |
- | algorithm. More importantly, understanding PCA will enable us to later
| + | |
- | implement '''whitening''', which is an important pre-processing step for many
| + | |
- | algorithms.
| + | |
| | | |
- | 【初译】:主成分分析是一种能够极大提升非监督学习速度的数据降维算法。更重要的,理解主成分分析算法对于学习implement whitening有很大的帮助,而implement whitening算法是一种很重要的预处理算法。
| + | == 实例和数学背景 == |
- | | + | 在我们的实例中,使用的输入数据集表示为 <math>\textstyle \{x^{(1)}, x^{(2)}, \ldots, x^{(m)}\}</math> ,维度 math>\textstyle n=2</math> 即 <math>\textstyle x^{(i)} \in \Re^2</math> 。假设我们想把数据从2维降到1维。(在实际应用中,我们也许需要把数据从256维降到50维;在这里使用低维数据,主要是为了更好地可视化算法的行为)。下图是我们的数据集: |
- | 【一审】:主成分分析是一种能够极大提升非监督学习速度的数据降维算法。更重要的,理解主成分分析算法将使我们能使用白化方法,白化处理是一种很重要的预处理算法。
| + | |
- | | + | |
- | 【二审】:主成分分析(PCA)是一种能够极大提升非监督特征学习速度的数据降维算法。更重要的是,理解PCA算法,对实现白化算法有很大的帮助,很多算法都先用白化算法作预处理步骤。
| + | |
- | | + | |
- | | + | |
- | 【原文】:Suppose you are training your algorithm on images. Then the input will be
| + | |
- | somewhat redundant, because the values of adjacent pixels in an image are
| + | |
- | highly correlated. Concretely, suppose we are training on 16x16 grayscale
| + | |
- | image patches. Then <math>\textstyle x \in \Re^{256}</math> are 256 dimensional vectors, with one
| + | |
- | feature <math>\textstyle x_j</math> corresponding to the intensity of each pixel. Because of the
| + | |
- | correlation between adjacent pixels, PCA will allow us to approximate the input with
| + | |
- | a much lower dimensional one, while incurring very little error.
| + | |
- | | + | |
- | 【初译】:假如通过图像输入来训练算法。那么输入数据是有一定冗余的,因为图像中相连的像素是强相关的。具体来说,假如我们正在训练16×16的灰度值图像,那么<math>\textstyle x \in \Re^{256}</math>的数据便是256维的向量,特征值<math>\textstyle x_j</math>表示每个像素的强度值。因为相连像素间具有相关性,PCA算法可以在保证产生很小的误差值的情况下近似的把输入数据投影到更低维的空间里。。
| + | |
- | | + | |
- | 【一审】:假设你使用图像来训练算法。那么输入数据是有一定冗余的,因为图像中相连的像素是强相关的。具体来说,假如我们正在训练16×16的灰度值图像,那么 <math>\textstyle x \in \Re^{256}</math>的数据便是256维的向量,特征值<math>\textstyle x_j</math>表示每个像素的强度值。因为相连像素间具有相关性,PCA算法可以在保证产生很小的误差值的情况下近似的把输入数据投影到更低维的空间里。
| + | |
- | | + | |
- | 【二审】:假设你使用图像来训练算法,那么输入数据是有一定冗余的,因为图像中相连的像素是强相关的。具体来说,假如我们正在训练的16x16灰度值图像,那么<math>\textstyle x \in \Re^{256}</math>是个256维向量,其中,特征值<math>\textstyle x_j</math>对应每个像素的亮度值。因为相连像素间具有相关性,PCA算法可以将输入向量转换为一个维数低很多的近似向量,并仅产生极小的误差。
| + | |
- | | + | |
- | | + | |
- | == Example and Mathematical Background 实例和数学背景 == | + | |
- | | + | |
- | | + | |
- | 【原文】:For our running example, we will use a dataset
| + | |
- | <math>\textstyle \{x^{(1)}, x^{(2)}, \ldots, x^{(m)}\}</math> with
| + | |
- | <math>\textstyle n=2</math> dimensional inputs, so that
| + | |
- | <math>\textstyle x^{(i)} \in \Re^2</math>.
| + | |
- | Suppose we want to reduce the data
| + | |
- | from 2 dimensions to 1. (In practice, we might want to reduce data
| + | |
- | from 256 to 50 dimensions, say; but using lower dimensional data in our example
| + | |
- | allows us to visualize the algorithms better.) Here is our dataset:
| + | |
- | | + | |
- | 【初译】:在我们的实例中,输入数据集<math>\textstyle \{x^{(1)}, x^{(2)}, \ldots, x^{(m)}\}</math>是<math>\textstyle n=2</math>维的数据,即<math>\textstyle x^{(i)} \in \Re^2</math>。假如想把数据从2维降到1维。(实际上,我们是想把数据从255维降到50维;但是用低维的数据我们可以用图形来更直观的解释算法)。
| + | |
- | | + | |
- | 【一审】:在我们的实例中,输入数据集<math>\textstyle \{x^{(1)}, x^{(2)}, \ldots, x^{(m)}\}</math>是<math>\textstyle n=2</math>维的数据,即<math>\textstyle x^{(i)} \in \Re^2</math>。假如想把数据从2维降到1维。(实际上,我们是想把数据从255维降到50维;但是用低维的数据我们可以用图形来更直观的解释算法)。
| + | |
- | | + | |
- | 【二审】:在我们的实例中,使用的输入数据集表示为<math>\textstyle \{x^{(1)}, x^{(2)}, \ldots, x^{(m)}\}</math>,维度<math>\textstyle n=2</math>,即<math>\textstyle x^{(i)} \in \Re^2</math>。假设我们想把数据从2维降到1维。(在实际应用中,我们往往需要把数据从256维降到50维;但在我们的示例中使用低维数据,可更直观的展现算法),下图是我们的数据集:
| + | |
| | | |
| [[File:PCA-rawdata.png|600px]] | | [[File:PCA-rawdata.png|600px]] |
| | | |
| + | 这些数据已经进行了预处理,使得每个特征 <math>\textstyle x_1</math> 和 <math>\textstyle x_2</math> 具有相同的均值(零)和方差。 |
| | | |
- | 【原文】:This data has already been pre-processed so that each of the features <math>\textstyle x_1</math> and <math>\textstyle x_2</math>
| + | 为方便展示,根据 <math>\textstyle x_1</math> 值的大小,我们将每个点分别涂上了三种颜色之一,但该颜色并不用于算法而仅用于图解。 |
- | have about the same mean (zero) and variance.
| + | |
| | | |
- | For the purpose of illustration, we have also colored each of the points one of
| + | PCA算法将寻找一个低维空间来投影我们的数据。从下图中可以看出, <math>\textstyle u_1</math> 是数据变化的主方向,而 <math>\textstyle u_2</math> 是次方向。 |
- | three colors, depending on their <math>\textstyle x_1</math> value; these colors are not used by the
| + | |
- | algorithm, and are for illustration only.
| + | |
- | | + | |
- | 【初译】:数据已经进行了预处理,所以特征值<math>\textstyle x_1</math>和<math>\textstyle x_2</math>有相近的平均值(零)和方差。
| + | |
- | | + | |
- | 为了更直观的区分,根据<math>\textstyle x_1</math>值的大小我们把它们分成了三种颜色。颜色的区分对于算法没有任何影响,仅仅是为了直观表示。
| + | |
- | | + | |
- | 【一审】:数据已经进行了预处理,所以特征值<math>\textstyle x_1</math>和<math>\textstyle x_2</math>有相近的平均值(零)和方差。
| + | |
- | | + | |
- | 为了更直观的区分,根据<math>\textstyle x_1</math>值的大小我们把它们分成了三种颜色。颜色的区分对于算法没有任何影响,仅仅是为了直观表示。
| + | |
- | | + | |
- | 【二审】:这些数据已经进行了预处理,所以每个特征值<math>\textstyle x_1</math>和<math>\textstyle x_2</math>有相同的平均值(零)和方差。
| + | |
- | | + | |
- | 为方便展示,根据<math>\textstyle x_1</math>值的大小,我们将每个点分别涂上了三种颜色的一种。该颜色并不用于算法而仅用于图解。
| + | |
- | | + | |
- | | + | |
- | 【原文】:PCA will find a lower-dimensional subspace onto which to project our data.
| + | |
- | From visually examining the data, it appears that <math>\textstyle u_1</math> is the principal direction of
| + | |
- | variation of the data, and <math>\textstyle u_2</math> the secondary direction of variation:
| + | |
- | | + | |
- | 【初译】:PCA算法的目的是为了选取一个数据投影的低维空间。从下图中可以看出,<math>\textstyle u_1</math>是数据变化的主方向,而<math>\textstyle u_2</math>是次方向。
| + | |
- | | + | |
- | 【一审】:PCA算法将选取一个低维空间来投影数据投影。从下图中可以看出,<math>\textstyle u_1</math>是数据变化的主方向,而<math>\textstyle u_2</math>是次方向。
| + | |
- | | + | |
- | 【二审】:PCA算法将选取一个低维空间来投影我们的数据。从下图中可以看出,<math>\textstyle u_1</math>是数据变化的主方向,而<math>\textstyle u_2</math>是次方向。
| + | |
| | | |
| [[File:PCA-u1.png | 600px]] | | [[File:PCA-u1.png | 600px]] |
| | | |
- | | + | 也就是说,数据在 <math>\textstyle u_1</math> 方向上的变化要比在 <math>\textstyle u_2</math> 方向上大。为更形式化地找出方向 <math>\textstyle u_1</math> 和 <math>\textstyle u_2</math> ,我们首先计算出矩阵 <math>\textstyle \Sigma</math> ,如下所示: |
- | 【原文】:I.e., the data varies much more in the direction <math>\textstyle u_1</math> than <math>\textstyle u_2</math>.
| + | |
- | To more formally find the directions <math>\textstyle u_1</math> and <math>\textstyle u_2</math>, we first compute the matrix <math>\textstyle \Sigma</math>
| + | |
- | as follows:
| + | |
- | | + | |
- | 【初译】:也就是说,<math>\textstyle u_1</math>方向上的数据要比<math>\textstyle u_2</math>方向的变化大。为了计算出方向<math>\textstyle u_1</math>和<math>\textstyle u_2</math>,我们首先要通过如下式子计算出矩阵<math>\textstyle \Sigma</math>:
| + | |
- | | + | |
- | 【一审】:举例说,<math>\textstyle u_1</math>方向上的数据要比<math>\textstyle u_2</math>方向的变化大。为了计算出方向<math>\textstyle u_1</math>和<math>\textstyle u_2</math>,我们首先计算出矩阵<math>\textstyle \Sigma</math>,如下:
| + | |
- | | + | |
- | 【二审】:也就是说,<math>\textstyle u_1</math>方向上的数据要比<math>\textstyle u_2</math>方向的变化大。为更正式地计算出方向<math>\textstyle u_1</math>和<math>\textstyle u_2</math>,我们首先计算出矩阵<math>\textstyle \Sigma</math>,如下所示:
| + | |
| | | |
| :<math>\begin{align} | | :<math>\begin{align} |
Line 106: |
Line 32: |
| \end{align}</math> | | \end{align}</math> |
| | | |
| + | 假设 <math>\textstyle x</math> 的均值为零,那么 <math>\textstyle \Sigma</math> 就是x的协方差矩阵。(符号 <math>\textstyle \Sigma</math> ,读"Sigma",是协方差矩阵的标准符号。虽然看起来与求和符号 <math>\sum_{i=1}^n i</math> 比较像,但它们其实是两个不同的概念。) |
| | | |
- | 【原文】:If <math>\textstyle x</math> has zero mean, then <math>\textstyle \Sigma</math> is exactly the covariance matrix of <math>\textstyle x</math>. (The symbol "<math>\textstyle \Sigma</math>", pronounced "Sigma", is the standard notation for denoting the covariance matrix. Unfortunately it looks just like the summation symbol, as in <math>\sum_{i=1}^n i</math>; but these are two different things.)
| + | 可以证明,数据变化的主方向 <math>\textstyle u_1</math> 就是协方差矩阵 <math>\textstyle \Sigma</math> 的主特征向量,而 <math>\textstyle u_2</math> 是次特征向量。 |
| | | |
- | It can then be shown that <math>\textstyle u_1</math>---the principal direction of variation of the data---is
| |
- | the top (principal) eigenvector of <math>\textstyle \Sigma</math>, and <math>\textstyle u_2</math> is
| |
- | the second eigenvector.
| |
| | | |
| 【初译】:假设<math>\textstyle x</math>的均值为零,那么<math>\textstyle \Sigma</math>就是<math>\textstyle x</math>的协方差矩阵。(符号<math>\textstyle \Sigma</math>,读"Sigma",是协方差矩阵的表示符。虽然看起来与求和符号<math>\sum_{i=1}^n i</math>比较像,但他们是两个不同的概念。) | | 【初译】:假设<math>\textstyle x</math>的均值为零,那么<math>\textstyle \Sigma</math>就是<math>\textstyle x</math>的协方差矩阵。(符号<math>\textstyle \Sigma</math>,读"Sigma",是协方差矩阵的表示符。虽然看起来与求和符号<math>\sum_{i=1}^n i</math>比较像,但他们是两个不同的概念。) |