principal component analysis scikit learn code example
Example: pca python
import numpy as np
from sklearn.decomposition import PCA
pca = PCA(n_components = 3) # Choose number of components
pca.fit(X) # fit on X_train if train/test split applied
print(pca.explained_variance_ratio_)