nirs4all.pipeline.dagml.fit_identity module
Fit-time sample identity normalization for native DAG-ML estimator paths.
The existing bridge mints identities from SpectroDataset content. The
sklearn-style native estimator also receives raw X/y arrays, so P2 needs
an explicit, testable identity frame before P3 compiles data envelopes. This
module does not build DAG-ML contracts; it only validates row-aligned identity,
group and metadata inputs and exposes helper maps in the shape the existing
envelope builders already consume.
- class nirs4all.pipeline.dagml.fit_identity.DagMLCalibrationIdentityFrame(n_samples: int, sample_ids: tuple[str, ...], groups: tuple[str | None, ...], metadata_rows: tuple[dict[str, Any], ...], explicit_sample_ids: bool, data_content_fingerprint: str, target_content_fingerprint: str, fingerprint: str)[source]
Bases:
objectExplicit PREDICT identities plus an attested measured-target proof.
Calibration is evaluated through a PREDICT replay so a Methods provider does not receive targets as execution inputs. Unlike ordinary inference, its replay provenance must still bind the separately supplied measured truth. The target fingerprint has the same raw-array profile as native training and is never synthesized from a sentinel.
- group_by_sample_id() dict[str, str][source]
Return non-null groups keyed by the exact public sample id.
- nirs4all.pipeline.dagml.fit_identity.feature_content_fingerprint(X: Any) str[source]
Return the native X-only content identity for an inference cohort.
This is deliberately the same byte-level identity used by the raw-array DAG-ML lowering for its
data_content_fingerprint. Absence of a target is represented only by the nullable replay target field; it must never change the feature identity through a sentinel marker.
- nirs4all.pipeline.dagml.fit_identity.normalize_calibration_identity(X: Any, y: Any, *, sample_ids: Sequence[Any] | None = None, groups: Sequence[Any] | None = None, metadata: Mapping[str, Sequence[Any]] | Sequence[Mapping[str, Any]] | None = None, require_explicit_sample_ids: bool = False) DagMLCalibrationIdentityFrame[source]
Bind a measured calibration cohort without changing PREDICT inputs.
- nirs4all.pipeline.dagml.fit_identity.normalize_fit_identity(X: Any, y: Any, *, sample_ids: Sequence[Any] | None = None, groups: Sequence[Any] | None = None, metadata: Mapping[str, Sequence[Any]] | Sequence[Mapping[str, Any]] | None = None, require_explicit_sample_ids: bool = False) DagMLFitIdentityFrame[source]
Normalize sample identities, groups and metadata for a native fit.
Without explicit
sample_idsthis emits compatibility ids derived from a content fingerprint plus row position. They are deterministic for the provided arrays but are not strong enough for future leakage/exchangeability claims; callers can setrequire_explicit_sample_ids=Trueto fail closed.
- nirs4all.pipeline.dagml.fit_identity.normalize_predict_identity(X: Any, *, sample_ids: Sequence[Any] | None = None, groups: Sequence[Any] | None = None, metadata: Mapping[str, Sequence[Any]] | Sequence[Mapping[str, Any]] | None = None, require_explicit_sample_ids: bool = False) DagMLPredictIdentityFrame[source]
Normalize an X-only PREDICT cohort without creating a target sentinel.
Compatibility sample ids are deterministic over features only. Callers serving persisted artifacts can require explicit ids, which is the only mode suitable for relation-sensitive replay and presentation joins.