nirs4all.operators.models.sklearn.aom_pls_aomlib module

Historical AOMPLSAomlibRegressor class path backed by nirs4all-methods.

The native global AOM selector owns operator/component selection and prediction. The old external aompls package is no longer required. Unsupported historical selection/preprocessing options raise explicitly instead of changing meaning.

class nirs4all.operators.models.sklearn.aom_pls_aomlib.AOMPLSAomlibRegressor(n_components: int = 15, selection: str = 'cv', cv: int = 5, one_se: bool = False, preprocessing: str | None = None, random_state: int | None = None, osc_n_components: int = 1, asls_lam: float = 100000.0, asls_p: float = 0.01, asls_n_iter: int = 10, center: bool = True, external_folds: Any | None = None)[source]

Bases: RegressorMixin, BaseEstimator

Native global AOM-PLS selector with the historical nirs4all class path.

n_components bounds component selection; cv controls internal folds. selection='cv'/'kfold' uses deterministic contiguous folds unless a random_state is supplied, in which case shuffled KFold is used. Explicit external_folds lists must partition the training samples exactly once. center controls native X/Y centering, with scaling disabled explicitly.

Legacy one-SE selection, SPXY/holdout modes and built-in preprocessing are not provided by this native selector and are rejected. Use explicit pipeline preprocessing steps. Their constructor fields remain only so existing saved configurations get clear errors, rather than silently losing parameters.

fit(X: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], y: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], X_val: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None = None, y_val: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None = None) → AOMPLSAomlibRegressor[source]

Fit through the installed nirs4all-methods C ABI binding.

Parameters:
  • X – Training spectra of shape (n_samples, n_features).

  • y – Target values of shape (n_samples,). Multivariate y is not supported by the compact PLS1 backend and is reshaped to 1D after squeezing trailing singleton dimensions.

  • X_val – Unused. Kept for API symmetry with other nirs4all wrappers that accept an optional validation set; the native backend performs operator/K selection internally.

  • y_val – Unused. See X_val.

Returns:

self, with diagnostic attributes populated.

get_params(deep: bool = True) → dict[str, Any][source]

Return constructor parameters for sklearn compatibility.

predict(X: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) → ndarray[tuple[Any, ...], dtype[floating]][source]

Predict target values for X.

Parameters:

X – Spectra of shape (n_samples, n_features).

Returns:

1D array of float predictions of shape (n_samples,).

set_fit_request(*, X_val: bool | None | str = '$UNCHANGED$', y_val: bool | None | str = '$UNCHANGED$') → AOMPLSAomlibRegressor

Configure whether metadata should be requested to be passed to the fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:
  • X_val (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for X_val parameter in fit.

  • y_val (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for y_val parameter in fit.

Returns:

self – The updated object.

Return type:

object

set_params(**params: Any) → AOMPLSAomlibRegressor[source]

Set constructor parameters and return self.

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') → AOMPLSAomlibRegressor

Configure whether metadata should be requested to be passed to the score method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:

sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for sample_weight parameter in score.

Returns:

self – The updated object.

Return type:

object