Models
This section covers model training, comparison, and optimization in NIRS4ALL.
- Model Training
- Hyperparameter Tuning
- Search source subsets, preprocessing chains and Ridge versus PLS
- Fixed ordered preprocessing chains
- Ordered source subsets before preprocessing
- Recipe and parameter identity
- Stop and resume
- Typed modality alternatives and weighted early fusion
- Early versus learned late fusion
- Bounded parallel typed campaigns
- Dense profile limits
- Native typed classification with early or learned late fusion
- Native structural Torch regression on CPU
- Native tuning and conformal calibration
- What is native today
- Native keyword/effect quick map
- Minimal pattern
- Inspecting tuning and conformal outputs
- Public Python result types
- Important keywords and effects
- Calibrating from an explicit dataset cohort
- Applying a stored calibrator
- Audit-only robustness report
- Workspace CLI
- Executable example
- Reading the guarantee metadata
- Native PLS phase controls
- Native PLS HPO within each outer fold
- Initialize SGD REFIT from an explicit CV fold
- AOM Models
- Deep Learning Models
- TabPFN for NIRS — fixed recipe (no HPO)
Overview
NIRS4ALL supports a wide range of machine learning models from different frameworks. This section covers model training workflows.
Train models with cross-validation and evaluate performance.
Optimize models with Optuna integration and grid search.
Use the native run(tuning=...) subset, persist tuning/conformal evidence, and apply calibrated intervals.
Includes the smoke-tested tune→calibrate→predict→robustness example.
Includes a native PLS example that tunes model.n_components.
Use TensorFlow, PyTorch, and JAX models in pipelines.
Use AOM-PLS, AOM-Ridge, AutoSelector, Blender, and FastAOM with pipeline folds.
Fixed-recipe TabPFN regressor that matches per-dataset HPO without it.
Supported Model Frameworks
Framework |
Import |
Examples |
|---|---|---|
scikit-learn |
Direct |
PLSRegression, RandomForest, SVM |
TensorFlow/Keras |
|
Sequential, Custom architectures |
PyTorch |
|
nn.Module subclasses |
JAX |
|
Flax/Haiku models |
Quick Example
from sklearn.cross_decomposition import PLSRegression
from sklearn.model_selection import KFold
result = nirs4all.run([
MinMaxScaler(),
KFold(n_splits=5),
{"model": PLSRegression(n_components=10)}
], dataset="data/")
print(f"RMSE: {result.best_rmse:.4f}")
Built-in NIRS Models
NIRS4ALL includes specialized models optimized for spectroscopy:
PLS Variants
Model |
Description |
|---|---|
AOMPLSRegressor |
Adaptive Operator-Mixture PLS — auto-selects best preprocessing from operator bank |
AOMPLSClassifier |
AOM-PLS for classification with probability calibration |
AOMRidgeRegressor |
AOM-Ridge with operator-bank selection and internal CV |
AOMRidgeAutoSelector |
Selects the best AOM-Ridge variant under outer CV |
AOMRidgeBlender |
Convex blend of AOM-Ridge variants; strongest general AOM-Ridge recipe |
FastAOMPLSRidge |
Fast screened operator-chain AOM PLS/Ridge |
POPPLSRegressor |
Per-Operator-Per-component PLS — different operator per component via PRESS |
POPPLSClassifier |
POP-PLS for classification with probability calibration |
PLSDA |
PLS Discriminant Analysis |
OPLS / OPLSDA |
Orthogonal PLS / OPLS-DA |
MBPLS |
Multi-Block PLS |
DiPLS |
Domain-Invariant PLS |
IKPLS |
Improved Kernel PLS |
FCKPLS |
Fractional Convolution Kernel PLS |
LWPLS |
Locally Weighted PLS |
SparsePLS |
Sparse PLS |
SIMPLS |
SIMPLS algorithm |
from nirs4all.operators.models import AOMPLSRegressor, AOMRidgeBlender, POPPLSRegressor
# Native n4m AOM-PLS: select preprocessing and component count by CV
pipeline = [
KFold(n_splits=5),
{"model": AOMPLSRegressor(max_components=10, cv=5)}
]
# AOM-Ridge Blender: strong split-aware operator-mixture Ridge recipe
pipeline = [
KFold(n_splits=5),
{
"model": AOMRidgeBlender(outer_cv=5, inner_cv=5),
"train_params": {"use_pipeline_folds_for_aom": "required"},
},
]
# Native n4m POP-PLS: selects a different operator per component
pipeline = [
KFold(n_splits=5),
{"model": POPPLSRegressor(max_components=15, cv=5)}
]
Deep Learning
nicon - 1D CNN for NIR classification/regression
decon - 1D CNN for NIR regression
from nirs4all.operators.models import nicon, decon
pipeline = [
MinMaxScaler(),
KFold(n_splits=5),
{"model": decon(n_outputs=1)}
]
See Also
Operator catalog: choose a job, then inspect the method - All available operators
Meta-Model Stacking User Guide - Model stacking and ensembles
Developer Guide - Custom model integration