DirectRS
- class modeva.models.directrs.api.MoDirectRSRegressor(base_model, name=None, construction='C', ridge_alpha=100.0, n_passes=1, n_trees_used=None)[source]
DirectRS post-processor for tree ensemble regressors.
Takes a pre-trained tree ensemble (XGBoost, LightGBM, or CatBoost) and builds a piecewise-linear model that can match or improve the original with per-tree Ridge regression on geometric embeddings φ_t(x) = [1, S’x].
- Parameters:
- base_modelfitted tree ensemble
Pre-trained XGBoost, LightGBM, or CatBoost regressor (or MoDeVa wrapper).
- namestr, optional
Model identifier. Default: “DirectRS”.
- constructionstr, default=”C”
Operator construction for geometry extraction: “A” (gain-weighted), “B” (co-occurrence), “C” (value-weighted), “M” (count).
- ridge_alphafloat, default=100.0
Ridge regularization for per-tree linear heads.
- n_passesint, default=1
Number of backfitting coordinate descent passes.
- n_trees_usedint, optional
Number of trees to use. Default: all trees.
- fit(X, y, sample_weight=None, X_val=None, y_val=None, verbose=False)[source]
Fit DirectRS on training data.
- Parameters:
- Xnp.ndarray of shape (n_samples, n_features)
- ynp.ndarray of shape (n_samples,)
- sample_weightignored (kept for API compatibility)
- X_valnp.ndarray, optional
- y_valnp.ndarray, optional
- verbosebool, default=False
- Returns:
- self
- set_fit_request(*, X_val: bool | None | str = '$UNCHANGED$', sample_weight: bool | None | str = '$UNCHANGED$', verbose: bool | None | str = '$UNCHANGED$', y_val: bool | None | str = '$UNCHANGED$') MoDirectRSRegressor
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:
- X_valstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
X_valparameter infit.- 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.- y_valstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
y_valparameter infit.
- Returns:
- selfobject
The updated object.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') MoDirectRSRegressor
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.api.MoDirectRSClassifier(base_model, name=None, construction='C', ridge_alpha=100.0, n_passes=1, n_trees_used=None)[source]
DirectRS post-processor for tree ensemble classifiers.
Takes a pre-trained tree ensemble classifier and builds a piecewise-linear model using logistic ridge via IRLS (weighted Ridge on working responses in logit space). Predictions use sigmoid for probabilities.
- Parameters:
- base_modelfitted tree ensemble
Pre-trained XGBoost, LightGBM, or CatBoost classifier (or MoDeVa wrapper).
- namestr, optional
Model identifier. Default: “DirectRS-Cls”.
- constructionstr, default=”C”
Operator construction for geometry extraction.
- ridge_alphafloat, default=100.0
Ridge regularization for per-tree linear heads.
- n_passesint, default=1
Number of backfitting coordinate descent passes.
- n_trees_usedint, optional
Number of trees to use. Default: all trees.
- fit(X, y, sample_weight=None, X_val=None, y_val=None, verbose=False)[source]
Fit DirectRS on training data for classification.
- Parameters:
- Xnp.ndarray of shape (n_samples, n_features)
- ynp.ndarray of shape (n_samples,)
- sample_weightignored
- X_valnp.ndarray, optional
- y_valnp.ndarray, optional
- verbosebool, default=False
- Returns:
- self
- set_decision_function_request(*, calibration: bool | None | str = '$UNCHANGED$') MoDirectRSClassifier
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(*, X_val: bool | None | str = '$UNCHANGED$', sample_weight: bool | None | str = '$UNCHANGED$', verbose: bool | None | str = '$UNCHANGED$', y_val: bool | None | str = '$UNCHANGED$') MoDirectRSClassifier
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:
- X_valstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
X_valparameter infit.- 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.- y_valstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
y_valparameter infit.
- Returns:
- selfobject
The updated object.
- set_predict_proba_request(*, calibration: bool | None | str = '$UNCHANGED$') MoDirectRSClassifier
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$') MoDirectRSClassifier
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$') MoDirectRSClassifier
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.