Command-line interface
xpectra installs ten console scripts. Four are the everyday pipeline; the rest reproduce the
published study (see Study reproduction workflows).
Command |
Purpose |
|---|---|
|
Build the three route files from the bundled sources |
|
Train and save models per route |
|
Predict polymer class for new spectra |
|
Run a named reproduction workflow |
|
Corrected deep-model reanalysis + figures |
|
Contrastive-representation diagnostics + figures |
|
Degradation-clustering diagnostics + figures |
xpectra-process-raw
Regenerate the three route files (.csv.xz). --out-dir defaults to processed_data/.
xpectra-process-raw # write to processed_data/
xpectra-process-raw --out-dir some/dir # write elsewhere
xpectra-process-raw --dry-run # build + verify, write nothing
xpectra-process-raw --keep-duplicates # retain within-study duplicate spectra
xpectra-process-raw --no-external # skip the external augmentation datasets
Deduplication happens here, at source, so the normalized and derivative matrices are duplicate-free for every downstream consumer.
xpectra-train
Train the model panel and save artifacts per route.
xpectra-train --routes all
xpectra-train --routes norm deriv1 --model "XGBoost (100)" --model "Random Forest (100)"
Artifacts are written to models/<route>/<model>.joblib, each bundling the fitted estimator,
StandardScaler, LabelEncoder, class names, preprocessing settings, and the exact training
wavenumber order. A models/training_summary.csv collates the run.
xpectra-predict
Predict from a CSV of spectra through the saved route artifacts.
xpectra-predict path/to/raw_spectra.csv --routes all --output predictions.csv
The --input-stage flag controls how much preprocessing to apply, matching the state of your
input:
|
Input is… |
Pipeline applied |
|---|---|---|
|
raw instrument spectra |
denoise → baseline → normalize → interpolate → derive |
|
already normalized |
interpolate → derive only |
|
already route-ready on the grid |
none |
Preprocessing can be overridden for raw inputs:
xpectra-predict path/to/raw_spectra.csv \
--denoising-method wavelet --baseline-method aspls \
--normalization-method spectral_moments --interpolate-method zero
# absorbance-like inputs stored on a 0–100 scale
xpectra-predict path/to/raw_spectra.csv --force-absorbance --absorbance-scale-factor 100
xpectra-study
List and run the reproduction workflows. Each accepts --route {norm,deriv1,deriv2} where
applicable (see Study reproduction workflows).
xpectra-study --list
xpectra-study loso
xpectra-study deep-ssl --route norm