Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the What you really need to know section for the big picture.
julearn.models.xgb_cvearlystopping.XGBClassifierCVEarlyStopping¶
- class julearn.models.xgb_cvearlystopping.XGBClassifierCVEarlyStopping(test_size, early_stopping_rounds, **kwargs)¶
XGBClassifier with cross-validated early stopping.
A wrapper for XGBoost that performs early stopping using a cross-validation split of the data. The model is first trained on a training set with early stopping based on a validation set, and then refit on the full data using the best number of iterations found.
- Parameters:
test_size (
float|int|None) – The proportion of the data to use as the validation set for early stopping. If groups is used on fit, this parameter refers to the number of groups, otherwise it refers to the number of samples. If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to include in the test split. If int, represents the absolute number. If None, the value is set to the complement of the train size. If train_size is also None, it will be set to 0.25 in the case of non-grouped data or 0.2 for grouped data (scikit-learn’s defaults for train_test_split and GroupShuffleSplit).early_stopping_rounds (
int) – The number of rounds to use for early stopping.**kwargs (
Any) – Extra keyword arguments to pass to the XGBClassifier.
- __init__(test_size, early_stopping_rounds, **kwargs)¶
- fit(X, y, groups=None)¶
Fit the model.
- Parameters:
- Returns:
The fitted model.
- predict(X)¶
Predict using the model.
- get_metadata_routing()¶
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
A
MetadataRequestencapsulating routing information.
- get_params(deep=True)¶
Get the parameters of the model.
- Parameters:
deep (
bool, default:True) – If True, will return the parameters for this model and contained subobjects that are estimators (default is True).- Returns:
Parameter names mapped to their values.
- predict_proba(X)¶
Predict probabilities using the model.
- score(X, y, sample_weight=None)¶
Return accuracy on provided data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
- Parameters:
X (array-like of shape (n_samples, n_features)) – Test samples.
y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True labels for X.
sample_weight (array-like of shape (n_samples,), default=None) – Sample weights.
- Returns:
Mean accuracy of
self.predict(X)w.r.t. y.
- set_fit_request(*, groups: bool | None | str = '$UNCHANGED$') XGBClassifierCVEarlyStopping¶
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the 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.
- Parameters:
groups (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
groupsparameter infit.- Returns:
The updated object.
- set_params(**params)¶
Set the parameters of the model.
- Parameters:
**params (
Any) – Estimator parameters.- Returns:
The model with updated parameters.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') XGBClassifierCVEarlyStopping¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the 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.
- Parameters:
sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
sample_weightparameter inscore.- Returns:
The updated object.