Skip to main content

Feature Engineering

Overview​

The FeatureEngineer class extracts 183 physics-based spectroscopic features from each preprocessed LAMOST spectrum. All features correspond to physically interpretable spectral properties. FeatureEngineer itself computes nothing from positions, instrument metadata or Gaia: these 183 features come from the spectrum alone.

Design philosophy

Every feature in AstroSpectro can be computed by a spectroscopist working with only the stellar spectrum. No positional information, survey metadata, or Gaia-derived parameter is computed by FeatureEngineer.

This is not the same as saying the trained classifier uses no Gaia column. The reference run (v6) selected 4 Gaia/photometric columns (M_G, M_BP, M_RP, ag_gspphot) from the cross-matched catalogue, next to the spectral features; see spectro_only=True Mode and the Data Leakage Audit.

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

The 9 feature families​

1. Balmer series (Hα to Hθ) — ~25 features​

For each Balmer line, three measurements are extracted:

MeasurementSymbolUnitDescription
Equivalent widthEWÅIntegrated line strength relative to continuum
Prominenceprom—Peak depth relative to local pseudo-continuum
FWHMfwhmÅFull width at half maximum

Reference wavelengths (NIST):

Lineλ (Å)Series
Hα6562.8n=3→2
Hβ4861.3n=4→2
Hγ4340.5n=5→2
Hδ4101.7n=6→2

2. Ca II H&K doublet — ~20 features​

Lineλ (Å)Importance
Ca II K3933.7#1 SHAP feature
Ca II H3968.5#4 SHAP feature
Ca II IR triplet8498, 8542, 8662Additional gravity indicator

3. Mg / Na / α-elements — ~15 features​

Lineλ (Å)Physical use
Mg b triplet5167, 5173, 5184Gravity + metallicity
Na D doublet5890, 5896ISM + chromospheric
[Mg/Fe] proxyderivedα-element enhancement

4. Molecular bands — ~20 features​

Active for T_eff < ~4,000 K (K-M stars):

BandMoleculeλ range (Å)
TiO γTiO5167–5169
TiO εTiO8432–8452
CaHCaH6382–6389
MgHMgH4780–4850

5. Fe & metal lines — ~25 features​

Key iron lines used in metallicity indices:

Lineλ (Å)
Fe I4668, 5270, 5335, 5406, 5709, 5782
Fe II4924, 5018, 5169

6. Continuum indices — ~30 features​

Shape-based features computed from spectral continuum:

  • Synthetic colour indices (B−V, V−I, R−I equivalents)
  • Blue/red flux ratios
  • Continuum slope fits
  • Lick IDS indices

7. Line ratios — ~20 features​

Physically motivated ratios between pairs of lines:

# Examples
Ca_K_to_Hb = Ca_II_K_EW / Hbeta_EW # metallicity/temperature
Fe_to_Mg = Fe_EW_sum / Mg_b_EW # [Fe/Mg] proxy
TiO_to_CaH = TiO_index / CaH_index # luminosity class (M stars)

8. Line-profile moments — ~15 features​

For key lines (Hα, Ca II K, Mg b):

  • Asymmetry: skewness of the line profile
  • Kurtosis: peakedness relative to Gaussian
  • EW/FWHM ratio: shape parameter

9. match_* columns — ~13 features​

These features are added by ProcessingPipeline during the line-matching step. They represent the best-match line measurements after correcting for radial velocity:

match_CaIIK_prom, match_CaIIH_prom, match_Hbeta_EW, ...
note

These match_* columns are the difference between the 174-feature FeatureEngineer output and the canonical 183-feature total. Use spectro_only=True mode so that all 183 features are computed from the spectrum alone.


Implementation​

from pipeline.feature_engineering import FeatureEngineer

fe = FeatureEngineer(spectro_only=True)
features_df = fe.extract_features(spectra_df)
# → DataFrame with 183 columns per spectrum

NumPy 2.0 compatibility note​

The module uses np.trapezoid (NumPy 2.0+) with a fallback to np.trapz (NumPy < 2.0):

try:
area = np.trapezoid(y, x)
except AttributeError:
area = np.trapz(y, x) # NumPy < 2.0

Performance​

Value
Extraction time per spectrum~2 ms
Full dataset (N = 43,019)~90 s (Ryzen 9 5950X, 32 threads)
Parallelisationjoblib with num_workers=0 (Windows)
Memory footprint~45 MB for full feature matrix

See also​