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_gbdtrecovers 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
- 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
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.- feature_namesstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
feature_namesparameter 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_request(*, head: bool | None | str = '$UNCHANGED$') MoGBDTKernelRegressor
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:
- headstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
headparameter inpredict.
- Returns:
- selfobject
The updated object.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') MoGBDTKernelRegressor
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.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_probaapplies the sigmoid.- 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
- set_decision_function_request(*, head: bool | None | str = '$UNCHANGED$') MoGBDTKernelClassifier
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:
- headstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
headparameter indecision_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
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.- feature_namesstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
feature_namesparameter 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(*, head: bool | None | str = '$UNCHANGED$') MoGBDTKernelClassifier
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:
- headstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
headparameter inpredict_proba.
- Returns:
- selfobject
The updated object.
- set_predict_request(*, head: bool | None | str = '$UNCHANGED$') MoGBDTKernelClassifier
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:
- headstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
headparameter inpredict.
- Returns:
- selfobject
The updated object.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') MoGBDTKernelClassifier
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.