Skip to content

Commit

Permalink
Update pca.py
Browse files Browse the repository at this point in the history
fixed issue OpenSourceSprint#6
  • Loading branch information
exaibot authored Feb 22, 2024
1 parent d63e5a2 commit c5ac837
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pca.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import numpy as np
aimport numpy as np
import pandas as pd
from matplotlib import pyplot as plt
# from mpl_toolkits.mplot3d import Axes3D
Expand Down Expand Up @@ -109,16 +109,17 @@
# The projected data in 3D will be n x 3 matrix
Proj_data_3D = np.dot(X_std,P_reduce)


# Visualize data in 3D

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Scatter plot in 3D (test negative for diabetes)
negative = ax.scatter(Proj_data_3D[:0,][y == 0], Proj_data_3D[:1,][y == 0], Proj_data_3D[:,2][y == 0], label="No Diabetes")
negative = ax.scatter(Proj_data_3D[:,0][y == 0], Proj_data_3D[:,1][y == 0], Proj_data_3D[:,2][y == 0], label="No Diabetes")

# Scatter plot in 3D (test positive for diabetes)
positive = ax.scatter(Proj_data_3D[:0,][y == 0], Proj_data_3D[:1,][y == 0], Proj_data_3D[:,2][y == 1], color="red", label="Have Diabetes")
positive = ax.scatter(Proj_data_3D[:,0][y == 1], Proj_data_3D[:,1][y == 1], Proj_data_3D[:,2][y == 1], color="red", label="Have Diabetes")

ax.set_title('PCA Reduces Data to 3D')

Expand Down Expand Up @@ -149,3 +150,8 @@








0 comments on commit c5ac837

Please sign in to comment.