تقرير تحليلي – منصة أرقامي |
تحليل المكونات الرئيسية (Principal Component Analysis, PCA) هو أسلوب إحصائي يهدف إلى خفض الأبعاد عبر تحويل مجموعة من المتغيرات المترابطة إلى مجموعة أصغر من المتغيرات غير المترابطة تسمى المكونات الرئيسية.
كيف يمكن استخدام PCA لاكتشاف الأنماط الرئيسية وتبسيط بيانات متعددة الأبعاد؟
هل يمكن لـ PCA تبسيط بيانات زهرة Iris إلى مكونين رئيسيين فقط مع الحفاظ على أغلب التباين؟
data(iris)
head(iris)
Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
---|---|---|---|---|
5.1 | 3.5 | 1.4 | 0.2 | setosa |
4.9 | 3.0 | 1.4 | 0.2 | setosa |
4.7 | 3.2 | 1.3 | 0.2 | setosa |
4.6 | 3.1 | 1.5 | 0.2 | setosa |
5.0 | 3.6 | 1.4 | 0.2 | setosa |
5.4 | 3.9 | 1.7 | 0.4 | setosa |
التفسير: نستخدم بيانات Iris التي تحتوي على أربعة متغيرات رقمية لوصف الأزهار.
iris_num <- iris[, 1:4]
iris_scaled <- scale(iris_num)
summary(iris_scaled)
## Sepal.Length Sepal.Width Petal.Length Petal.Width
## Min. :-1.86378 Min. :-2.4258 Min. :-1.5623 Min. :-1.4422
## 1st Qu.:-0.89767 1st Qu.:-0.5904 1st Qu.:-1.2225 1st Qu.:-1.1799
## Median :-0.05233 Median :-0.1315 Median : 0.3354 Median : 0.1321
## Mean : 0.00000 Mean : 0.0000 Mean : 0.0000 Mean : 0.0000
## 3rd Qu.: 0.67225 3rd Qu.: 0.5567 3rd Qu.: 0.7602 3rd Qu.: 0.7880
## Max. : 2.48370 Max. : 3.0805 Max. : 1.7799 Max. : 1.7064
التفسير: توحيد المقاييس ضروري لأن المتغيرات بوحدات مختلفة.
pca_model <- prcomp(iris_scaled, center = TRUE, scale. = TRUE)
summary(pca_model)
## Importance of components:
## PC1 PC2 PC3 PC4
## Standard deviation 1.7084 0.9560 0.38309 0.14393
## Proportion of Variance 0.7296 0.2285 0.03669 0.00518
## Cumulative Proportion 0.7296 0.9581 0.99482 1.00000
التفسير: ملخص النتائج يظهر أن المكونين الأول والثاني يفسران معظم التباين (>95%).
pca_var <- pca_model$sdev^2
pca_var_ratio <- pca_var / sum(pca_var)
scree_df <- data.frame(
PC = paste0('PC', seq_along(pca_var_ratio)),
Variance = pca_var_ratio,
Cumulative = cumsum(pca_var_ratio)
)
ggplot(scree_df, aes(x = seq_along(Variance), y = Variance)) +
geom_point(size = 3) +
geom_line() +
labs(title = 'Scree Plot — نسب التباين لكل مكوّن')
التفسير: يوضح الرسم أن PC1 وPC2 يفسران معظم التباين، بينما مساهمة PC3 وPC4 ضعيفة.
pca_scores <- as.data.frame(pca_model$x)
pca_scores$Species <- iris$Species
ggplot(pca_scores, aes(PC1, PC2, color = Species)) +
geom_point(size = 3, alpha = 0.8) +
labs(title = 'إسقاط Iris على (PC1, PC2)')
التفسير: يوضح الرسم أن الأنواع الثلاثة من Iris تنفصل بشكل جيد على PC1 وPC2.
round(pca_model$rotation, 3)
## PC1 PC2 PC3 PC4
## Sepal.Length 0.521 -0.377 0.720 0.261
## Sepal.Width -0.269 -0.923 -0.244 -0.124
## Petal.Length 0.580 -0.024 -0.142 -0.801
## Petal.Width 0.565 -0.067 -0.634 0.524
التفسير: الأحمال تبين مساهمة كل متغير في تكوين PC1 وPC2. قيم أعلى تعني مساهمة أكبر.
Jolliffe, I. T. (2002). Principal Component Analysis (2nd ed.). Springer.
Jolliffe, I. T., & Cadima, J. (2016). Principal Component Analysis: A Review and Recent Developments. Philosophical Transactions of the Royal Society A: Mathematical, Physical and Engineering Sciences, 374(2065).
Abdi, H., & Williams, L. J. (2010). Principal component analysis. Wiley Interdisciplinary Reviews: Computational Statistics, 2(4), 433–459.
UCLA Institute for Digital Research and Education. (n.d.). Principal Components Analysis.
Scikit-Learn Documentation. (n.d.). PCA – Principal Component Analysis.
جميع الحقوق محفوظة © أرقامي 2025
لمزيد من المعلومات، تواصل معنا عبر بريدنا الإلكتروني: argamil2025@gmail.com