ICL-MoE

class modeva.models.directrs.icl_moe_api.MoDirectRSICLRegressor(directrs_model, name=None, variant='hierarchical', k=50, tau=1.0, ridge_lambda=1.0, top_m=5)[source]

ICL-MoE post-processor for DirectRS regressors.

Takes a fitted MoDirectRSRegressor and builds a soft-gated mixture of experts using kNN attention in the DirectRS stretch embedding space.

Parameters:
directrs_modelMoDirectRSRegressor

A fitted DirectRS regressor (must have ._core set).

namestr, optional

Model identifier. Default: “ICL-MoE”.

variantstr, default=”hierarchical”

One of “point_expert”, “local_linear”, “leaf_expert”, “hierarchical”.

kint, default=50

Number of nearest neighbors for kNN gating.

taufloat, default=1.0

Temperature for softmax gating weights.

ridge_lambdafloat, default=1.0

Regularisation for local linear / residual ridge.

top_mint, default=5

Number of top leaf experts per tree (variant C / hierarchical).

fit(X, y, sample_weight=None, verbose=False)[source]

Fit ICL-MoE on training data.

Parameters:
Xnp.ndarray of shape (n_samples, n_features)
ynp.ndarray of shape (n_samples,)
sample_weightignored (kept for API compatibility)
verbosebool, default=False
Returns:
self
set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$', verbose: bool | None | str = '$UNCHANGED$') MoDirectRSICLRegressor

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see 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.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in fit.

verbosestr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for verbose parameter in fit.

Returns:
selfobject

The updated object.

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

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see 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.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

Returns:
selfobject

The updated object.

class modeva.models.directrs.icl_moe_api.MoDirectRSICLClassifier(directrs_model, name=None, variant='hierarchical', k=50, tau=1.0, ridge_lambda=1.0, top_m=5)[source]

ICL-MoE post-processor for DirectRS classifiers.

Takes a fitted MoDirectRSClassifier and builds a soft-gated mixture of experts using kNN attention in the DirectRS stretch embedding space. Operates in logit space internally; predictions use sigmoid.

Parameters:
directrs_modelMoDirectRSClassifier

A fitted DirectRS classifier (must have ._core set).

namestr, optional

Model identifier. Default: “ICL-MoE-Cls”.

variantstr, default=”hierarchical”

One of “point_expert”, “local_linear”, “leaf_expert”, “hierarchical”.

kint, default=50

Number of nearest neighbors for kNN gating.

taufloat, default=1.0

Temperature for softmax gating weights.

ridge_lambdafloat, default=1.0

Regularisation for local linear / residual ridge.

top_mint, default=5

Number of top leaf experts per tree (variant C / hierarchical).

fit(X, y, sample_weight=None, verbose=False)[source]

Fit ICL-MoE on training data for classification.

Parameters:
Xnp.ndarray of shape (n_samples, n_features)
ynp.ndarray of shape (n_samples,)
sample_weightignored
verbosebool, default=False
Returns:
self
set_decision_function_request(*, calibration: bool | None | str = '$UNCHANGED$') MoDirectRSICLClassifier

Request metadata passed to the decision_function method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to decision_function 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 decision_function.

  • 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.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
calibrationstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for calibration parameter in decision_function.

Returns:
selfobject

The updated object.

set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$', verbose: bool | None | str = '$UNCHANGED$') MoDirectRSICLClassifier

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see 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.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in fit.

verbosestr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for verbose parameter in fit.

Returns:
selfobject

The updated object.

set_predict_proba_request(*, calibration: bool | None | str = '$UNCHANGED$') MoDirectRSICLClassifier

Request metadata passed to the predict_proba method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict_proba 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 predict_proba.

  • 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.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
calibrationstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for calibration parameter in predict_proba.

Returns:
selfobject

The updated object.

set_predict_request(*, calibration: bool | None | str = '$UNCHANGED$') MoDirectRSICLClassifier

Request metadata passed to the predict method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict 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 predict.

  • 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.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
calibrationstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for calibration parameter in predict.

Returns:
selfobject

The updated object.

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

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see 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.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

Returns:
selfobject

The updated object.