主成分分析与白化,这部分很简单,当然,其实是用Matlab比较简单,要是自己写SVD分解算法,足够研究好几个月的了。下面是我自己实现的练习答案,不保证完全正确,不过结果和网站上面给出的基本一致。

1.PCA in 2D

1.1 Step 1a: Implement PCA to obtain U

u = zeros(size(x, )); % You need to compute this
sigma = x * x' / size(x, 2);
[u,s,v]=svd(sigma);

1.2 Step 1b: Compute xRot, the projection on to the eigenbasis

xRot = zeros(size(x)); % You need to compute this
xRot=u'*x;

1.3 Step 2: Reduce the number of dimensions from 2 to 1.

k = ; % Use k =  and project the data onto the first eigenbasis
xHat = zeros(size(x)); % You need to compute this
x_ap=u(:,:k)'*x;
xHat(:k,:)=x_ap;
xHat=u*xHat;

1.4 Step 3: PCA Whitening

xPCAWhite = zeros(size(x)); % You need to compute this
xPCAWhite = diag(./sqrt(diag(s) + epsilon)) * u' * x;

1.5 Step 3: ZCA Whitening

xZCAWhite = zeros(size(x)); % You need to compute this
xZCAWhite=u * diag(./sqrt(diag(s) + epsilon)) * u' * x;

2.PCA and Whitening

2.1 Step 0b: Zero-mean the data (by row)

avg = mean(x, );
x = x - repmat(avg, size(x, ), );

2.2 Step 1a: Implement PCA to obtain xRot

xRot = zeros(size(x)); % You need to compute this
sigma = x * x' / size(x, 2);
[U,S,V]=svd(sigma);
xRot=U'*x;

2.3 Step 1b: Check your implementation of PCA

covar = zeros(size(x, )); % You need to compute this
covar = xRot * xRot' / size(xRot, 2);

2.4 Step 2: Find k, the number of components to retain

k = ; % Set k accordingly
sum_k=;
sum=trace(S);
for k=:size(S,)
sum_k=sum_k+S(k,k);
if(sum_k/sum>=0.99) %0.9
break;
end
end

2.5 Step 3: Implement PCA with dimension reduction

xHat = zeros(size(x));  % You need to compute this
xTilde = U(:,:k)' * x;
xHat(:k,:)=xTilde;
xHat=U*xHat;

2.6 Step 4a: Implement PCA with whitening and regularisation

xPCAWhite = diag(./sqrt(diag(S) + epsilon)) * U' * x;

2.7 Step 4b: Check your implementation of PCA whitening

covar = zeros(size(xPCAWhite, ));
covar = xPCAWhite * xPCAWhite' / size(xPCAWhite, 2);

2.8 Step 5: Implement ZCA whitening

xZCAWhite=U * diag(./sqrt(diag(S) + epsilon)) * U' * x;

最新文章

  1. 【译】Meteor 新手教程:在排行榜上添加新特性
  2. Git 总结
  3. awk命令和grep命令的使用
  4. Qt——动态库的创建和使用
  5. Web自动化测试工具调研
  6. Latex 页面样式
  7. Web Api 中返回JSON的正确做法
  8. 机器学习技法-决策树和CART分类回归树构建算法
  9. Android开发之bindService()通信
  10. 容易上手-类似ERP系统 简单特效
  11. 使用DiskGenius对虚拟机磁盘进行压缩
  12. 自学Zabbix3.6.4-触发器triggers dependencies依赖关系
  13. Django:(博客系统)使用使用mysql数据->后台管理tag/post/category的配置
  14. Linux驱动之USB总线驱动程序框架简析
  15. YourSQLDba遭遇.NET Framework Error 6522
  16. Django框架第一篇基础
  17. [洛谷]p1996约瑟夫环 &xdoj1311
  18. 一个进程(Process)最多可以生成多少个线程(Thread)
  19. 【WEB2.0】 网页调用QQ聊天(PC+M站)
  20. c#中的out和ref

热门文章

  1. 中南大学oj:1352: New Sorting Algorithm
  2. DLL封装Interface(接口)(D2007+win764位)
  3. [转]Oracle存储过程总结
  4. [转]Ext.grid常用属性和方法
  5. bootstrap插件(对话框)bootbox参数和自定义弹出框宽度设置
  6. THINKPHP短链接设置方法(路由设置)
  7. mysql的导入导出工具mysqldump命令详解
  8. Google工作原理
  9. 使用jquery将表单元素转json提交后台
  10. kd-tree理论以及在PCL 中的代码的实现