Created
November 10, 2019 23:05
-
-
Save amitrani6/9e0eef12c0b17f59c185771bf1a50590 to your computer and use it in GitHub Desktop.
PCA 3D Visualization Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The code to generate a 3-D plot of Seinfeld and Curb Your Enthusiasm | |
# scripts with dimensions identified with Principal Component Analysis | |
import matplotlib.pyplot as plt | |
seinfeld_3d = transformed_data_3d[:num_seinfeld] | |
s3_x = [i[0] for i in seinfeld_3d] | |
s3_y = [i[1] for i in seinfeld_3d] | |
s3_z = [i[2] for i in seinfeld_3d] | |
curb_3d = transformed_data_3d[num_seinfeld:] | |
c3_x = [i[0] for i in curb_3d] | |
c3_y = [i[1] for i in curb_3d] | |
c3_z = [i[2] for i in curb_3d] | |
fig = plt.figure(figsize=(10,5)) | |
ax = fig.add_subplot(111, projection='3d') | |
ax.scatter(s3_x, s3_y, s3_z, c='b', s=60, label=1) | |
ax.scatter(c3_x, c3_y, c3_z, c='red', s=60, label=0) | |
ax.view_init(30, 10) | |
ax.legend() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment