Skip to content

Instantly share code, notes, and snippets.

@vals
Created November 29, 2012 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vals/4172358 to your computer and use it in GitHub Desktop.
Save vals/4172358 to your computer and use it in GitHub Desktop.
from sklearn.decomposition.pca import PCA
pca = PCA(n_components=2)
# Note, data.shape = (6, 26440)
pca.fit(data)
Yd = dict()
Yd["400"] = pca.transform(data.ix[:,"400"])
Yd["5000"] = pca.transform(data.ix[:,"5000"])
plt.scatter(*zip(*Yd["400"]), c='#348ABD', s=100, label="400");
plt.scatter(*zip(*Yd["500"]), c='#A60628', s=100, label="5000");
plt.legend();
plt.title("Score plot");
plt.xlabel("PC1");
plt.ylabel("PC2");
plt.grid();
@shyammimit
Copy link

Please validate it with example output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment