nirs4all.api.general_explain module

SHAP over a captured scientific predictor, without replaying a legacy runner.

nirs4all.api.general_explain.LINEAR_BACKGROUND_SEED = 0

Background subsampling seed of the exact linear path (the Methods backend default).

nirs4all.api.general_explain.explain_general(model: Any, data: Any, *, name: str, session: Any, verbose: int, plots_visible: bool, n_samples: int | None, explainer_type: str, options: dict[str, Any]) → ExplainResult[source]

Explain the complete frozen raw-input predictor with the selected attribution backend.

Preprocessing and target inverses stay inside the captured predictor. SHAP therefore explains original input columns and original target units, not a terminal estimator with an incorrectly labelled raw feature axis. Multi-output requests expose a labelled selected output, preserving the 2D ExplainResult. explainer_backend="shap" (default) uses the shap package; explainer_backend="methods" uses the nirs4all-methods kernels (see nirs4all.api.methods_explain). Both record a nirs4all.explanation.v1 envelope in ExplainResult.explanation.