Complete the code to import the PCA class from scikit-learn.
from sklearn.decomposition import [1]
The PCA class is imported from sklearn.decomposition to perform Principal Component Analysis.
Complete the code to create a PCA object that reduces data to 2 components.
pca = PCA(n_components=[1])Setting n_components=2 tells PCA to reduce the data to 2 principal components.
Fix the error in the code to fit PCA on the data array named 'data'.
pca.fit([1])The fit method requires the data array as input. Here, the data is stored in the variable 'data'.
Fill both blanks to transform the data and store the result in 'pca_result'.
pca_result = pca.[1]([2])
fit_transform fits PCA on the data and returns the transformed data in one step.
Fill the two blanks to print the explained variance ratio of the first principal component.
print(pca.[1][[2]])
explained_variance_ratio_ is the attribute that holds the fraction of total variance explained by each principal component. Index it with 0 to access the first component.
