nirs4all.pipeline.dagml.pipeline_objective module
Shared native DAG-ML pipeline objective substrate.
P4 is the seam between a typed tuning contract and optimizer adapters. This module does not run Optuna or n4m. It evaluates one explicit trial by cloning an estimator, applying candidate parameter patches, fitting through the estimator’s own native compiler/client path, and extracting one score through an injected callback. Optimizer adapters in P5 can then consume the same score tape.
- class nirs4all.pipeline.dagml.pipeline_objective.PipelineObjective(estimator: Any, tuning: DagMLTuningSpec | Mapping[str, Any], *, score_extractor: Callable[[Any], float], clone_estimator: bool = True)[source]
Bases:
objectEvaluate one fixed-topology trial through a supplied estimator seam.
- class nirs4all.pipeline.dagml.pipeline_objective.PipelineObjectiveResult(trial_index: int, params: Mapping[str, Any], score: float, metric: str, direction: str, tuning_fingerprint: str, diagnostics: Mapping[str, Any])[source]
Bases:
objectResult for one evaluated candidate.
- nirs4all.pipeline.dagml.pipeline_objective.apply_trial_parameter_patch(estimator: Any, path: str, value: Any) None[source]
Apply one fail-closed candidate parameter patch to an estimator.
- nirs4all.pipeline.dagml.pipeline_objective.make_conformal_prediction_score_extractor(metric: str, X_score: Any, y_score: Any, calibration_data: Mapping[str, Any], *, coverage: float = 0.9, sample_ids: Any = None, groups: Any = None, metadata: Any = None) Callable[[Any], float][source]
Build a conformal-aware development score extractor.
This helper is intentionally evaluation-only. For each fitted candidate it:
predicts an explicit development calibration cohort;
fits a temporary split conformal calibrator from that cohort;
predicts the explicit scoring cohort;
evaluates empirical conformal diagnostics on the scoring cohort.
It does not persist the temporary calibrator and does not touch the final calibrator produced by
run(..., calibration=...).
- nirs4all.pipeline.dagml.pipeline_objective.make_prediction_score_extractor(metric: str, X_score: Any, y_score: Any, *, sample_ids: Any = None, groups: Any = None, metadata: Any = None) Callable[[Any], float][source]
Build a
PipelineObjectivescore extractor from explicit score data.The returned callable scores a fitted estimator by calling
estimator.predict(X_score)and evaluating the requested metric againsty_score. The score cohort is supplied explicitly; this helper does not split data, reuse optimizer objective values as test metrics, or infer a validation set. Optionalsample_ids/groups/metadataare validated for row alignment and forwarded topredict()only when the estimator signature accepts them.