Created
July 23, 2019 05:47
-
-
Save KhyatiMahendru/c21b697fcad05fdd55919250f8d07205 to your computer and use it in GitHub Desktop.
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
import numpy as np | |
from sklearn.decomposition import TruncatedSVD | |
A = np.array([[-1, 2, 0], [2, 0, -2], [0, -2, 1]]) | |
print("Original Matrix:") | |
print(A) | |
svd = TruncatedSVD(n_components = 2) | |
A_transf = svd.fit_transform(A) | |
print("Singular values:") | |
print(svd.singular_values_) | |
print("Transformed Matrix after reducing to 2 features:") | |
print(A_transf) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment