Skip to content

Instantly share code, notes, and snippets.

@gkarthik
Created December 7, 2016 00:16
Show Gist options
  • Save gkarthik/8aaf5e8e264b6b2366fbe1b6a9d2ea52 to your computer and use it in GitHub Desktop.
Save gkarthik/8aaf5e8e264b6b2366fbe1b6a9d2ea52 to your computer and use it in GitHub Desktop.
PCA graphviz
digraph {
labelloc="t"
label="PCA";
node [shape=rect];
rankdir = LR;
a[label="Sample Data\nM0 = [(x1 ... x100)(y1....y100)]"];
b[label="Centered Matrix\nM=[(x1-mean(x) ... x100-mean(x))(y1-mean(y)...y100-mean(y))]"];
c[label="Sample covariance\nC = (MM')/(n-1)\nn=100"];
d[label="C=VDV'"];
e[label="PC Matrix\nP=V*sqrt(D)"];
f[label="C is +ve semidefnite.\nFor all w, w'Cw>=0;"];
g[label="Covariance matrix, C real valued symmetric.\nV orthonormal if inv(V) = V'.\nSpectral decomposition, C = VDV'."]
h[label="M2 = V'M.\n Combination of rotation,reflection,scaling,shearing and orthogonal projections."];
i[label="Verify??"];
j[label="(M2*M2')/n-1 = D. Note that C = VDV' => D = V'CV"]
a -> b -> c -> d -> e -> f -> h -> j[constraint=false];
f -> g[dir="both"];
h -> i[dir="both"];
subgraph trace{
shape = rect;
color=blue;
rank = same;
label="% variance";
t1[label="Trace(matrix) = sum of diagonal."];
t2[label="Note: Trace(X) = Trace(XAX')"];
t3[label="Trace(C) = trace(D) based on parent."];
t4[label="%variance=eigenvalue/trace(D)"];
}
j->t1 -> t2 -> t3 -> t4;
t5[label="SVD - takes scaling into account for mixed physical quantities."];
t4 -> t5;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment