scikit-learnxgbclassifier

How to pass XGBoost fit parameters when using OneVsRestClassifier?


I want to pass the fit's parameters of xgboost through OneVsRestClassifier's fit method.

clf = OneVsRestClassifier( XGBClassifier(objective='binary:logistic', seed=0))
# Want to pass `eval_set` and 'eval_metric' to xgboost model.
clf.fit(X_train, y_train, estimator__eval_metric='aucpr', estimator__eval_set= eval_set_xgboost)

Error: fit() got an unexpected keyword argument 'estimator__eval_metric'

Can you please help me how can I pass the XGBoost fit parameters using OneVsRestClassifier fit method?


Solution

  • XGBoost by default handles the multi-class classification. Refer to this example for more explanations.

    With the current framework, you cannot pass fit_params for OneVsRestClassifier. Refer to this issue for more details.

    May be, if you can share your intention for wrapping with OneVsRestClassifier, we can guide you appropriately.

    Update:

    I don't think wrapping with one Vs rest classifier would reduce the overfitting.

    Use the simple XGBoost but fine-tune the hyper-parameters.

    The other best options for reducing the overfitting is briefed here