Skip to main content

SHAP Interpretability

Run context

SHAP of the reference classifier ST_350k_xgb_AFGKM_v6 (20260522T161236Z) · XGBoost · spectro_only mode · G2, 349,998 spectra · 99 selected features · classes A / F / G / K / M.

v6 · includes 4 Gaia/photometric features — see Data Leakage Audit

The central finding​

Key scientific result

Current SHAP results for the reference model suggest that a small set of spectroscopic features (Mg b, CaH2, the deep-red continuum slope, Ca II K and Hα) carries most of the learned classification structure, alongside classical Balmer temperature indicators.

  • 96.8% of the total mean |SHAP| comes from spectroscopic features; 29 of the 30 most important features are spectroscopic. The remainder belongs to Gaia/photometric columns (3.2%), see the Data Leakage Audit
  • Ranks 1–3: feature_Mg_b_eq_width, feature_index_CaH2, feature_slope_deep_red; Ca II K equivalent width (feature_CaIIK_eq_width) is rank 4
  • This contrasts with PCA where Balmer lines dominate PC1 (the temperature axis)

"Suggest" is used deliberately — the finding is robust within this dataset and model configuration, but replication across independent surveys and model families remains future work.


SHAP vs PCA: two complementary questions​

MethodQuestion answeredDominant featurePhysical result
PCA (unsupervised, PHY-3500 · G1)What is the primary source of variance?Balmer lines (PC1 = thermal axis, 16.9% of the variance)Temperature T_eff dominates variance
XGBoost + SHAP (supervised, reference run)What best separates spectral classes?Mg b, CaH2, deep-red slope (ranks 1–3), then Ca II KMixed metal and band indicators are the most discriminative

These results are not contradictory — they answer different questions. Temperature (Balmer) drives the most variance in spectral space. Metal and molecular-band indicators are more discriminative for class boundary decisions.

SHAP comparison PCA vs XGBoost
SHAP importance heatmap by feature × class — SHAP analysis features_20260305T174836Z (model v5, which also kept Gaia/photometric columns)

Top-10 SHAP features (mean |SHAP value| across all classes)​

⚡
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

The share of spectroscopic features is reported above (96.8% of the summed mean |SHAP|, not a share of the top-30). Gaia absolute magnitudes (M_G, M_BP, M_RP) and ag_gspphot are among the selected features and carry the rest, so the claim "no Gaia-derived feature is used" does not hold for this run.

Top features SHAP per class
Class-specific SHAP importance — top 10 features per spectral type, reference run v6 (01_data_leak)

Per-class dominant features​

Top three features of each class in the figure above (reference run v6, mean |SHAP| per class). The ranking is read off the figure: shap_feature_importance.csv holds the global importance only, with no per-class table.

ClassTop three features (in order)Also in the class top 10
ACa II K equivalent width, G4300 index, CN₂ indexHβ index, Hγ and Hδ FWHM
FMg b equivalent width, Na D equivalent width, continuum curvatureHα depth, Al 3944 equivalent width
GMg 5184 equivalent width, CNO index, EW(Hα)/EW(Hβ) ratioNa D Lick index, Dn4000
KMg b equivalent width, Hα equivalent width, deep-red slopebp_g (broadband colour)
MCaH2 index, deep-red slope, continuum RMSTiO5 index, M_BP (Gaia/photometric), color_ri

Two readings follow, both suggestive rather than established. Different features lead each class, and the leaders are not the textbook temperature indicators one might expect for every class (for A stars, Ca II K and the G4300 band come before the Balmer measurements). Gaia/photometric or colour columns reach the top 10 of classes K and M (see Data Leakage Audit). No per-class physical interpretation is claimed here; that needs an expert reading of the SHAP dependence plots.


Physical validation: Ca II K vs [Fe/H]​

The correlation between Ca II K prominence (a Ca II K descriptor; its equivalent width ranks 4th in the reference run) and Gaia DR3 [Fe/H] is shown below. It is a descriptive check of the Ca II K descriptor against an external metallicity, not a validation of the SHAP ranking.

Ca II K vs metallicity

Ca II K prominence vs Gaia DR3 [Fe/H] — G1 figure, kept as a descriptive check


PCA vs XGBoost: why the difference matters​

PCA: maximises total variance → Balmer / temperature axis (PC1, G1)
XGBoost: minimises class error → Mg b, CaH2, deep-red slope, then Ca II K (v6, G2)

The two analyses use different data (PCA: G1; SHAP: the v6 run on G2) and answer different questions, so the comparison is qualitative.

  • PCA follows the direction of maximum variance in the sample, which is thermal.
  • XGBoost + SHAP shows which features the trained model relies on to separate the five classes. Hα equivalent width is rank 5 and Ca II K equivalent width rank 4, so the reference run does not support a simple "Ca II outranks Balmer" statement. What it shows is that Mg b, the CaH2 band and the deep-red slope come first.
  • Why those features rank high is not tested here. Explanations such as metallicity-at-fixed-temperature remain hypotheses.

Known limitations of this SHAP analysis​

Limitations
  1. Model-specific: SHAP values reflect the decision structure of a single XGBoost model. Different model families (neural networks, random forests) may yield different rankings.

  2. Ca II H&K and chromospheric activity: These lines respond to both metallicity and stellar chromospheric activity (e.g., active M dwarfs show Ca II emission). The SHAP finding conflates these two physical effects.

  3. Single train/test split: Bootstrapped SHAP stability across multiple splits has not been assessed in the current version.

  4. Gaia/photometric columns: The reference model includes four Gaia/photometric features (M_G, M_BP, M_RP, ag_gspphot). A SHAP analysis of a model without them is not available: v7 was trained without them, but that run is partial and no complete spectro-only reference run exists yet. See the Data Leakage Audit.


See also​