Documentation Index
Fetch the complete documentation index at: https://mintlify.com/LauraSilRu/exoplanet-profiler/llms.txt
Use this file to discover all available pages before exploring further.
05_clustering_and_evaluation.ipynb takes the 4 PCA components from notebook 04 and applies K-Means clustering to discover natural groupings among the 731 exoplanets. After evaluating K values from 2 to 10, K=2 is selected based on a Silhouette score of 0.4950. Stability is confirmed across multiple random seeds and cross-validated with DBSCAN and hierarchical clustering.
Input Contract
Before running this notebook, verify the following:
- File:
data/processed/pca/pca_scores.csvmust exist (produced by notebook 04) - Shape: 731 rows × 5 columns in the file (
pl_name,PC1,PC2,PC3,PC4); the clustering matrixXis 731 × 4 (PC1–PC4 only) - Variance: 4 components collectively retain 90.35% of original variance
- Identifier:
pl_nameis unique and non-null; it is separated from the feature matrix before clustering and re-joined to labels at export
pl_name is never passed to the K-Means algorithm.K Evaluation
K-Means is evaluated for every value of K from 2 to 10. The Silhouette Coefficient quantifies how well each point fits its own cluster relative to the nearest alternative cluster (1.0 is perfect separation; 0.0 is ambiguous; negative is misassigned). The elbow method plots within-cluster sum of squares (inertia/WCSS) to identify the point of diminishing returns.The evaluation starts at K=2 because the Silhouette Coefficient requires at
least two clusters to compare intra-cluster cohesion against inter-cluster
separation. The metric is mathematically undefined for K=1.
| K | Inertia (WCSS) | Silhouette Score |
|---|---|---|
| 2 | 4023.36 | 0.4950 ⭐ |
| 3 | 2820.81 | 0.3223 |
| 4 | 2392.98 | 0.3238 |
| 5+ | — | < 0.28 |
Stability Analysis
The K=2 model is retrained with five different random seeds to verify that the solution is not an artifact of centroid initialization.| Seed | Inertia | Silhouette | Agreement with K=2 Baseline |
|---|---|---|---|
| 42 (baseline) | 4023.36 | 0.4950 | — |
| 10 | 4023.36 | 0.4950 | 100.00% |
| 2026 | 4023.36 | 0.4950 | 100.00% |
| 9999 | 4023.36 | 0.4950 | 100.00% |
| 100 | 4025.21 | 0.4796 | 99.04% |
Cross-Validation with Alternative Algorithms
Two alternative clustering algorithms are applied to independently verify that the K=2 structure reflects a genuine pattern in the data rather than an artifact of the K-Means objective function. Hierarchical (Agglomerative) Clustering. The dendrogram shows two clearly dominant primary branches, confirming that the 731 exoplanets naturally split into two large groups when built bottom-up. Label agreement with the K-Means K=2 assignment is 97.13%. The 2.87% disagreement occurs at the boundary between the two populations. DBSCAN (Density-Based). DBSCAN does not require a pre-specified K. It identifies one large, dense majority cluster and approximately 60 isolated points classified as noise or outliers (label = -1). This is consistent with the K-Means Cluster 1 structure — a small population of extreme objects with unusual orbital and physical properties, separated from the mainstream.
The convergence of three independent algorithms on the same two-population structure provides strong evidence that K=2 reflects a real, stable partition of the exoplanet data.
Cluster Profiles
Cluster 0 — Standard Population
667 exoplanets (91.24%)The mainstream of TESS discoveries. Captures rocky planets, Super-Earths,
and Sub-Neptunes with typical orbital periods, moderate radii, and stellar
hosts spanning a wide range of effective temperatures. Represents the
statistical norm in the sample.
Cluster 1 — Exotic Objects
64 exoplanets (8.76%)Massive gas giants and Hot Jupiters characterized by extreme orbital
parameters, high planetary mass, and large planetary radii. These are
the outliers confirmed by DBSCAN — physically real objects that sit in
the tail of every feature distribution.
Label Export
After the final K=2 model is validated, two label columns are added to the dataset and exported:Cluster_K2— integer cluster label (0 or 1)Familia_Planeta— human-readable descriptive label:'Familia 0 (Población Estándar)'for Cluster 0'Familia 1 (Población Exótica / Atípica)'for Cluster 1
pl_name — never by row position — to guarantee correct alignment even if row order changes.
Output Artifacts
| File | Description |
|---|---|
data/processed/clustered_exoplanets.csv | 731 rows with pl_name, PC1–PC4, Cluster_K2, Familia_Planeta |
Running the Notebook
data/processed/pca/pca_scores.csv must exist and contain 731 rows. Run notebook 04 first if this file is missing or outdated.
Astrophysical Context
The two ExoProfiler clusters align closely with NASA’s recognized planetary
size categories:
- Terrestrials & Super-Earths — rocky planets with radius < 2 R⊕
- Sub-Neptunes — intermediate gaseous planets, 2–4 R⊕
- Gas Giants / Hot Jupiters — massive planets > 4 R⊕ with high mass and often short, hot orbits