Skip to main content

XGBoost — Classification Performance

This page documents the results of the reference XGBoost classifier, run ST_350k_xgb_AFGKM_v6, trained on the 350k-spectrum generation (G2: 349,998 spectra processed, 99 selected features, five types A, F, G, K, M). It also describes how classifier predictions relate to the unsupervised UMAP structure of the PHY-3500 study — a qualitative comparison made on a different dataset (G1) with an earlier model.

Key results​

BA
89.2%
Balanced accuracy
balanced accuracy · 5 classes
On types A, F, G, K, M
F1
0.883
Macro F1
test set · N = 60,947
Accuracy 87.4%
AUC
0.986
ROC-AUC macro
global discriminability
1.000 = perfect
ST_350k_xgb_AFGKM_v6 · run 20260522T161236Z · G2 · 349,998 spectra
v6 · includes 4 Gaia/photometric features — see Data Leakage Audit
Gaia leak in run v6

Run v6 (ST_350k_xgb_AFGKM_v6) was trained with spectro_only enabled, but its 99 selected features include 4 Gaia/photometric columns (M_G, M_BP, M_RP, ag_gspphot). Its metrics are therefore not purely spectroscopic; see the Data Leakage Audit.


Context and motivation​

The conclusion of the PHY-3500 article (Baker, Caillat & Jean, 28 April 2026) uses an earlier classifier, run v5 (ST_100k_xgb_AFGKM_v5, 99,999 spectra processed), whose balanced accuracy on its own test set is 87.3%.

The article then projects the predictions of this model onto a different dataset. Its predictions, projected onto the UMAP embedding of the PHY-3500 dataset (PHY-3500 · G1 · 43,019 spectra), have a median confidence of 96.3% and follow the geography of the embedding. The article concludes that supervised and unsupervised methods capture the same physical structure, and that projections can serve as qualitative validation spaces for supervised models.

These v5 figures belong to that article and to G1; they are not the metrics of the reference run reported in Key results. Run v5 also includes a Gaia-derived column (M_G).


Experimental configuration​

spectro_only=True mode​

The reference run was trained with spectro_only=True in SpectralClassifier. The mode is meant to keep only flux-derived features; in addition to the columns that are always excluded (identifiers, ra/dec, redshift, seeing, SNR per band, GSP-Phot parameters, parallax, Gaia catalogue magnitudes), it removes every column whose name starts with a non-spectroscopic prefix (parallax, phot_, bp_rp, teff, logg, …).

The exclusion was prefix-based, and the Gaia-derived columns M_G, M_BP, M_RP and ag_gspphot match none of the prefixes: they reached the selected features of the reference run (see the caution above and Classification). The metrics below are therefore those of a mostly — not purely — spectroscopic model. The code has since been fixed with an explicit list of Gaia/photometric columns, but no complete spectro-only reference run exists yet.

Training data​

Experimental configuration
◎
Dataset
LAMOST DR5 × Gaia DR3
N = 349,998 spectra · G2
p
Descriptors
99
selected from 207 candidates
★
Target classes
A · F · G · K · M
5 stellar spectral types
≡
Metric
balanced_accuracy
optimization & evaluation
⊘
Split train/test
229,274 / 60,947
79 / 21 · stratified by class
XGBoost hyperparametersrun 20260522T161236Z
n_estimators
600
max_depth
6
learning_rate
0.1
colsample_bytree
0.8
subsample
0.8
tree_method
"hist"
Tuning with GridSearchCV · tree_method hist = GPU/CPU
v6 · includes 4 Gaia/photometric features — see Data Leakage Audit
from src.pipeline.classifier import SpectralClassifier

clf = SpectralClassifier(
model_type="XGBoost",
prediction_target="main_class",
)
clf.train_and_evaluate(features_df, spectro_only=True)

Classification results​

Per-class performance — the Harvard sequence​

Harvard sequence — effective temperature (K)
A
F
G
K
M
7 500+ K →← < 3 700 K
A
F1 = 0.893
6.1% of test set
Hot stars
> 7 500 K
Very strong Balmer lines
★ Sirius, Vega, Altair
F
F1 = 0.822
21.0% of test set
Yellow-white stars
6 000–7 500 K
Moderate Balmer lines, weak Ca II
★ Procyon, Canopus
G
F1 = 0.861
35.9% of test set
Solar-type stars
5 200–6 000 K
Moderate Ca II, weak Balmer lines
★ Sun, Tau Ceti, Alpha Cen A
K
F1 = 0.893
22.4% of test set
Orange stars
3 700–5 200 K
Strong Ca II, visible Mg b
★ Alpha Centauri B, Arcturus
M
F1 = 0.946
14.5% of test set
Cool red stars
< 3 700 K
TiO, VO, CaH molecular bands
★ Proxima Centauri, Betelgeuse
Class M — F1 = 0.946: TiO, VO, and CaH molecular bands are absent from all hot types — class M is spectrally unmistakable. Hover over the cards for performance notes.
F1 and class share: test set of ST_350k_xgb_AFGKM_v6 (run 20260522T161236Z · G2 · 349,998 spectra · test N = 60,947)
v6 · includes 4 Gaia/photometric features — see Data Leakage Audit

F/G confusion — the trickiest boundary​

The main confusion of the reference run is between F and G: true F predicted G (1,478 test spectra) and true G predicted F (2,179), and these two classes have the lowest F1 scores (F 0.822, G 0.861). The two types are adjacent in temperature and differ by gradual changes in line strengths; on the PHY-3500 UMAP (G1, model v5), the disputed spectra lie in the transition zone between the two populations. Full analysis: F/G Confusion Analysis.


Geographic coherence in UMAP space​

Principle of supervised/unsupervised cross-validation​

This section uses the PHY-3500 dataset (PHY-3500 · G1 · 43,019 spectra) and the predictions of run v5, not the reference run. The UMAP projection of XGBoost predictions allows qualitative validation of a model: if the supervised classifier has learned the same physical structure as UMAP (unsupervised), predictions should follow the geography of the projection.

Results​

Loading…
XGBoost predictions
Each point colored by the spectral type predicted by XGBoost
Class geography
A
Hot peninsula
Upper left — hot A-F stars
> 7,500 K
✓
F
Hot transition
Upper intermediate zone
6,000–7,500 K
✓
G
Central mass
Central main mass
5,200–6,000 K
✓
K
Cool periphery
Cool edge of the central mass
3,700–5,200 K
✓
M
Cool endpoint
Lower branch — M dwarfs
< 3,700 K
✓
Median confidence 96.3%
42,920 predictions of ST_100k_xgb_AFGKM_v5 (v5) projected on the PHY-3500 · G1 UMAP. The XGBoost geography in UMAP is consistent with the unsupervised structure: supervised and unsupervised methods capture the same physics.
v5 · includes 1 Gaia/photometric feature — see Data Leakage Audit

This direct correspondence between the emergent structure of UMAP (without labels) and XGBoost classification (with labels) demonstrates that both approaches capture the same underlying physical structure: the effective temperature sequence of Harvard's MK classification.


SHAP interpretability — which features decide?​

SHAP (SHapley Additive exPlanations) analysis of the reference run shows which features drive its decisions: 96.8% of the total mean |SHAP| goes to spectroscopic features and 3.2% to Gaia/photometric columns (share of total importance, not of the top-30).

⚡
Top SHAP feature — Mg b EW (Mg b)
The top 10 span 7 feature families; spectroscopic features carry 96.8% of the total mean |SHAP| for ST_350k_xgb_AFGKM_v6.
Mg b (1 in top-10)
Ca II (2 in top-10)
Continuum (2 in top-10)
Hα (Balmer) (1 in top-10)
Mol. CN/CH (2 in top-10)
Hβ (Balmer) (1 in top-10)
Na D (1 in top-10)
mean |SHAP| — model run 20260522T161236Z · G2 · 349,998 spectra
#
Feature
SHAP Importance
Family
1
Mg b EW
0.43
Mg b
2
CaH2 index
0.35
Ca II
3
slope deep red
0.30
Continuum
4
CaIIK EW
0.29
Ca II
5
Hα EW
0.27
Hα (Balmer)
6
continuum rms
0.26
Continuum
7
G4300 index
0.20
Mol. CN/CH
8
CN 2 index
0.19
Mol. CN/CH
9
Hbeta index
0.19
Hβ (Balmer)
10
Na D EW
0.17
Na D
29/30 of the 30 most important features (SHAP top-30) are spectroscopic; they carry 96.8% of the total mean |SHAP|. Hover bars to see the pipeline name of each feature.
v6 · includes 4 Gaia/photometric features — see Data Leakage Audit

PCA vs XGBoost — two questions, two answers​

PCA ranks features by the variance they carry, XGBoost by how much they help separate the classes; the two rankings answer different questions. The comparison below uses the PHY-3500 PCA (G1) and the SHAP run of the same generation (model v5):

PCA phy3500_pca_run_20260408T012751Z (PHY-3500 · G1 · 43,019 spectra) · SHAP ST_100k_xgb_AFGKM_v5 (run 20260306T020848Z · G1 · 99,999 spectra)
PCA
Direction of maximum variance
Unsupervised
Dominant feature
Hα EW
top PC1 loading +0.173 · PC1 = 16.9% variance
Physical result
Temperature T_eff
ρ(PC1, Teff) = +0.831
›Maximises total variance
›Balmer and continuum shape load PC1 → thermal axis
›Temperature = variance source #1
›No labels used
XGBoost
Optimal decision boundary
Supervised
Dominant feature
CaH2 index
SHAP top 3: CaH2 index · Mg b EW · Hα EW
Physical result
Spectroscopic features dominate
97.9% of Σ|SHAP| · 29/30 top features
›Minimises classification error
›SHAP on ST_100k_xgb_AFGKM_v5 (98 features)
›Mixes molecular bands, Mg b and Balmer lines
›Spectral type labels used
✓ These two results are complementary — they answer two different questions. PCA answers: "what is the dominant source of variance?" → temperature. XGBoost answers: "what information best separates classes?" → the SHAP ranking of ST_100k_xgb_AFGKM_v5 (same feature generation as the PCA), led by CaH2 index.
v5 · includes 1 Gaia/photometric feature — see Data Leakage Audit

This result is part of a coherent progression of the AstroSpectro project:

1
v3 · G1 · 99,999 spectra
86.4%
XGBoost
103 features · 3 Gaia/phot.
⚠ run 20260306T011253Z
→
2
v5 · G1 · 99,999 spectra
87.3%
XGBoost
98 features · 1 Gaia/phot.
⚠ run 20260306T020848Z
→
CURRENT
3
v6 · G2 · 349,998 spectra
89.2%
XGBoost
99 features · 4 Gaia/phot.
⚠ run 20260522T161236Z
Reading this timeline: each step is a recorded run; the value is the balanced accuracy on its own test set (A, F, G, K, M). Runs differ in sample size and feature set, so the steps are not a controlled ablation. ⚠ marks runs whose selected features include Gaia/photometric columns.
v6 · includes 4 Gaia/photometric features — see Data Leakage Audit

Using the model​

Load and predict​

from src.pipeline.classifier import SpectralClassifier

# Load a saved model (<ts> = run identifier)
clf = SpectralClassifier.load_model(
"data/models/spectral_classifier_xgboost_<ts>.pkl"
)

# Predict on new spectra (same feature format)
predictions = clf.model_pipeline.predict(X_new)
probabilities = clf.model_pipeline.predict_proba(X_new)

Reference run metadata​

Each run is documented by:

data/models/
├── spectral_classifier_xgboost_<ts>.pkl
└── spectral_classifier_xgboost_<ts>_meta.json
data/reports/<ts>/
└── session_report_xgboost_<ts>.json

For the reference run, <ts> = 20260522T161236Z. Its meta JSON contains the final hyperparameters, the 99 selected features (out of 207 candidates), the class labels and the training file (features_20260522T153123Z.csv); the session report records the model MD5 hash (e752bb7ce5494364364f77a4200aa480). See Reproducibility.