pca

关于fisher判别的一点理解

两盒软妹~` 提交于 2019-12-25 04:55:28
最近一个朋友问这方面的一些问题,其实之前也就很粗略的看了下fisher,真正帮别人解答问题的时候才知道原来自己也有很多东西不懂。下面小结下自己对fisher判别的理解: 其实fisher和PCA差不多,熟悉PCA的人都知道,PCA其实就是在寻找一个子空间。这个空间怎么来的呢,先求协方差矩阵,然后求这个协方差矩阵的特征空间(特征向量对应的空间),选取最大的特征值对应的特征向量组成特征子空间(比如说k个,相当于这个子空间有k维,每一维代表一个特征,这k个特征基本上可以涵盖90%以上的信息)。那么我们把样本投影在这个子空间,原来那么多维的信息就可以用这k维的信息代替了,也就是说降维了。至于PCA为啥要用求协方差矩阵然后求特征子空间的方法,这个数学上有证明,记得在某篇文章上看过,有兴趣的可以找找,看看证明。 那么fisher空间又是怎么一回事呢,其实fisher判别和PCA是在做类似的一件事,都是在找子空间。不同的是,PCA是找一个低维的子空间,样本投影在这个空间基本不丢失信息。而fisher是寻找这样的一个空间,样本投影在这个空间上,类内距离最小,类间距离最大。那么怎么求这个空间呢,类似于PCA,求最大特征值对应的特征向量组成的空间。 当我们取最大几个特征值对应的特征向量组成特征空间时(这里指出,最佳投影轴的个数d<=c-1,这里c是类别数),最佳投影矩阵如下:

change point colors and shapes in ggbiplot in r

大憨熊 提交于 2019-12-25 03:43:13
问题 I am using ggbiplot() and would like to manipulate the colors and shapes of the datapoints to make them more printer friendly. Currently I get the default rainbow of colors from ggbiplot(). I have tried using the arguments "+ scale_colour_discrete" and "+ scale_shape_manual" but the "groups=" argument ggbiplot seems to override these. If I eliminate the "groups=" argument then ellipses can't be drawn. The "+ theme" argument works just fine. My code is below. I know I could manipulate the

After generating dummy variables?

无人久伴 提交于 2019-12-25 02:08:51
问题 I am trying to change the category variables into dummy variables. "season","holiday","workingday","weather","temp","atemp","humidity","windspeed", "registered","count","hour","dow" are all variables. Here is my code: #dummy library(dummies) #set up new dummy variables data.new = data.frame(data) data.new = cbind(data.new,dummy(data.new$season, sep = "_")) data.new = cbind(data.new,dummy(data.new$holiday, sep = "_")) data.new = cbind(data.new,dummy(data.new$weather, sep = "_")) data.new =

机器学习降维算法一:PCA (Principal Component Analysis)

六月ゝ 毕业季﹏ 提交于 2019-12-25 00:29:01
引言: 机器学习领域中所谓的降维就是指采用某种映射方法,将原高维空间中的数据点映射到低维度的空间中。降维的本质是学习一个映射函数 f : x->y ,其中 x 是原始数据点的表达,目前最多使用向量表达形式。 y 是数据点映射后的低维向量表达,通常 y 的维度小于 x 的维度(当然提高维度也是可以的)。 f 可能是显式的或隐式的、线性的或非线性的。 当然还有一大类方法本质上也是做了降维,叫做feature selection,目的是从原始的数据feature集合中挑选一部分作为数据的表达。 目前大部分降维算法处理向量表达的数据,也有一些降维算法处理高阶张量表达的数据。 之所以使用降维后的数据表示是因为: (1)在原始的高维空间中,包含有冗余信息以及噪音信息,在实际应用例如图像识别中造成了误差,降低了准确率;而通过降维 , 我们希望减少 冗余信息 所造成的误差 , 提高识别(或其他应用)的精度。 (2)或者希望通过降维算法来寻找数据内部的本质结构特征。 (3)通过降维来加速后续计算的速度 (4)还有其他很多目的,如解决数据的sparse问题 在很多算法中,降维算法成为了数据预处理的一部分,如 PCA 。事实上,有一些算法如果没有降维预处理,其实是很难得到很好的效果的。 如果你需要处理数据,但是数据原来的属性又不一定需要全部保留,那么PCA也许是一个选择。 主成分分析算法( PCA )

Sparse Principal Component Analysis using sklearn

老子叫甜甜 提交于 2019-12-25 00:02:47
问题 I'm trying to replicate an application from this paper, where the authors download the 20 newsgroups data and use SPCA to extract the principal components that in some sense best describe the text corpus [see section 4.1]. This is for a high dimensions class project where we were asked to pick a topic and replicate/apply it. The output should be K principal components, which each have a short list of words that all intuitively correspond to a certain theme (for example, the paper finds the

特征工程

百般思念 提交于 2019-12-24 17:51:42
转至博文:http://www.cnblogs.com/jasonfreak/p/5448385.html 知乎问答:https://www.zhihu.com/question/29316149 归一化,正则化:http://blog.csdn.net/u012102306/article/details/51940147 卡方检验:http://blog.csdn.net/sunshine_in_moon/article/details/45155803 目录 1 特征工程是什么? 2 数据预处理   2.1 无量纲化     2.1.1 标准化     2.1.2 区间缩放法     2.1.3 标准化与归一化的区别   2.2 对定量特征二值化   2.3 对定性特征哑编码   2.4 缺失值计算   2.5 数据变换 3 特征选择   3.1 Filter     3.1.1 方差选择法     3.1.2 相关系数法     3.1.3 卡方检验     3.1.4 互信息法   3.2 Wrapper     3.2.1 递归特征消除法   3.3 Embedded     3.3.1 基于惩罚项的特征选择法     3.3.2 基于树模型的特征选择法 4 降维   4.1 主成分分析法(PCA)   4.2 线性判别分析法(LDA) 5 总结 6 参考资料 1

ModuleNotFoundError: No module named 'sklearn.utils._joblib'

♀尐吖头ヾ 提交于 2019-12-24 16:41:20
问题 I'm using python 3.6 on on Anaconda Jupyter notebooks platform. My pc uses win 8.1 as OS. I was trying to import PCA from sklearn using the following lines: import sklearn from sklearn import decomposition from sklearn.decomposition import PCA the third line returns a Module error: ModuleNotFoundError: No module named 'sklearn.utils._joblib' Strangely, I couldn't find any record on this error online! I'd appreciate any help. I copied the complete error message below: -------------------------

How to find principal eigen direction?

此生再无相见时 提交于 2019-12-24 07:38:52
问题 I am trying to generate points within ellipsoid and then trying to fit with smooth ellipsoid surfaces. The goal is to fit with unknown data where i have to find value of a,b and c in 3 principal axes. Rinv should be equivalent to pc. But what i am getting pc in different order. So i have to find correct order to rotate my data to matlab coordinate. a=3; b=5; c=1; index=1; for i=1:500000 x=10*rand-5; y=10*rand-5; z=10*rand-5; if ((x^2/a^2) + (y^2/b^2) + (z^2/c^2) -1) <0 C(index,:)=[x,y,z];

ImportError: cannot import name 'LatentDirichletAllocation' when importing PCA [closed]

橙三吉。 提交于 2019-12-24 06:13:37
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 9 days ago . I keep getting the error: ImportError: cannot import name 'LatentDirichletAllocation' full traceback: Traceback (most recent call last): File "/home/path/to/file/pca.py", line 7, in <module> from sklearn.decomposition import PCA File "/home/user/.local/lib/python3.6/site-packages/sklearn/decomposition/__init__.py

How to project a new point to PCA new basis?

こ雲淡風輕ζ 提交于 2019-12-23 18:13:38
问题 For example, I have 9 variables and 362 cases. I've made PCA calculation, and found out that first 3 PCA coordinates are enough for me. Now, I have new point in my 9-dimensional structure, and I want to project it to principal component system coordinate. How to get its new coordinates? %# here is data (362x9) load SomeData [W, Y] = pca(data, 'VariableWeights', 'variance', 'Centered', true); %# orthonormal coefficient matrix W = diag(std(data))\W; % Getting mean and weights of data (for