API Reference#
Complete reference for all public classes and functions in MaldiDeepKit, organized by module.
Base Classes#
Every classifier inherits from BaseSpectralClassifier,
which handles device placement, validation splits, early stopping, and
persistence. Subclasses only need to override _build_model().
Abstract base for all MaldiDeepKit classifiers. |
|
PyTorch |
|
Build stratified train / validation |
Classifiers#
sklearn-compatible MLP classifier with optional attention gating. |
|
sklearn-compatible 1-D CNN classifier for MALDI-TOF spectra. |
|
sklearn-compatible 1-D ResNet classifier for MALDI-TOF spectra. |
|
sklearn-compatible 1-D ViT classifier for MALDI-TOF spectra. |
Building Blocks#
Low-level nn.Module classes backing each classifier are re-exported
through the maldideepkit.blocks namespace, so a user who wants to
embed a single component in a custom network can import from one place.
See Blocks Module for the full list, grouped into full backbones vs.
composable primitives.
from maldideepkit.blocks import (
SpectralTransformer1D, # full backbones
TransformerBlock, # composable primitives
PatchEmbed1D,
BasicBlock1D,
# ...
)
Training Utilities#
Seed Python, NumPy, and PyTorch (CPU + CUDA) RNGs in one call. |
|
Resolve a user-facing device specifier to a |
|
Track the best validation loss and signal when to stop training. |
|
Run a classic train + validate loop with early stopping. |
|
Multi-class focal loss with optional class weighting and label smoothing. |
|
Wrap a base optimizer in the SAM two-step update. |
|
Pick the binary decision threshold that maximises |
|
Fit a scalar temperature by LBFGS minimisation of NLL. |
|
Sweep learning rate geometrically and return the LR / loss curve. |
|
Ensemble N fitted or unfitted spectral classifiers. |
Augmentation#
Per-batch augmentations applied to training batches only; bypassed during validation and inference. See Augment Module for the full API.
Composable per-batch spectrum augmentation. |
|
Mixup: convex-combine two random permutations of the batch. |
|
CutMix on 1-D spectra: splice a contiguous m/z window. |
Uncertainty Quantification#
Drop-in estimators that wrap a fitted classifier and return calibrated predictions plus per-sample uncertainty. See Uncertainty Module.
Monte Carlo Dropout estimator (Gal and Ghahramani, 2016). |
|
Laplace-approximation uncertainty estimator. |
|
Split conformal predictor with the LAC non-conformity score. |
|
Container for the output of a |