Sparse PCA: reproduction of the synthetic example
The paper:
Hui Zou, Trevor Hastie, and Robert Tibshirani,
Sparse Principal Component Analysis,
Journal of computational and Graphical Statistics, 15(2): 265-286, 2006.
Reproduction of the Synthetic Example in Section 5.2 using R programming:
library(elasticnet) ## sample version of SPCA
n =
v1 = rnorm(n,,sqrt())
v2 = rnorm(n,,sqrt())
v3 = -.*v1 + 0.925*v2 + rnorm(n)
x1 = v1 + rnorm(n)
x2 = v1 + rnorm(n)
x3 = v1 + rnorm(n)
x4 = v1 + rnorm(n) x5 = v2 + rnorm(n)
x6 = v2 + rnorm(n)
x7 = v2 + rnorm(n)
x8 = v2 + rnorm(n) x9 = v3 + rnorm(n)
x10 = v3 + rnorm(n) x = cbind(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10)
x.cov = t(x) %*% x/n; head(x.cov)
a = spca(x, , type='predictor', sparse='varnum', para=c(,), lambda=)
a
## population version of SPCA
g1 = matrix(, , )
diag(g1) = g2 = matrix(, , )
diag(g2) = g3 = matrix(283.7875, , )
diag(g3) = diag(g3)+ g1g3 = matrix(-, , )
g2g3 = matrix(277.5, , ) # construct the exact covariance matrix
x.cov = matrix(, , )
x.cov[:,:] = g1
x.cov[:,:] = g2
x.cov[:,:] = g3
x.cov[:,:] = g1g3
x.cov[:,:] = t(g1g3)
x.cov[:,:] = g2g3
x.cov[:,:] = t(g2g3) b = spca(x.cov, , type='Gram', sparse='varnum', para=c(,), lambda=)
b
The results of the population version using exact covariance matrix are exactly as in the paper:
> b Call:
spca(x = x.cov, K = , para = c(, ), type = "Gram", sparse = "varnum",
lambda = ) sparse PCs
Pct. of exp. var. : 40.9 39.5
Num. of non-zero loadings :
Sparse loadings
PC1 PC2
[,] 0.0 0.5
[,] 0.0 0.5
[,] 0.0 0.5
[,] 0.0 0.5
[,] 0.5 0.0
[,] 0.5 0.0
[,] 0.5 0.0
[,] 0.5 0.0
[,] 0.0 0.0
[,] 0.0 0.0
But the sample version may randomly vary a little.
> a Call:
spca(x = x, K = , para = c(, ), type = "predictor", sparse = "varnum",
lambda = ) sparse PCs
Pct. of exp. var. : 37.9 37.6
Num. of non-zero loadings :
Sparse loadings
PC1 PC2
x1 0.000 -0.303
x2 0.000 -0.533
x3 0.000 -0.576
x4 0.000 -0.540
x5 -0.492 0.000
x6 -0.287 0.000
x7 -0.481 0.000
x8 -0.666 0.000
x9 0.000 0.000
x10 0.000 0.000
Having fun learning sparse PCA!
Sparse PCA: reproduction of the synthetic example的更多相关文章
- Deflation Methods for Sparse PCA
目录 背景 总括 Hotelling's deflation 公式 特点 Projection deflation 公式 特点 Schur complement deflation Orthogona ...
- Spectral Bounds for Sparse PCA: Exact and Greedy Algorithms[贪婪算法选特征]
目录 概括 Sparse PCA Formulation 非常普遍的问题 Optimality Conditions Eigenvalue Bounds 算法 代码 概括 这篇论文,不像以往的那些论文 ...
- Sparse PCA 稀疏主成分分析
Sparse PCA 稀疏主成分分析 2016-12-06 16:58:38 qilin2016 阅读数 15677 文章标签: 统计学习算法 更多 分类专栏: Machine Learning ...
- A direct formulation for sparse PCA using semidefinite programming
目录 背景 Sparse eigenvectors(单个向量的稀疏化) 初始问题(low-rank的思想?) 等价问题 最小化\(\lambda\) 得到下列问题(易推) 再来一个等价问题 条件放松( ...
- 主成分分析(PCA)原理总结
主成分分析(Principal components analysis,以下简称PCA)是最重要的降维方法之一.在数据压缩消除冗余和数据噪音消除等领域都有广泛的应用.一般我们提到降维最容易想到的算法就 ...
- Python机器学习笔记 使用scikit-learn工具进行PCA降维
之前总结过关于PCA的知识:深入学习主成分分析(PCA)算法原理.这里打算再写一篇笔记,总结一下如何使用scikit-learn工具来进行PCA降维. 在数据处理中,经常会遇到特征维度比样本数量多得多 ...
- 深入学习主成分分析(PCA)算法原理(Python实现)
一:引入问题 首先看一个表格,下表是某些学生的语文,数学,物理,化学成绩统计: 首先,假设这些科目成绩不相关,也就是说某一科目考多少分与其他科目没有关系,那么如何判断三个学生的优秀程度呢?首先我们一眼 ...
- Sparse Principal Component Analysis
目录 背景: 部分符号 创新点 文章梗概 The LASSO AND THE ELASTIC NET 将PCA改造为回归问题 定理二 单个向量(无需进行SVD版本) 定理三 多个向量(无需进行SVD, ...
- Full Regularization Path for Sparse Principal Component Analysis
目录 背景 Notation Sparse PCA Semidefinite Relaxation Low Rank Optimization Sorting and Thresholding 背景 ...
随机推荐
- Queen Attack -- 微软2017年预科生计划在线编程笔试第二场
#!/usr/bin/env python # coding:utf-8 # Queen Attack # https://hihocoder.com/problemset/problem/1497 ...
- HackGame2 writeup
网址:http://hackgame.blackbap.org/ 第一关 突破客户端:无论输入什么密码都会提示"密码不能为空",使用浏览器检查网页元素会发现提交时会触发 javas ...
- [Bzoj3262]陌上花开(CDQ分治&&树状数组||树套树)
题目链接 题目就是赤裸裸的三维偏序,所以用CDQ+树状数组可以比较轻松的解决,但是还是树套树好想QAQ CDQ+树状数组 #include<bits/stdc++.h> using nam ...
- poj1011 Sticks (dfs剪枝)
[题目描述] George took sticks of the same length and cut them randomly until all parts became at most 50 ...
- 引入maven以外的jar包
这里有2个案例,需要手动发出Maven命令包括一个 jar 到 Maven 的本地资源库. 要使用的 jar 不存在于 Maven 的中心储存库中. 您创建了一个自定义的 jar ,而另一个 Mave ...
- python学习笔记(7)容器以及容器的访问使用
一.容器 1.list列表 序列是python中最基本的数据结构,序列中的每个元素都分配一个数字,它的位置或索引,第一个索引是0,第二个索引是1,以此类推 Built-in mutable seque ...
- CSS固定定位实现右下角可关闭广告
代码: <!DOCTYPE html><html lang="zh-cn"><head> <meta charset="UTF- ...
- C++宽字符串转字符串
这文章是更改别人代码 #include <string> #include <iostream> #include <stdlib.h> #include < ...
- Windows下的Linux子系统安装,WSL 2下配置docker
Windows下的Linux子系统安装,WSL 2下配置docker 前提条件: 安装WSL 2需要Windows 10版本是Build 18917或更高,首先先确认系统版本已升级. 在“启用或关闭W ...
- Linux架构之Nginx 负载均衡会话保持
案例No.50:Nginx负载均衡会话保持 前期准备环境 web01.web02 (web01.web02.db01.nfs01都要优化基本源)[root@web01 ~]# vim /etc/yum ...