GBDT Leaf Kernel

class modeva.models.kernel_xgb.api.MoGBDTKernelRegressor(base_model, name=None, kernel_topk=200, kernel_rho=1.0, ridge_lambda=1.0, n_clusters=8, gate_mode='defensive', nystrom_landmarks=300, residual_gamma_max=1.5, gate_tmin=1.96, shrink_tau=20.0, random_state=0)[source]

GBDT-as-learned-kernel regressor with five interchangeable heads.

Wraps a pre-trained tree ensemble and exposes prediction heads on the induced leaf kernel. Default head exact_gbdt recovers the base GBDT prediction exactly via the generalized Nadaraya-Watson representation (Theorem 1 of the GBDT-GNW paper).

Parameters:
base_modelfitted XGBoost regressor (or MoXGBRegressor wrapper)

Pre-trained ensemble whose leaf geometry will be re-used.

namestr, optional

Identifier. Default: "GBDTKernel".

kernel_topkint, default=200

Number of training neighbors used by the NW heads.

kernel_rhofloat, default=1.0

Sharpening exponent: w_i \propto K(x, x_i)^rho.

ridge_lambdafloat, default=1.0

KRR regularization on the leaf one-hot basis.

n_clustersint, default=8

Number of behavioral cohorts for cluster-gated residual repair.

gate_mode{“defensive”, “adaptive”}, default=”defensive”
nystrom_landmarksint, default=300
residual_gamma_maxfloat, default=1.5
gate_tminfloat, default=1.96
shrink_taufloat, default=20.0
random_stateint, default=0
fit(X, y, sample_weight=None, X_val=None, y_val=None, feature_names=None, verbose=False)[source]
predict(X, head='exact_gbdt')[source]

Predict in target space using the chosen head.

set_fit_request(*, X_val: bool | None | str = '$UNCHANGED$', feature_names: bool | None | str = '$UNCHANGED$', sample_weight: bool | None | str = '$UNCHANGED$', verbose: bool | None | str = '$UNCHANGED$', y_val: bool | None | str = '$UNCHANGED$') MoGBDTKernelRegressor

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:
X_valstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for X_val parameter in fit.

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

Metadata routing for feature_names parameter in fit.

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.

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

Metadata routing for y_val parameter in fit.

Returns:
selfobject

The updated object.

set_predict_request(*, head: bool | None | str = '$UNCHANGED$') MoGBDTKernelRegressor

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:
headstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for head parameter in predict.

Returns:
selfobject

The updated object.

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

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.kernel_xgb.api.MoGBDTKernelClassifier(base_model, name=None, kernel_topk=200, kernel_rho=1.0, ridge_lambda=1.0, n_clusters=8, gate_mode='defensive', nystrom_landmarks=300, residual_gamma_max=1.5, gate_tmin=1.96, shrink_tau=20.0, random_state=0)[source]

GBDT-as-learned-kernel binary classifier with five heads.

Same parameters and head menu as MoGBDTKernelRegressor. All predictions are produced in logit space internally; predict_proba applies the sigmoid.

decision_function(X, head='exact_gbdt')[source]

Margin / logit prediction under the chosen head.

fit(X, y, sample_weight=None, X_val=None, y_val=None, feature_names=None, verbose=False)[source]
predict(X, head='exact_gbdt')[source]

Model predictions, calling the child class’s ‘_predict’ method.

Parameters:
Xnp.ndarray of shape (n_samples, n_features)

Feature matrix for prediction.

calibrationbool, default=True

If True, will use calibrated probability if calibration is done. Otherwise, will use raw probability.

Returns:
np.ndarray: The (calibrated) final prediction
predict_proba(X, head='exact_gbdt')[source]

Class probabilities under the chosen head.

set_decision_function_request(*, head: bool | None | str = '$UNCHANGED$') MoGBDTKernelClassifier

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:
headstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for head parameter in decision_function.

Returns:
selfobject

The updated object.

set_fit_request(*, X_val: bool | None | str = '$UNCHANGED$', feature_names: bool | None | str = '$UNCHANGED$', sample_weight: bool | None | str = '$UNCHANGED$', verbose: bool | None | str = '$UNCHANGED$', y_val: bool | None | str = '$UNCHANGED$') MoGBDTKernelClassifier

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:
X_valstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for X_val parameter in fit.

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

Metadata routing for feature_names parameter in fit.

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.

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

Metadata routing for y_val parameter in fit.

Returns:
selfobject

The updated object.

set_predict_proba_request(*, head: bool | None | str = '$UNCHANGED$') MoGBDTKernelClassifier

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:
headstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for head parameter in predict_proba.

Returns:
selfobject

The updated object.

set_predict_request(*, head: bool | None | str = '$UNCHANGED$') MoGBDTKernelClassifier

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:
headstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for head parameter in predict.

Returns:
selfobject

The updated object.

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

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.