API reference

The public API is re-exported from the top-level xpectra namespace. The tables below are generated from the installed package; click any name for the full signature and docstring.

Configuration & data

xpectra.TrustConfig

xpectra.load_labeled

Labeled spectra (4 studies, unknowns dropped), grouped 6-class labels.

xpectra.load_unknown

The kedzierski_2019_u unlabeled environmental pool, on the labeled grid.

xpectra.load_external

One external augmentation pool (openspecy / simple / awi2024) from the norm route.

xpectra.loso_splits

Leave-one-study-out folds over the labeled studies.

xpectra.leave_one_class_out

Masks for synthetic OOD: train without one class, hold it out as OOD.

Metrics

xpectra.expected_calibration_error

Top-label ECE plus the per-bin table used for reliability diagrams.

xpectra.multiclass_brier

Mean squared error between one-hot labels and predicted probabilities.

xpectra.risk_coverage

Selective-risk curve: abstain on the least confident samples first.

xpectra.aurc

Area under the risk-coverage curve (lower is better).

xpectra.selective_metrics_at_coverage

Accuracy/macro-F1/MCC on the retained fraction at a target coverage.

Calibration

xpectra.CalibratedModel

One estimator + one calibration method behind a uniform proba API.

xpectra.TemperatureScaler

Single-parameter temperature scaling fitted by NLL minimization.

xpectra.reliability_curve

Per-bin confidence/accuracy table for reliability diagrams.

Out-of-distribution detection & abstention

xpectra.AbstainingClassifier

Predict a class when the OOD score is below tau, otherwise abstain.

xpectra.MaxSoftmax

1 - max predicted probability.

xpectra.Entropy

Normalized Shannon entropy of the predictive distribution.

xpectra.Energy

Negative log-sum-exp of logits (log-proba fallback for CV-calibrated models).

xpectra.Mahalanobis

Min per-class Mahalanobis distance in PCA space (shared LW covariance).

xpectra.KNNDistance

Distance to the k-th nearest training sample in PCA space.

xpectra.SpectralAngleScorer

Min spectral angle to the class-mean spectra (norm route only).

Semi-supervised learning

xpectra.self_train

xpectra.label_spread

LabelSpreading with a sparse kNN kernel on PCA-reduced features.

xpectra.ssl_loso_experiment

Per LOSO fold: supervised-only vs self-training vs label-spreading, all evaluated on the held-out study.

Weathering analysis

xpectra.band_area

Integrated area (or peak height) of a wavenumber window.

xpectra.carbonyl_index

C=O band relative to the CH2-scissoring reference band.

xpectra.weathering_report

Spearman correlations of carbonyl index vs confidence and OOD scores.

xpectra.unknown_composition

Class fractions among the unknowns, with and without abstentions.

Module index

xpectra.config

Configuration for the xpectra weathered-unknowns study.

xpectra.data

Data loading for the trust study, built on xpectra.pipeline.

xpectra.metrics

Calibration and selective-prediction metrics not provided by sklearn.

xpectra.calibration

Leakage-safe probability calibration wrappers.

xpectra.ood

Out-of-distribution scoring and abstention.

xpectra.ssl

Semi-supervised learning: do the 4,058 unlabeled weathered spectra help?

xpectra.weathering

Band-ratio weathering indicators (carbonyl index) and composition tables.

xpectra.protocols

Experimental orchestrators shared by the driver scripts.

xpectra.plotting

Publication figures for the trust study.

xpectra.pipeline

Reusable training and prediction utilities for the FTIR notebooks.