Kurchi

Kurchi

Kurchi

 

11. PCA

import numpy as np

import matplotlib.pyplot as plt

from sklearn.decomposition import PCA

X = np.random.rand(100, 5)

n_components = 2

pca = PCA(n_components=n_components)

pca.fit(X)

X_transformed = pca.transform(X)

explained_variance_ratio = pca.explained_variance_ratio_

plt.scatter(X_transformed[:, 0], X_transformed[:, 1])

plt.title(“PCA Scatter Plot”)

plt.xlabel(“Principal Component 1”)

plt.ylabel(“Principal Component 2”)

plt.show()

Output: 

Boxes

1.

Please follow and like us:
Scroll to Top