Skip to main content

AstroSpectro

Interpretable machine-learning pipeline for stellar spectral classification.

LAMOST DR5 × Gaia DR3 · 183 engineered features · XGBoost · TreeSHAP

Scientific question

When a modern ML classifier is trained on large-scale stellar spectroscopy, which physical indicators actually drive its decisions?
AstroSpectro was built to answer this — with physics-motivated descriptors, a reproducible pipeline, and post-hoc SHAP interpretability on N ≈ 350k LAMOST DR5 × Gaia DR3 spectra.

⚛
Physics-informed
183 spectroscopic descriptors derived from astrophysical line physics — equivalent widths, FWHM, Lick indices, molecular band strengths. Every feature carries physical meaning before the model sees it.
◎
Interpretable by design
TreeSHAP post-hoc analysis validates what the classifier actually learns against known stellar physics — not just whether the accuracy score meets an arbitrary threshold.
⊘
Leakage-aware
spectro_only = True enforces strict exclusion of positional coordinates, redshift, and observational metadata at training time. Physical purity is a design constraint, not an afterthought.
Results are versioned elsewhere

AstroSpectro is actively evolving. Current metrics, SHAP rankings, and model comparisons are intentionally centralised in the dedicated results, model-card, and claims-register pages — not here. This introduction page is designed to stay stable as the project grows.


Scientific purpose​

AstroSpectro exists to investigate a deceptively simple question: when a machine learning classifier is trained on a large stellar spectroscopic survey, which physical indicators actually determine its decisions?

The classical MK spectral classification system places effective temperature — traced by Balmer series strength — at the centre of the A/F/G/K/M hierarchy. Modern surveys like LAMOST DR5 now make it possible to train classifiers on hundreds of thousands of spectra and then interrogate those models via post-hoc interpretability methods. AstroSpectro does exactly this, with four explicit scientific goals:

  • Classify stellar spectra into five Harvard types (A, F, G, K, M) with calibrated confidence, using only features derivable from the spectrum itself.
  • Extract physically meaningful descriptors that encode astrophysical observables — line strengths, profile shapes, molecular band indices — rather than raw flux pixels.
  • Validate what the model learns against independent stellar parameters from Gaia DR3, confirming or challenging the astrophysical coherence of the classification structure.
  • Avoid observational shortcuts: positional, temporal, and survey-specific metadata are excluded at the architectural level via spectro_only = True.

What AstroSpectro does​

The pipeline operates in six stages, from raw FITS files to astrophysical interpretation.

  • 01
    LAMOST DR5 spectraSmartDownloader

    Raw .fits.gz spectra are downloaded from the LAMOST DR5 public archive. The SmartDownloader module implements idempotent, resumable parallel downloading organised by observation plan — progress is preserved across sessions.

    LAMOST DR5 →
  • 02
    Preprocessing

    Each spectrum is wavelength-normalised onto a common λ grid (3,690–9,100 Å, 3,921 channels), continuum-divided, and subjected to quality filters (SNRg threshold, Gaia RUWE filter). Spectra failing quality criteria are rejected before any features are computed.

    Preprocessing →
  • 03
    Feature engineering183 descriptors

    The FeatureEngineer module extracts 183 spectroscopic descriptors spanning six physical families: Balmer lines, Ca II H&K and IR triplet, Mg b and α-elements, iron-peak metals, Lick/SDSS band indices, and continuum slopes. Each descriptor carries a direct astrophysical interpretation before the classifier ever sees it.

    Feature engineering →
  • 04
    Classifier trainingspectro_only = True

    An XGBoost gradient-boosted classifier is trained on the feature matrix with spectro_only = True enforced throughout. The calibrated model outputs class-conditional probability vectors, and every run is logged to Weights & Biases with a reproducible session report and MD5 hash.

    Classification →
  • 05
    Dimensionality reductionPCA · UMAP · t-SNE · AE

    Independently of the supervised pipeline, the same 183-feature matrix is explored via PCA, UMAP + HDBSCAN, t-SNE, and a symmetric autoencoder. This multi-method analysis reveals what physical structure the high-dimensional feature space contains and whether different projection methods recover equivalent information.

    Dimensionality reduction →
  • 06
    Scientific interpretationTreeSHAP

    TreeSHAP is applied post-hoc to the trained classifier to decompose every prediction into per-feature contributions. The global importance ranking is then cross-validated against Gaia DR3 stellar parameters — T_eff, log g, [Fe/H] — to assess the physical coherence of what the model has learned.

    SHAP Interpretability →

Project philosophy​

01
spectro_only = True
Spectroscopy first

The classifier ingests only spectroscopic descriptors — line strengths, profiles, and indices derived from the stellar spectrum itself. Positional coordinates, redshift, and Gaia metadata are excluded at training time. The model must earn its accuracy from physics alone.

02
SHAP + physical validation
Interpretability over accuracy

A high accuracy score that cannot be explained by astrophysics is not sufficient. Every classification decision should be traceable to known stellar physics via SHAP values, and the resulting rankings should be validated against independent stellar parameters from Gaia DR3.

03
feature audit + claims register
Leakage as a design concern

Observational shortcuts — features that correlate with labels for non-physical reasons — are tracked and excluded explicitly. A Data Leakage Audit documents every exclusion decision, and the spectro_only mode enforces the boundary at runtime.

04
W&B · session reports · MD5
Reproducible runs

Every training run is logged to Weights & Biases and produces a JSON session report containing hyperparameters, feature lists, and a model MD5 hash. Results are never stated without a pointer to the specific experiment that produced them.

05
Scientific Claims Register
Claims backed by evidence

Scientific findings are tracked in a dedicated Claims Register with an explicit evidence level — suggests vs. confirms — and a pointer to the analysis that supports each claim. No finding is promoted to the documentation without it.


Pipeline at a glance​

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

Three-tier architecture​

The project is organised in three tiers that build on each other and can be read independently.

Tier 1 — Core pipeline Preprocessing → Feature engineering → Classification

The foundational tier: from raw FITS spectra to a trained, calibrated classifier. It covers the SmartDownloader, the FeatureEngineer (183 descriptors), the GaiaCrossmatcher (Gaia DR3 positional match), and the SpectralClassifier (XGBoost, isotonic calibration, SHAP output). spectro_only = True is the central design constraint of this tier.

See: Core Pipeline

Tier 2 — Dimensionality reduction PCA · UMAP · t-SNE · Autoencoder · HDBSCAN

An independent multi-method exploration of the 183-feature matrix in low dimensions. This tier covers the algorithmic foundations of each method, their hyperparameter sensitivity, their Procrustes stability, and the physical interpretation of their axes and clusters. It constitutes the analytical core of the PHY-3500 course project (Baker, Caillat & Jean, Université Laval, 2026).

See: Dimensionality Reduction

Tier 3 — Scientific validation SHAP · Physical cross-checks · Claims register

Post-hoc interpretability and astrophysical validation of the classifier's decisions. This tier contains the SHAP global importance analysis, per-class beeswarm plots, feature interaction matrices, physical cross-validation against Gaia DR3 parameters, and the Scientific Claims Register that tracks every finding with its evidence level.

See: Scientific Analysis


Research sections​

SectionContentsStatus
OverviewScientific motivation · key results · project map✓
Concepts & Architecturespectro_only=True · physical purity · data lifecycle✓
Data & DatasetsLAMOST DR5 · Gaia DR3 · feature catalogue (183 features)✓
Core PipelinePreprocessing · feature engineering · XGBoost v6✓
Dimensionality ReductionPCA · UMAP + HDBSCAN · t-SNE · Autoencoder✓
⭐Scientific AnalysisSHAP · classification · validation · limitations✓
GuidesInstallation · quick start · Gaia connection✓
API ReferencePreprocessor · FeatureEngineer · Classifier · Dimred✓
CommunityRoadmap · RNAAS manuscript · citing✓

Where to find current results​

ℹLatest highlighted analysis

The current SHAP analysis suggests that metallicity-sensitive spectroscopic descriptors, including Mg b and Ca II features, play a major role in the learned classification structure — above classical Balmer temperature indicators.

This finding is tracked in the dedicated SHAP and Claims Register pages, which are the authoritative sources for all quantitative claims.

If you are looking for…Go to
Classification accuracy and per-class metricsKey Results at a Glance
SHAP feature importance rankingSHAP Interpretability
Physical validation plots (Ca II K vs [Fe/H], Hα FWHM vs T_eff)Scientific Validation
PCA, UMAP, t-SNE, autoencoder quantitative resultsDimensionality Reduction
XGBoost hyperparameters and model architectureClassification
Evidence levels for all findingsScientific Claims Register
F/G boundary confusion analysisF/G Confusion Analysis

Run provenance​

Current runST_350k_xgb_AFGKM_v6
Experiment
ST_350k_xgb_AFGKM_v6
Saved (UTC)
20260522T161236Z
MD5
e752bb7ce5494364364f77a4200aa480
Stack
Python 3.11.9 / XGBoost 3.1.1
Full dataset retraining · 350k spectra · spectro_only = True · isotonic calibrationFor detailed metrics →
v6 · includes 4 Gaia/photometric features — see Data Leakage Audit

Cross-references​

Related pageRelation
⭐ SHAP InterpretabilityCentral scientific contribution
Key Results at a GlanceAll current performance metrics
Model Card — XGBoostFull architecture, hyperparams, per-class metrics
Data Leakage AuditWhich features are and are not spectroscopic
Scientific Claims RegisterEvidence level for all findings on this project
AstroVisionCompanion project — galaxy morphology
GitHub — AstroSpectroCode · releases · notebooks