-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Binary file added
BIN
+64.2 KB
...ent Analysis (Dimensionality Reduction)/Screenshot from 2020-05-23 18-28-02.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.04 KB
Principal Component Analysis (Dimensionality Reduction)/__pycache__/PCA.cpython-36.pyc
Binary file not shown.
27 changes: 27 additions & 0 deletions
27
Principal Component Analysis (Dimensionality Reduction)/pca_testing.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from sklearn import datasets | ||
from PCA import PCA | ||
|
||
pre_data = datasets.load_iris() | ||
X = pre_data.data | ||
Y = pre_data.target | ||
|
||
pca = PCA(2) | ||
pca.fit(X) | ||
X_transformed = pca.transform(X) | ||
|
||
print("Dimensions of X is " + str(X.shape)) | ||
|
||
print("Dimensions of X_transformed is" + str(X_transformed.shape)) | ||
|
||
print(Y) | ||
|
||
x1 = X_transformed[: ,0] | ||
x2 = X_transformed[: ,1] | ||
|
||
plt.xlabel("Component 1") | ||
plt.ylabel("Component 2") | ||
plt.scatter(x1, x2, alpha = 1, cmap = plt.cm.get_cmap('Dark2', 3), c = Y, edgecolor = "red") | ||
plt.colorbar() | ||
plt.show() |