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
MoDirectRSRegressorand 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
._coreset).- 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
fitmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.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_weightparameter infit.- verbosestr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
verboseparameter infit.
- Returns:
- selfobject
The updated object.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') MoDirectRSICLRegressor
Request metadata passed to the
scoremethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.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_weightparameter inscore.
- 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
MoDirectRSClassifierand 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
._coreset).- 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_functionmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed todecision_functionif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it todecision_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
calibrationparameter indecision_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
fitmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.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_weightparameter infit.- verbosestr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
verboseparameter infit.
- Returns:
- selfobject
The updated object.
- set_predict_proba_request(*, calibration: bool | None | str = '$UNCHANGED$') MoDirectRSICLClassifier
Request metadata passed to the
predict_probamethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredict_probaif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict_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
calibrationparameter inpredict_proba.
- Returns:
- selfobject
The updated object.
- set_predict_request(*, calibration: bool | None | str = '$UNCHANGED$') MoDirectRSICLClassifier
Request metadata passed to the
predictmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.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
calibrationparameter inpredict.
- Returns:
- selfobject
The updated object.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') MoDirectRSICLClassifier
Request metadata passed to the
scoremethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.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_weightparameter inscore.
- Returns:
- selfobject
The updated object.