📋 المحتوى المنظم
📖 محتوى تعليمي مفصّل
نوع: محتوى تعليمي
from sklearn.cluster import AgglomerativeClustering # used for agglomerative clustering
import scipy.cluster.hierarchy as hierarchy
hierarchy.set_link_color_palette(color_palette) # sets the color palette
plt.figure()
# iteratively merges points and clusters until all points belong to a single cluster
linkage_flat = hierarchy.linkage(X_norm, method = 'ward')
hierarchy.dendrogram(linkage_flat)
plt.show()
نوع: محتوى تعليمي
ward (وارد) عبارة عن طريقة ربط تُستخدم في التجميع التكتلي الهرمي.
شكل 4.19: الرسم الشجري يصنف البيانات إلى عنقودين
نوع: FIGURE_REFERENCE
شكل 4.19: الرسم الشجري يصنف البيانات إلى عنقودين
نوع: محتوى تعليمي
يكشف الرسم الشجري عنقودين كبيرين يمكن تقسيمهما إلى عناقيد أصغر. ويُستخدم المقطع البرمجي التالي أداة AgglomerativeClustering (التجميع التكتلي)؛ لإنشاء عشرة عناقيد، وهو العدد الفعلي للعناقيد الموجودة في البيانات:
نوع: محتوى تعليمي
AC = AgglomerativeClustering(linkage = 'ward', n_clusters = 10)
AC.fit(X_norm) # applies the tool to the data
pred = AC.labels_ # gets the cluster labels
pred
نوع: محتوى تعليمي
array([9, 6, 3, ..., 4, 4, 3], dtype=int64)
نوع: محتوى تعليمي
وأخيرًا، تُستخدم مؤشرات: Homogeneity (التجانس)، و Completeness (الاكتمال)، و Adjusted Rand (راند المعدّل) وكلها تعرّفت عليها في الدرس الثاني من الوحدة الثالثة؛ لتقييم جودة العناقيد الناتجة.
نوع: METADATA
وزارة التعليم
Ministry of Education
2025 - 1447
226
🔍 عناصر مرئية
الرسم الشجري يصنف البيانات إلى عنقودين
A dendrogram illustrating hierarchical clustering. The x-axis implicitly represents individual data points or sub-clusters, and the y-axis represents the dissimilarity or distance at which clusters are merged. The diagram shows a tree-like structure where individual points are initially at the bottom (y=0) and are progressively merged into larger clusters as the y-value increases. The main structure shows two large clusters, visually distinguished by blue and green branches, merging at a high dissimilarity level (around 1600). The blue cluster on the left and the green cluster on the right each contain numerous smaller sub-clusters, indicating the hierarchical merging process.
📄 النص الكامل للصفحة
from sklearn.cluster import AgglomerativeClustering # used for agglomerative clustering import scipy.cluster.hierarchy as hierarchy hierarchy.set_link_color_palette(color_palette) # sets the color palette plt.figure()# iteratively merges points and clusters until all points belong to a single cluster linkage_flat = hierarchy.linkage(X_norm, method = 'ward')
hierarchy.dendrogram(linkage_flat)
plt.show()ward (وارد) عبارة عن طريقة ربط تُستخدم في التجميع التكتلي الهرمي.--- SECTION: شكل 4.19: الرسم الشجري يصنف البيانات إلى عنقودين --- شكل 4.19: الرسم الشجري يصنف البيانات إلى عنقودين يكشف الرسم الشجري عنقودين كبيرين يمكن تقسيمهما إلى عناقيد أصغر. ويُستخدم المقطع البرمجي التالي أداة AgglomerativeClustering (التجميع التكتلي)؛ لإنشاء عشرة عناقيد، وهو العدد الفعلي للعناقيد الموجودة في البيانات:AC = AgglomerativeClustering(linkage = 'ward', n_clusters = 10)
AC.fit(X_norm) # applies the tool to the data pred = AC.labels_ # gets the cluster labels pred array([9, 6, 3, ..., 4, 4, 3], dtype=int64)وأخيرًا، تُستخدم مؤشرات: Homogeneity (التجانس)، و Completeness (الاكتمال)، و Adjusted Rand (راند المعدّل) وكلها تعرّفت عليها في الدرس الثاني من الوحدة الثالثة؛ لتقييم جودة العناقيد الناتجة.2025 - 1447--- VISUAL CONTEXT ---
**DIAGRAM**: الرسم الشجري يصنف البيانات إلى عنقودين
Description: A dendrogram illustrating hierarchical clustering. The x-axis implicitly represents individual data points or sub-clusters, and the y-axis represents the dissimilarity or distance at which clusters are merged. The diagram shows a tree-like structure where individual points are initially at the bottom (y=0) and are progressively merged into larger clusters as the y-value increases. The main structure shows two large clusters, visually distinguished by blue and green branches, merging at a high dissimilarity level (around 1600). The blue cluster on the left and the green cluster on the right each contain numerous smaller sub-clusters, indicating the hierarchical merging process.
X-axis: Data points/clusters (implicit)
Y-axis: Dissimilarity/Distance (implicit)
Data: The dendrogram shows a hierarchical structure of clusters. The y-axis ranges from 0 to 1600, representing the distance or dissimilarity. The horizontal lines indicate merges between clusters, and the height of the merge corresponds to the dissimilarity. The diagram visually separates into two primary clusters (blue and green) at higher dissimilarity levels, with numerous sub-clusters at lower levels.
Key Values: Y-axis range: 0 to 1600
Context: This dendrogram visually represents the hierarchical clustering process, demonstrating how data points are grouped into clusters based on their similarity. It supports the explanation of the AgglomerativeClustering algorithm and helps in understanding how to determine the optimal number of clusters by observing the merge heights.
🎴 بطاقات تعليمية للمراجعة
عدد البطاقات: 5 بطاقة لهذه الصفحة
ما هو الغرض الرئيسي من استخدام طريقة 'ward' في التجميع التكتلي الهرمي (Hierarchical Clustering)؟
الإجابة: طريقة 'ward' هي طريقة ربط تُستخدم في التجميع التكتلي الهرمي بهدف تقليل التباين داخل كل عنقود تم إنشاؤه.
الشرح: تهدف طريقة 'ward' إلى تقليل مجموع مربعات المسافات بين كل نقطة ومركز العنقود الذي تنتمي إليه، مما يؤدي إلى تكوين عناقيد متساوية الحجم تقريباً ومتماسكة.
تلميح: فكر في ما تحاول الخوارزميات التجميعية تحقيقه عند دمج النقاط أو العناقيد.
في سياق التجميع التكتلي الهرمي (Hierarchical Clustering)، ماذا يمثل الرسم الشجري (Dendrogram)؟
الإجابة: الرسم الشجري يمثل تسلسل عمليات دمج النقاط والعناقيد، موضحًا العلاقة الهرمية بينها وكيفية تشكيل العناقيد الأكبر من العناقيد الأصغر.
الشرح: يُظهر الرسم الشجري كيف يتم دمج النقاط الفردية أو المجموعات الصغيرة معًا في كل خطوة، بناءً على مقياس تشابه أو اختلاف محدد، حتى يتم دمج كل شيء في عنقود واحد كبير.
تلميح: تخيل كيف تبدأ العملية بأبسط وحدة (نقطة) وكيف تتشكل المجموعات تدريجيًا.
ما هي وظيفة 'AgglomerativeClustering' في مكتبة Scikit-learn عند استخدامها للتجميع التكتلي؟
الإجابة: تُستخدم AgglomerativeClustering لإنشاء العناقيد عن طريق البدء بكل نقطة كعنقود منفصل ثم دمجها تدريجيًا مع أقرب العناقيد حتى الوصول إلى العدد المطلوب من العناقيد أو استيفاء معايير التوقف.
الشرح: Agglomerative Clustering هي استراتيجية 'من الأسفل إلى الأعلى' (bottom-up)، حيث يتم تجميع النقاط والعناقيد بشكل متكرر.
تلميح: ما هي الاستراتيجية التي تتبعها هذه الأداة لإنشاء العناقيد؟ هل تبدأ بعنقود كبير وتُقسمه، أم تبدأ بعناقيد صغيرة وتُجمعها؟
ماذا يعني المعامل 'linkage' عند تهيئة AgglomerativeClustering؟
الإجابة: المعامل 'linkage' يحدد الطريقة التي يتم بها حساب المسافة بين مجموعتين (عنقودين) عند محاولة دمجهما، مثل 'ward' (الذي يهدف لتقليل التباين).
الشرح: توجد طرق مختلفة لتحديد المسافة بين العناقيد، مثل 'ward', 'complete', 'average', 'single'. كل طريقة تؤثر على شكل وحجم العناقيد الناتجة.
تلميح: عندما نقارن مجموعتين من النقاط، ما هي المعايير التي نستخدمها لتحديد أيها 'أقرب' أو 'أكثر تشابهاً'؟
لماذا قد نحتاج إلى تقييم جودة العناقيد الناتجة باستخدام مقاييس مثل Homogeneity و Completeness و Adjusted Rand؟
الإجابة: هذه المؤشرات تُستخدم لتقييم مدى جودة العناقيد التي أنتجتها خوارزمية التجميع، للتأكد من أن العناقيد متماسكة داخليًا (Homogeneity) وأنها تغطي جميع البيانات بشكل كامل (Completeness)، ومدى توافقها مع التقسيم الحقيقي إذا كان معروفًا (Adjusted Rand).
الشرح: هذه المقاييس تساعد على فهم ما إذا كانت خوارزمية التجميع نجحت في فصل البيانات إلى مجموعات منطقية وذات معنى، خاصة عندما لا يكون لدينا تقسيم مسبق معروف (unsupervised learning).
تلميح: بعد إنشاء مجموعات، كيف يمكننا أن نقول إنها 'جيدة'؟ ما هي الصفات التي نبحث عنها في المجموعات الجيدة؟