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 背景 ...
随机推荐
- Web高级 JavaScript中的数据结构
复杂度分析 大O复杂度表示法 常见的有O(1), O(n), O(logn), O(nlogn) 时间复杂度除了大O表示法外,还有以下情况 最好情况时间复杂度 最坏情况时间复杂度 平均情况时间复杂度 ...
- X86平台下用汇编写"HelloWorld"
首先需要安装一个汇编器,我用的是Nasm,这个汇编器在Linux下安装还是很简单的. Nasm下载地址http://www.nasm.us/pub/nasm/releasebuilds/ 在下载之后对 ...
- SpringBoot官方文档学习(二)使用Spring Boot构建系统
强烈建议您选择一个支持依赖关系管理并且可以使用发布到“ Maven Central”仓库的构建系统.我们建议您选择Maven或Gradle.其他构建系统(例如,Ant)也可以和Spring Boot一 ...
- Weak Pair (dfs+树状数组)
Weak Pair (dfs+树状数组) 题意 这个题目是要求:一颗树上,有n个节点,给出每个节点的权值.另外给出一个值k,问有多少对节点满足: \(power[u]*power[v]<=k\) ...
- 小白学Python(12)——pyecharts ,生成词云图 WordCloud
WordCloud(词云图) from pyecharts import options as opts from pyecharts.charts import Page, WordCloud fr ...
- 分布式唯一ID生成器
在应用程序中,经常需要全局唯一的ID作为数据库主键.如何生成全局唯一ID? 首先,需要确定全局唯一ID是整型还是字符串?如果是字符串,那么现有的UUID就完全满足需求,不需要额外的工作.缺点是字符串作 ...
- 事件对象e的实现原理
转自:https://segmentfault.com/q/1010000007337410?_ea=1313467 事件对象传递原理 1.前置知识回顾 在讲传递原理前,我们先看看普通函数是如何传递参 ...
- JavaScript基础8——弹窗案例
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 如何利用Chrome进行跨域调试
为什么要跨域调试: 拿嵌入式web开发说,代码都是跑在板子上,我一个优雅的前端开发要每次改完代码都打包到板子上,用板子的地址打开,这是人做的事??? 怎么跨域调试: 1.升级Chrome为最新版本 2 ...
- 消灭 Java 代码的“坏味道”
消灭 Java 代码的“坏味道” 原创: 王超 阿里巴巴中间件 昨天 导读 明代王阳明先生在<传习录>谈为学之道时说: 私欲日生,如地上尘,一日不扫,便又有一层.着实用功,便见道无终穷,愈 ...