pca

Cluster texture based on features extracted from Gabor

时光总嘲笑我的痴心妄想 提交于 2019-11-27 22:30:27
I'm trying to cluster textures based on the features extracted from Gabor bank that I've created, but the result is far from what is typically expected so here is what I'm doing >> 1-generate a filter bank (based on the Miki's answer here I'm getting both real and imaginary part so that I can later extract Magnitude feature) void Gabor::generateFilterbank(int bankRows,int bankCols) { bankCol=bankCols; bankRow=bankRows; setBankSize(); int thetaStep=pos_th_max/bankCols; int lambadaStep=(pos_lm_max/bankRows) /10; for (int i = 1; i <= bankRows; i++) // cols = theta rows = lambda for (int j = 1; j

Adding ellipses to a principal component analysis (PCA) plot

你。 提交于 2019-11-27 19:25:14
I am having trouble adding grouping variable ellipses on top of an individual site PCA factor plot which also includes PCA variable factor arrows. My code: prin_comp<-rda(data[,2:9], scale=TRUE) pca_scores<-scores(prin_comp) #sites=individual site PC1 & PC2 scores, Waterbody=Row Grouping Variable. #site scores in the PCA plot are stratified by Waterbody type. plot(pca_scores$sites[,1], pca_scores$sites[,2], pch=21, bg=point_colors[data$Waterbody], xlim=c(-2,2), ylim=c(-2,2), xlab=x_axis_text, ylab=y_axis_text) #species=column PCA1 & PCA2 Response variables arrows(0,0,pca_scores$species[,1],pca

Using memmap files for batch processing

你。 提交于 2019-11-27 18:47:24
问题 I have a huge dataset on which I wish to PCA. I am limited by RAM and computational efficency of PCA. Therefore, I shifted to using Iterative PCA. Dataset Size-(140000,3504) The documentation states that This algorithm has constant memory complexity, on the order of batch_size, enabling use of np.memmap files without loading the entire file into memory. This is really good, but unsure on how take advantage of this. I tried load one memmap hoping it would access it in chunks but my RAM blew.

主成分分析(PCA)

别来无恙 提交于 2019-11-27 18:39:55
§1 基本思想 主成分分析试图在力保数据信息丢失最少的原则下,对这种多变量的截面数据进行最佳综合简化。也就是说,对高维变量空间进行降维处理。 研究指标体系的少数几个线性组合,并且这几个线性组合所构成的综合指标将尽可能多地保留原来指标变异方面的信息。这些综合指标就称为主成分。 §2 数学模型 假设我们所讨论的实际问题中,有p个指标,我们把这p个指标看作p个随机变量,记为X1,X2,…,Xp,主成分分析就是要把这p个指标的问题,转变为讨论p个指标的线性组合的问题,而这些新的指标F1,F2,…,Fk(k≤p),要求保留主要信息量的原则(即充分反映原指标的信息),并且相互独立。 这种由讨论多个指标降为少数几个综合指标的过程在数学上就叫做降维。主成分分析通常的做法是,寻求原指标的线性组合Fi。 §4 主成分分析优劣的判定标准 第一,尽量将更多变量压缩在第一主成分和第二主成分之内; 第二,第一主成分解释的信息能够超过 50%; 第三,第一主成分和第二主成分解释的信息总和超过 70%; 第四,第一主成分除以第二主成分的比值大于 3; 第五,用更少的主成分代表更多的变量。 来源: https://www.cnblogs.com/lvzw/p/11372360.html

PCA(主成分分析)原理,步骤详解以及应用

孤街浪徒 提交于 2019-11-27 18:21:39
主成分分析(PCA, Principal Component Analysis) 一个 非监督 的机器学习算法 主要用于数据的降维处理 通过降维,可以发现更便于人类理解的特征 其他应用:数据可视化,去噪等 主成分分析是尽可能地忠实再现原始重要信息的数据降维方法 原理推导: 如图,有一个二维的数据集,其特征分布于特征1和2两个方向 现在希望对数据进行降维处理,将数据压缩到一维,直观的我们可以想到将特征一或者特征二舍弃一个,可以得到这样的结果          ------- : 舍弃特征1之后         ------- : 舍弃特征2之后 可以看出,舍弃特征2保留特征1是一个较好的降维方案,此时点和点之间距离较大,拥有更高的可区分度 此时我们要想,肯定会有比这更好的方案,毕竟这太简单了 我们想象一下,能够找到这样的一条斜线w,将数据降维到w上(映射到w上)之后,能最好的保留原来的分布特征,且这些点分布在了一个轴上(斜线w)后点和点之间的距离也比之前的两种方案更加的大,此时的区分度也更加明显 思考: 如何找到让这个样本降维后间距最大的轴? 如何定义样本间距? 在统计学中,有一个直接的指标可以表示样本间的间距,那就是 方差 ( Variance ) 这样回过头来看思考1,问题就变成了: 找到一个轴,使得样本空间的所有点映射到这个轴之后,方差最大 求解这个轴的过程 将样例的均值归为0

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

偶尔善良 提交于 2019-11-27 18:02:04
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'class1', pca_features=DenseVector([-0.33256, 0.8668, 0

Apply PCA on very large sparse matrix

心已入冬 提交于 2019-11-27 17:30:26
问题 I am doing a text classification task with R, and I obtain a document-term matrix with size 22490 by 120,000 (only 4 million non-zero entries, less than 1% entries). Now I want to reduce the dimensionality by utilizing PCA (Principal Component Analysis). Unfortunately, R cannot handle this huge matrix, so I store this sparse matrix in a file in the "Matrix Market Format", hoping to use some other techniques to do PCA. So could anyone give me some hints for useful libraries (whatever the

R function prcomp fails with NA's values even though NA's are allowed

徘徊边缘 提交于 2019-11-27 17:17:45
问题 I am using the function prcomp to calculate the first two principal components. However, my data has some NA values and therefore the function throws an error. The na.action defined seems not to work even though it is mentioned in the help file ?prcomp Here is my example: d <- data.frame(V1 = sample(1:100, 10), V2 = sample(1:100, 10)) prcomp(d, center = TRUE, scale = TRUE, na.action = na.omit) d$V1[5] <- NA d$V2[7] <- NA prcomp(d, center = TRUE, scale = TRUE, na.action = na.omit) I am using

Recovering features names of explained_variance_ratio_ in PCA with sklearn

送分小仙女□ 提交于 2019-11-27 17:14:50
I'm trying to recover from a PCA done with scikit-learn, which features are selected as relevant . A classic example with IRIS dataset. import pandas as pd import pylab as pl from sklearn import datasets from sklearn.decomposition import PCA # load dataset iris = datasets.load_iris() df = pd.DataFrame(iris.data, columns=iris.feature_names) # normalize data df_norm = (df - df.mean()) / df.std() # PCA pca = PCA(n_components=2) pca.fit_transform(df_norm.values) print pca.explained_variance_ratio_ This returns In [42]: pca.explained_variance_ratio_ Out[42]: array([ 0.72770452, 0.23030523]) How can

RNA-seq表达数据之样本PCA分析

陌路散爱 提交于 2019-11-27 16:48:58
Principal component analysis (PCA) 分析 主成分分析(PCA)帮助我们归纳总结和可视化数据集中的信息,这些数据包含由多个相互关联的变量描述的个体 / 观察主成分分析。 可以将每个变量视为不同的维度。 但如果您的数据集中有3个以上的变量,那么很难在多维超空间可视化。 主成分分析是用来从一个多变量数据表中提取重要信息,并将这些信息表示为一组称为主成分的新变量。 这些新的变量相当于原始数据的线性组合。 主成分的个数小于或等于原始变量的个数。 给定数据集中的信息对应于它所包含的总变差。 主成分分析的目的是确定数据变化最大的方向(或主成分)。换句话说,主成分分析将多变量数据的维数降低为两个或三个主成分,这些主成分可以以图形化的方式显示,信息损失最小。转录组中,一般用来检验不同处理组样本间重复性的好坏。更多PCA原理及分析方法请点击文末的PCA分析资料,下面小编用自己的数据在R中进行PCA分析。 PCA可视化 数据展示 代码展示 ****************************************************************************************************** #### RNA-seq样本PCA分析#### #加载的R包 install.packages(c("ggpubr",