Skip to main content

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.csv must exist (produced by notebook 04)
  • Shape: 731 rows × 5 columns in the file (pl_name, PC1, PC2, PC3, PC4); the clustering matrix X is 731 × 4 (PC1–PC4 only)
  • Variance: 4 components collectively retain 90.35% of original variance
  • Identifier: pl_name is 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.
KInertia (WCSS)Silhouette Score
24023.360.4950
32820.810.3223
42392.980.3238
5+< 0.28
K=2 is selected. It achieves the highest Silhouette score by a clear margin and corresponds to the primary elbow in the inertia curve. Higher K values produce marginally lower inertia at the cost of substantially weaker cluster separation.

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.
SeedInertiaSilhouetteAgreement with K=2 Baseline
42 (baseline)4023.360.4950
104023.360.4950100.00%
20264023.360.4950100.00%
99994023.360.4950100.00%
1004025.210.479699.04%
Three seeds reproduce the baseline solution exactly. Seed 100 produces a marginally higher inertia and assigns 7 of 731 planets differently (99.04% agreement), which represents a negligible boundary effect. The K=2 solution is highly stable, reproducible, and free from sensitivity to centroid initialization.

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
Labels are joined to the PCA scores by pl_name — never by row position — to guarantee correct alignment even if row order changes.

Output Artifacts

FileDescription
data/processed/clustered_exoplanets.csv731 rows with pl_name, PC1PC4, Cluster_K2, Familia_Planeta
This file closes the ExoProfiler ML pipeline. It is the primary input for any downstream profiling, visualization, or product layer (e.g., the Streamlit application).

Running the Notebook

jupyter notebook notebooks/05_clustering_and_evaluation.ipynb
Prerequisite: 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
Cluster 0 (Standard Population) captures the continuum of Terrestrials, Super-Earths, and Sub-Neptunes — the dominant population in TESS discoveries and the statistical backbone of the dataset.Cluster 1 (Exotic Objects) isolates Gas Giants and Hot Jupiters at the extreme end of the mass and radius distributions, characterized by anomalous orbital parameters and high insolation flux.The clusters are data-driven, not manually defined. Their correspondence with NASA’s categories provides interpretive grounding but should not be treated as an exact classification system — the boundary between populations is a continuous gradient, not a sharp physical threshold.

Build docs developers (and LLMs) love