PCA is an unsupervised machine learning technique that can be used to reduce dimensions using linear transformation. In the following figure, we can see two principle components, PC1 and PC2, which show the shape of the spread of the data points. PC1 and PC2 can be used to summarize the data points with appropriate coefficients:
Let's consider the following code:
from sklearn.decomposition import PCAiris = pd.read_csv('iris.csv')X = iris.drop('Species', axis=1)pca = PCA(n_components=4)pca.fit(X)
Now let's print the coefficients of our PCA model:
Note that the original DataFrame has four features, Sepal.Length ...