nirs4all.controllers.models.pipeline_cv module

Utilities for forwarding pipeline folds to split-aware estimators.

class nirs4all.controllers.models.pipeline_cv.PrecomputedFoldSplitter(folds: tuple[tuple[tuple[int, ...], tuple[int, ...]], ...], n_samples: int | None = None, label: str = 'pipeline')[source]

Bases: object

Picklable sklearn-compatible splitter backed by explicit fold indices.

property fold_ids: ndarray

Return the canonical per-row fold identifiers consumed by n4m.

folds: tuple[tuple[tuple[int, ...], tuple[int, ...]], ...]
for_training_subset(train_indices: Sequence[int], *, label: str | None = None) → PrecomputedFoldSplitter | None[source]

Restrict this splitter to rows selected by train_indices.

train_indices are row positions in the current splitter’s coordinate system. The returned splitter uses positions in X[train_indices].

classmethod from_folds(folds: Iterable[tuple[Sequence[int], Sequence[int]]], *, n_samples: int | None = None, label: str = 'pipeline') → PrecomputedFoldSplitter[source]
get_n_splits(X=None, y=None, groups=None) → int[source]
label: str = 'pipeline'
n_samples: int | None = None
split(X, y=None, groups=None)[source]
property validation_folds: list[list[int]]

Return validation indices in the external-folds format used by AOM_lib.

nirs4all.controllers.models.pipeline_cv.apply_pipeline_folds_to_aom_estimator(estimator: Any, splitter: PrecomputedFoldSplitter | None, *, policy: Any = 'auto', unavailable_reason: str | None = None) → bool[source]

Inject pipeline folds into supported AOM estimator parameters.

Returns True when at least one estimator parameter was changed.

nirs4all.controllers.models.pipeline_cv.pipeline_cv_policy_enabled(policy: Any) → bool[source]

Interpret train_params.use_pipeline_folds_for_aom.

nirs4all.controllers.models.pipeline_cv.pipeline_cv_policy_required(policy: Any) → bool[source]

Return whether missing pipeline folds should fail the fit.