본문으로 이동
메뉴 여닫기
환경 설정 메뉴 여닫기
개인 메뉴 여닫기
로그인하지 않음
지금 편집한다면 당신의 IP 주소가 공개될 수 있습니다.

Principal Component Analysis (PCA) is a statistical technique used for dimensionality reduction by transforming a dataset into a new coordinate system. The transformation emphasizes the directions (principal components) that maximize the variance in the data, helping to reduce the number of features while preserving essential information.

  • Principal Components: New orthogonal axes computed as linear combinations of the original features. The first principal component captures the maximum variance, followed by subsequent components with decreasing variance.
  • Explained Variance: The proportion of total variance captured by each principal component.
  • Orthogonality: Principal components are mutually perpendicular, ensuring no redundancy.
  1. Standardize the Data: Center the data by subtracting the mean of each feature and scale it (if necessary).
  2. Compute the Covariance Matrix: Calculate the covariance matrix of the dataset to understand relationships between features.
  3. Calculate Eigenvectors and Eigenvalues: Find the eigenvectors and eigenvalues of the covariance matrix to determine the principal components and their variance contribution.
  4. Select Principal Components: Retain the top k principal components that explain the majority of the variance.
  5. Transform the Data: Project the original data onto the new feature space defined by the selected principal components.

Applications of PCA

편집 원본 편집

PCA is widely used in various fields for the following purposes:

  • Dimensionality Reduction: Reducing the number of features in datasets for efficient processing.
  • Noise Reduction: Removing irrelevant or noisy dimensions to improve data quality.
  • Data Visualization: Visualizing high-dimensional data in 2D or 3D for better interpretability.
  • Feature Extraction: Creating new features that summarize the original dataset effectively.
  • Anomaly Detection: Highlighting deviations by focusing on key patterns in data.

Performing PCA using Python's scikit-learn library:

from sklearn.decomposition import PCA
import numpy as np

# Example dataset
data = np.array([[2.5, 2.4],
                 [0.5, 0.7],
                 [2.2, 2.9],
                 [1.9, 2.2],
                 [3.1, 3.0]])

# Apply PCA to reduce dimensions to 1
pca = PCA(n_components=1)
reduced_data = pca.fit_transform(data)

print("Reduced Data:", reduced_data)
print("Explained Variance Ratio:", pca.explained_variance_ratio_)
  • Dimensionality Reduction: Simplifies complex datasets while preserving essential information.
  • Noise Reduction: Eliminates redundant features, improving model accuracy.
  • Efficient Data Representation: Reduces computation time and storage requirements.
  • Loss of Interpretability: Transformed features (principal components) are linear combinations of original features, making them harder to interpret.
  • Assumption of Linearity: PCA assumes that the data's variance is best captured in a linear manner, which may not hold for all datasets.
  • Sensitive to Scaling: PCA performance can be affected if the data is not properly standardized.

PCA is closely related to Singular Value Decomposition (SVD). In PCA:

  • Principal components are derived from the eigenvectors of the covariance matrix, which correspond to the left singular vectors in SVD.
  • Eigenvalues correspond to the squared singular values from SVD.
편집 원본 편집