Skip to content
Snippets Groups Projects

Resolve "Update EDA"

3 files
+ 186
83
Compare changes
  • Side-by-side
  • Inline

Files

+ 4
3
@@ -23,7 +23,7 @@ def find_mean_img(full_mat):
@@ -23,7 +23,7 @@ def find_mean_img(full_mat):
# calculate the average
# calculate the average
mean_img = np.mean(full_mat[mat], axis = 0)
mean_img = np.mean(full_mat[mat], axis = 0)
# reshape it back to a matrix
# reshape it back to a matrix
mean_img = mean_img.reshape((200, 150))
mean_img = mean_img.reshape((170, 120))
ax = fig.add_subplot(rows, cols,i+1)
ax = fig.add_subplot(rows, cols,i+1)
ax.imshow(mean_img, vmin=0, vmax=255, cmap='Greys_r')
ax.imshow(mean_img, vmin=0, vmax=255, cmap='Greys_r')
ax.set_title('Average ' + mat)
ax.set_title('Average ' + mat)
@@ -31,7 +31,7 @@ def find_mean_img(full_mat):
@@ -31,7 +31,7 @@ def find_mean_img(full_mat):
plt.tight_layout()
plt.tight_layout()
def plot_pca(pca, title, size = (200, 150)):
def plot_pca(pca, title, size = (170, 120)):
"""Plots each decomposed PCA image and labels the amount of variability for each image.
"""Plots each decomposed PCA image and labels the amount of variability for each image.
Args:
Args:
@@ -57,7 +57,7 @@ def plot_pca(pca, title, size = (200, 150)):
@@ -57,7 +57,7 @@ def plot_pca(pca, title, size = (200, 150)):
plt.show()
plt.show()
def eigenimages(full_mat,n_comp = 0.7, size = (200, 150)):
def eigenimages(full_mat,n_comp = 0.7, size = (170, 120)):
"""Creates creates and fits a PCA estimator from sklearn.
"""Creates creates and fits a PCA estimator from sklearn.
Args:
Args:
@@ -69,6 +69,7 @@ def eigenimages(full_mat,n_comp = 0.7, size = (200, 150)):
@@ -69,6 +69,7 @@ def eigenimages(full_mat,n_comp = 0.7, size = (200, 150)):
sklearn PCA object: Fitted PCA model.
sklearn PCA object: Fitted PCA model.
"""
"""
# fit PCA to describe n_comp * variability in the class
# fit PCA to describe n_comp * variability in the class
 
print(full_mat, n_comp)
pca = PCA(n_components = n_comp, whiten = True)
pca = PCA(n_components = n_comp, whiten = True)
pca.fit(full_mat)
pca.fit(full_mat)
Loading