nirs4all.api.native_training module

Explicit public entry point for the first fully-native training lane.

The broad nirs4all.run() compatibility surface still contains legacy workflow features that are not expressible by the portable runtime. This module deliberately exposes only the proven raw-array lane instead of silently re-running that workflow through PipelineRunner during export.

nirs4all.api.native_training.fit_native_pipeline(pipeline: list[Any], X: Any, y: Any, *, sample_ids: Sequence[str], groups: Sequence[Any] | None = None, metadata: Mapping[str, Sequence[Any]] | None = None, selection_metric: str = 'rmse', selection_objective: str = 'minimize', package_id: str | None = None, dagml_module: str = 'dag_ml', native_client: Any = None, training_losses: tuple[Mapping[str, Any], ...] = (), local_implementations: Any = None, methods_library_path: str | None = None, methods_hpo_operation: Mapping[str, Any] | None = None, seed: int = 12345, retrain_lineage: NativeRetrainLineage | None = None) → DagMLPipelineEstimator[source]

Fit the supported raw-array pipeline entirely through DAG-ML.

This is an intentionally narrow native API: either one KFold/PLS model or an exact nested-OOF stack of two-or-more PLS branches followed by default sklearn Ridge(alpha=...). The Ridge features are scheduler-owned OOF predictions; the raw matrix is retained only for identity/target attestation. Inputs remain finite 2-D X with finite targets. sample_ids are mandatory because the resulting Package V2 and Archive V2 require stable identities for every later PREDICT cohort.

The installed DAG-ML runtime must produce a portable_required Methods Package V2 with one durable N4MM refit artifact. Host-sidecar/joblib results are refused before this function returns: they cannot be replayed or exported as a native archive. A successful estimator retains the exact native TrainingResult, TrainingOutcome and Package V2. Its export_native_archive() method writes Archive V2 directly; it never invokes the legacy runner or fits the model a second time. With nirs4all[native], the bundled nirs4all-methods runtime is discovered automatically; methods_library_path remains an explicit deployment override.

nirs4all.api.native_training.run_native_methods(pipeline: list[Any], dataset: Mapping[str, Any], *, name: str = '', session: Any = None, save_artifacts: bool = True, save_charts: bool = False, plots_visible: bool = False, random_state: int | None = None, refit: bool | None = True, cache: Any = None, project: str | None = None, report_naming: str = 'nirs', results_path: Any = None, runner_kwargs: Mapping[str, Any] | None = None, tuning: Any = None, calibration: Any = None, terminal_predict: Mapping[str, Any] | None = None, retrain_lineage: NativeRetrainLineage | None = None) → NativeMethodsRunResult[source]

Run the verified public Methods training subset without a legacy runner.

The accepted dataset is exactly {X, y, sample_ids} with optional groups and metadata. Charts, workspaces, sessions, cache, tuning, and non-native refit policies remain explicit capability refusals rather than becoming ignored legacy arguments.

tuning is deliberately a separate, strict native operation rather than the older Python objective adapter. Its V1 shape is {"engine": "methods-hpo", "trials": N}, optionally selecting the attested random/tpe sampler and none/median pruner. A later call may add resume_package_json obtained from NativeMethodsRunResult.hpo_resume_package_json(); it is the complete signed package, never a caller-provided checkpoint. DAG-ML owns all trial execution, resume validation, SELECT, native incumbent attestation, and the single selected rerun/refit.