python - PCA how to plot effect of one component -
python - PCA how to plot effect of one component -
edit @ bottom containing solution
i performed pca on dataset, resulting in eigenvectors, eigenvalues , mean. want plot effects of varying 1 principal component can't figure out how. want create plot this:
http://i.stack.imgur.com/6lqaa.png
so formula for should
mean + pb
with p eigenvectors , b
b = p.t * (x - mean)
but don't know utilize x. possibility according active shape model paper cootes that
b = (b1 b2 .. bt).t
so vector of weights. makes more sense me, way have weight of first b set -3 * sqrt(eigenvalue) , plot result. i'm having dimensionality problems way.
my input info pca [20, 160], returns [160] mean, [160, n] n amount of principal components want retain, let's take 5. , [n] eigenvalues. way can't pb because p [160] should dotproduct [160]? i'm pretty confused on how this, help appreciated!
edit: ok figured out problem. when trying plot effect of first principal component, taking first column of eigenvectors, mistake.
what should take of eigenvectors p, in case [160, 5], , create new vector b dimension [5]. b consists of zeros, except on index of principal component wish change, set e.g. -2 * sqrt(eigenvalue_i), plot effect of varying principal component i, 2 standard deviations left. result in
x = mu + p * b
with mu = mean, p finish set of eigenvectors, , b vector containing weights of variation.
python components analysis pca principal
Comments
Post a Comment