svd

Using Principal Components Analysis (PCA) on binary data

不问归期 提交于 2019-12-04 20:42:32
I am using PCA on binary attributes to reduce the dimensions (attributes) of my problem. The initial dimensions were 592 and after PCA the dimensions are 497. I used PCA before, on numeric attributes in an other problem and it managed to reduce the dimensions in a greater extent (the half of the initial dimensions). I believe that binary attributes decrease the power of PCA, but i do not know why. Could you please explain me why PCA does not work as good as in numeric data. Thank you. The principal components of 0/1 data can fall off slowly or rapidly, and the PCs of continuous data too — it

奇异分解(SVD)理论介绍

萝らか妹 提交于 2019-12-04 04:54:49
一、前言 奇异值分解(Singular Value Decomposition,以下简称SVD)是在机器学习领域广泛应用的算法,主要应用如下: 信息检索(LSA:隐性语义索引,LSA:隐性语义分析),分解后的奇异值代表了文章的主题或者概念,信息检索的时候同义词,或者说同一主题下的词会映射为同一主题,这样就可以提高搜索效率 数据压缩:通过奇异值分解,选择能量较大的前N个奇异值来代替所有的数据信息,这样可以降低噪声,节省空间。 推荐系统:主要是降噪,矩阵变换至低维空间(分解后还原的矩阵元素值作为原本缺失值的一种近似),方便计算(目前没有意识到它对推荐精确度的提升有什么具体作用)。 二、奇异值与特征值基础知识: 特征值分解的方法比较简单,有趣的是探究什么样的矩阵可以进行特征值分解以及矩阵进行特征值分解之后展现出的矩阵有意思的性质。特征向量矩阵S 是一个正交矩阵,一般写作 Q,也就是实对称矩阵的特征值分解可以写作: 首先,要明确的是,一个矩阵其实相当于一个线性变换,因为一个矩阵乘以一个向量后得到的向量,其实就相当于将这个向量进行了线性变换。比如说下面的一个矩阵: 这其实是在平面上对一个轴进行的拉伸变换(如蓝色的箭头所示),在图中,蓝色的箭头是一个最主要的变化方向(变化方向可能有不止一个),如果我们想要描述好一个变换,那我们就描述好这个变换主要的变化方向就好了。 特征值分解也有很多的局限

Any reason why Octave, R, Numpy and LAPACK yield different SVD results on the same matrix?

泪湿孤枕 提交于 2019-12-04 03:40:20
I'm using Octave and R to compute SVD using a simple matrix and getting two different answers! The code is listed below: R > a<-matrix(c(1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1), 9, 4) > a [,1] [,2] [,3] [,4] [1,] 1 1 0 0 [2,] 1 1 0 0 [3,] 1 1 0 0 [4,] 1 0 1 0 [5,] 1 0 1 0 [6,] 1 0 1 0 [7,] 1 0 0 1 [8,] 1 0 0 1 [9,] 1 0 0 1 > a.svd <- svd(a) > a.svd$d [1] 3.464102e+00 1.732051e+00 1.732051e+00 1.922963e-16 > a.svd$u [,1] [,2] [,3] [,4] [1,] -0.3333333 0.4714045 -1.741269e-16 7.760882e-01 [2,] -0.3333333 0.4714045 -3.692621e-16 -1.683504e-01 [3,] -0.3333333 0

Fit points to a plane algorithms, how to iterpret results?

你说的曾经没有我的故事 提交于 2019-12-03 19:28:48
问题 Update : I have modified the Optimize and Eigen and Solve methods to reflect changes. All now return the "same" vector allowing for machine precision. I am still stumped on the Eigen method. Specifically How/Why I select slice of the eigenvector does not make sense. It was just trial and error till the normal matched the other solutions. If anyone can correct/explain what I really should do, or why what I have done works I would appreciate it. . Thanks Alexander Kramer, for explaining why I

SVD的完整推导过程

余生颓废 提交于 2019-12-03 15:12:50
(一)前言 老生常谈,现在很多写博客的人根本就不管自己抄过来的对不对,有些甚至连转载出处都不标,错误逐渐传播,图片通通copy,影响极其恶劣,令人作呕。正如现在要找一篇数学上证明SVD的文章都很难找到,全都是给你直接讲“直观理解”和所谓的“内涵”,搞来搞去就是复制黏贴那些已经有过的东西,转载的人可能根本连这些自己发的都还搞不懂,滑天下之大稽! (二)推导 定理:设$X_{n×p},rank(X)=r$,且$\lambda_1 \geq ... \geq \lambda_r$为$X^TX$的非零特征值,记$\Lambda^{\frac{1}{2}}=diag(\lambda_1^{\frac{1}{2}},...,\lambda_r^{\frac{1}{2}})$,则存在正交阵$P_{p×p},Q_{n×n}$使得$X=Q \left[ \begin{matrix} \Lambda^{\frac{1}{2}} & \mathbf{0}\\ \mathbf{0}& \mathbf{0} \end{matrix}\right]P^T$,其中$P$的列向量组为与$X^TX$的$p$个特征值$\lambda_1,...,\lambda_r,0,...,0$对应的特征向量组,$Q$的列向量组为与$XX^T$的$n$个特征值$\lambda_1,...,\lambda_r,0,...,0

TOP 10开源的推荐系统简介

北城以北 提交于 2019-12-03 14:02:02
最近这两年推荐系统特别火,本文搜集整理了一些比较好的开源推荐系统,即有轻量级的适用于做研究的SVDFeature、LibMF、LibFM等,也有重量级的适用于工业系统的Mahout、Oryx、EasyRecd等,供大家参考。PS:这里的top 10仅代表个人观点。 #1.SVDFeature 主页: http://svdfeature.apexlab.org/wiki/Main_Page 语言:C++ 一个feature-based协同过滤和排序工具,由上海交大Apex实验室开发,代码质量较高。在KDD Cup 2012中获得第一名,KDD Cup 2011中获得第三名,相关论文发表在2012的JMLR中,这足以说明它的高大上。 SVDFeature包含一个很灵活的Matrix Factorization推荐框架,能方便的实现SVD、SVD++等方法, 是单模型推荐算法中精度最高的一种。SVDFeature代码精炼,可以用相对较少的内存实现较大规模的单机版矩阵分解运算。另外含有Logistic regression的model,可以很方便的用来进行ensemble。 #2.LibMF 主页: http://www.csie.ntu.edu.tw/~cjlin/libmf/ 语言:C++ 作者 Chih-Jen Lin 来自大名鼎鼎的台湾国立大学,他们在机器学习领域享有盛名

Eigenvectors computed with numpy's eigh and svd do not match

元气小坏坏 提交于 2019-12-03 08:56:17
问题 Consider singular value decomposition M=USV*. Then the eigenvalue decomposition of M* M gives M* M= V (S* S) V*=VS* U* USV*. I wish to verify this equality with numpy by showing that the eigenvectors returned by eigh function are the same as those returned by svd function: import numpy as np np.random.seed(42) # create mean centered data A=np.random.randn(50,20) M= A-np.array(A.mean(0),ndmin=2) # svd U1,S1,V1=np.linalg.svd(M) S1=np.square(S1) V1=V1.T # eig S2,V2=np.linalg.eigh(np.dot(M.T,M))

svd of very large matrix in R program

时间秒杀一切 提交于 2019-12-03 07:50:55
问题 I have a matrix 60 000 x 60 000 in a txt file, I need to get svd of this matrix. I use R but I don´t know if R can generate it. 回答1: I think it's possible to compute (partial) svd using the irlba package and bigmemory and bigalgebra without using a lot of memory. First let's create a 20000 * 20000 matrix and save it into a file require(bigmemory) require(bigalgebra) require(irlba) con <- file("mat.txt", open = "a") replicate(20, { x <- matrix(rnorm(1000 * 20000), nrow = 1000) write.table(x,

SVD和SVD++

亡梦爱人 提交于 2019-12-03 04:09:41
参考自:http://blog.csdn.net/wjmishuai/article/details/71191945 http://www.cnblogs.com/Xnice/p/4522671.html 基于潜在(隐藏)因子的推荐,常采用SVD或改进的SVD++ 奇异值分解(SVD) : 考虑CF中最为常见的用户给电影评分的场景,我们需要一个数学模型来模拟用户给电影打分的场景,比如对评分进行预测。 将评分矩阵U看作是两个矩阵的乘积: 其中,u xy 可以看作是user x对电影的隐藏特质y的热衷程度,而i yz 可以看作是特质 y 在电影 z中的体现程度。那么上述模型的评分预测公式为: q 和 p 分别对应了电影和用户在各个隐藏特质上的特征向量。 以上的模型中,用户和电影都体现得无差别,例如某些用户非常挑剔,总是给予很低的评分;或是某部电影拍得奇烂,恶评如潮。为了模拟以上的情况,需要引入 baseline predictor. 其中 μ 为所有评分基准,bi 为电影 i 的评分均值相对μ的偏移,bu 类似。注意,这些均为参数,需要通过训练得到具体数值,不过可以用相应的均值作为初始化时的估计。 模型参数bi,bu,qi,pu通过最优化下面这个目标函数获得: 可以用梯度下降方法或迭代的最小二乘算法求解。在迭代最小二乘算法中,首先固定pu优化qi,然后固定qi优化pu,交替更新

Pyspark and PCA: How can I extract the eigenvectors of this PCA? How can I calculate how much variance they are explaining?

匿名 (未验证) 提交于 2019-12-03 03:05:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am reducing the dimensionality of a Spark DataFrame with PCA model with pyspark (using the spark ml library) as follows: pca = PCA(k=3, inputCol="features", outputCol="pca_features") model = pca.fit(data) where data is a Spark DataFrame with one column labed features wich is a DenseVector of 3 dimensions: data.take(1) Row(features=DenseVector([0.4536,-0.43218, 0.9876]), label=u'class1') After fitting, I transform the data: transformed = model.transform(data) transformed.first() Row(features=DenseVector([0.4536,-0.43218, 0.9876]), label=u